/*
 * x-auto operations console.
 * One charcoal system: tokens -> base -> controls -> primitives -> shell -> pages -> dialogs -> responsive.
 * Type scale (px): 13 body, 12 secondary, 11 smallest (badges, captions), 14 section, 17 page title, 22 KPI.
 * Nothing here scales the page (no zoom / transform): sizes are set where they are used.
 */

/* ---- tokens ---- */
:root {
  color-scheme: dark;
  --font: Inter, "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
  --fs-body: 13px;
  --fs-sub: 12px;
  --fs-min: 11px;
  --fs-section: 14px;
  --fs-title: 17px;
  --fs-kpi: 22px;
  --bg: #14171c;
  --rail: #181b21;
  --surface: #1b1f27;
  --surface-2: #222732;
  --surface-3: #2b3140;
  --border: #2e3440;
  --border-strong: #3c4352;
  --text: #e8eaf0;
  --muted: #a8b0c0;
  --faint: #8d96a8;
  --accent: #7c73ff;
  --accent-solid: #6155df;
  --accent-line: #8d84ff;
  --accent-bg: #2a2650;
  --accent-text: #d3cdff;
  --cyan: #4cc9ec;
  --amber: #f3bf61;
  --green: #5acaa1;
  --red: #f08091;
  --ok-bg: #1d3a33;
  --ok-text: #7fd9b8;
  --warn-bg: #3b3220;
  --warn-text: #efc986;
  --err-bg: #432a34;
  --err-text: #f0a0b0;
  --radius: 6px;
}

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-body) / 1.5 var(--font); font-synthesis: none; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: var(--fs-title); }
h2 { font-size: var(--fs-section); }
h3 { font-size: var(--fs-body); }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
a { color: var(--cyan); }
small { font-size: var(--fs-sub); color: var(--muted); }
.muted { color: var(--muted); }
.danger { color: var(--red); }
.warn { color: var(--amber); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* ---- controls ---- */
button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button {
  min-height: 28px; padding: 4px 10px; cursor: pointer; line-height: 1.4; font-weight: 500;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
button:hover { background: var(--surface-3); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { color: #fff; font-weight: 600; background: var(--accent-solid); border-color: var(--accent-line); }
button.primary:hover { background: #7165ec; }
button.small { min-height: 24px; padding: 1px 8px; font-size: var(--fs-sub); }
button.link { min-height: 0; padding: 0 2px; border: 0; background: none; color: var(--cyan); font-size: var(--fs-sub); }
button.link:hover { text-decoration: underline; background: none; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 30px; padding: 4px 8px;
  background: #14181f; color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
input::placeholder, textarea::placeholder { color: #7f889c; }
select option { background: var(--surface); color: var(--text); }
textarea { min-height: 72px; resize: vertical; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type="date"] { width: auto; color-scheme: dark; }
:focus-visible { outline: 2px solid #a39dff; outline-offset: 1px; }
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } }

/* ---- primitives ---- */
.badge, .chip, .tag, .sns-tag {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 0 6px; border-radius: 4px;
  font-size: var(--fs-min); line-height: 1.6; white-space: nowrap; background: #2f3542; color: #c3cad8;
}
.badge { padding: 1px 7px; }
.tag { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }
.sns-tag { background: #2a3140; color: #c9d2e6; }
.badge.ok, .chip.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn, .chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.error, .chip.error { background: var(--err-bg); color: var(--err-text); }
.state-dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #96a0b3; }
.state-dot.ok { background: var(--green); }
.state-dot.warn { background: var(--amber); }
.state-dot.error { background: var(--red); }
.row, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.actions select { width: auto; min-width: 140px; }
.panel { position: relative; margin-bottom: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.panel-head { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: var(--fs-section); font-weight: 650; }
.panel-head .link { margin-left: auto; }
details.panel > summary.panel-head { cursor: pointer; }
details.panel > summary.panel-head::before { content: ""; flex: none; border-style: solid; border-width: 4px 0 4px 6px; border-color: transparent transparent transparent var(--muted); }
details.panel[open] > summary.panel-head::before { transform: rotate(90deg); }
.panel-body { padding: 12px; }
.panel-note { color: var(--muted); font-size: var(--fs-sub); }
.panel > p.panel-note { margin: 0; padding: 6px 12px 0; }
.panel-foot { margin: 0; padding: 6px 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-sub); }
.notice, .error-message {
  margin: 0 0 10px; padding: 8px 12px; border: 1px solid #384a65; border-radius: var(--radius);
  background: #242f43; color: #b4d2f2; font-size: var(--fs-sub); line-height: 1.6;
}
.error-message { background: #3a252e; color: #f2a8b7; border-color: #623a49; }
.notice button, .error-message button { margin-left: 8px; }
.empty { padding: 20px 12px; text-align: center; color: var(--muted); font-size: var(--fs-sub); line-height: 1.7; }
.loading { padding: 16px; color: var(--muted); }
#page-content[aria-busy="true"] { opacity: .55; transition: opacity .15s; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-sub); }
.table-scroll { position: relative; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid #2b313c; }
th { background: #1f2430; color: var(--muted); font-size: var(--fs-sub); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

/* ---- shell: sidebar ---- */
.layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100vh; }
.workspace { min-width: 0; }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; height: 100vh; min-width: 0;
  padding: 12px 12px 8px; background: var(--rail); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.brand-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #38334e; border: 1px solid #60578a; color: #ebe8ff; font-size: 15px; font-weight: 700; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.brand small { margin-left: auto; color: var(--faint); font-size: var(--fs-min); letter-spacing: .1em; }
.main-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.main-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 44px; padding: 5px 2px; color: var(--muted); font-size: var(--fs-min); background: var(--surface); border-color: var(--border); }
.main-nav button span { color: var(--cyan); font-size: 15px; line-height: 1; }
.main-nav button span svg { display: block; }
.main-nav button[data-page="attention"] span { color: var(--amber); }
.main-nav button[aria-current="page"] { color: var(--accent-text); background: var(--accent-bg); border-color: #6d63c4; }
.main-nav button[aria-current="page"] span { color: #c3baff; }
.account-browser { display: flex; flex: 1; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; padding-top: 8px; border-top: 1px solid var(--border); }
.browser-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 4px; }
.browser-head h2 { font-size: var(--fs-body); font-weight: 650; }
.browser-summary { color: var(--muted); font-size: var(--fs-sub); white-space: nowrap; }
.browser-search { display: block; }
.platforms { display: flex; gap: 2px; }
.platforms button { flex: 1 1 auto; min-width: 0; min-height: 26px; padding: 2px 4px; color: var(--muted); font-size: var(--fs-sub); background: transparent; border-color: transparent; }
.platforms button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-bg); border-color: #5c5087; }
.account-groups { position: relative; flex: 1; min-height: 0; overflow: auto; padding-right: 2px; scrollbar-width: thin; scrollbar-color: #454c5b transparent; }
.owner-group + .owner-group { margin-top: 6px; }
.owner-group-heading { position: sticky; top: 0; z-index: 1; background: var(--rail); }
.owner-scope { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 28px; padding: 3px 6px; color: #d8dce6; font-size: var(--fs-sub); font-weight: 650; text-align: left; background: var(--rail); border: 0; border-radius: 5px; }
.owner-scope:hover { background: #242a35; }
.owner-scope[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-bg); }
.owner-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-count { flex: none; min-width: 24px; padding: 0 5px; color: var(--muted); font-size: var(--fs-min); font-weight: 500; text-align: center; background: #2c3340; border-radius: 4px; }
.account-row { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 40px; margin: 1px 0; padding: 4px 6px; text-align: left; color: var(--text); background: transparent; border: 1px solid transparent; border-left: 3px solid transparent; border-radius: var(--radius); }
.account-row:hover { background: #232936; }
.account-row[aria-pressed="true"] { color: #fff; background: var(--accent-bg); border-color: #4d4590; border-left-color: var(--accent-line); }
.account-row[aria-pressed="true"] .account-row-sub { color: #d6d0fa; }
.account-avatar { display: grid; flex: none; place-items: center; width: 24px; height: 24px; color: #ccd3e1; font-size: var(--fs-min); font-weight: 700; background: #252b36; border: 1px solid #445061; border-radius: 50%; }
.account-avatar.large { width: 36px; height: 36px; font-size: var(--fs-sub); }
.account-avatar.platform-youtube { color: #f6a2ae; background: #372831; border-color: #5a3945; }
.account-avatar.platform-instagram { color: #dcb0ed; background: #32253e; border-color: #553667; }
.account-avatar.platform-tiktok { color: #89e2dc; background: #213638; border-color: #305054; }
.account-row-body { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; }
.account-row-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.account-audience { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.account-audience.unavailable { color: var(--faint); font-size: var(--fs-min); font-weight: 400; }
.account-row-sub { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: var(--fs-min); }
/* The shared prefix of a long ID may shrink; its distinguishing tail never does. */
.account-native { display: flex; flex: 1; min-width: 0; white-space: nowrap; }
.native-name { flex: 0 100 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.native-name::after { content: "\00a0·\00a0"; }
.id-head { flex: 0 10 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.id-tail { flex: none; }
.account-state { display: inline-flex; flex: none; align-items: center; gap: 4px; }
.account-state.warn { color: var(--warn-text); }
.account-state.error { color: var(--err-text); }
.pinned-selection { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid #46405a; }
.pinned-selection > small { display: block; padding: 2px 6px; color: #c3bafa; font-size: var(--fs-min); }
.empty-owner { display: block; padding: 2px 8px 4px 34px; color: var(--faint); font-size: var(--fs-min); }
.sidebar .footer { display: flex; align-items: center; gap: 6px; padding: 8px 4px 0; color: var(--muted); font-size: var(--fs-min); border-top: 1px solid var(--border); }
.footer > span:last-child { margin-left: auto; color: var(--faint); }

/* ---- shell: workspace chrome (top bar, selected account, tabs + route state) ---- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 48px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.page-title { margin-right: 4px; font-size: var(--fs-title); font-weight: 650; letter-spacing: -.01em; }
.scope-controls { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.owner select { width: 200px; max-width: 100%; }
.range { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sub); }
.range label { white-space: nowrap; }
.range input { width: 130px; min-height: 28px; padding: 3px 6px; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }
.selected-context { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: linear-gradient(115deg, #262a36, #1d2129 70%); border-bottom: 1px solid var(--border); }
.selected-context.unavailable { gap: 12px; }
.selected-context.unavailable .notice { flex: 1; margin: 0; }
.context-identity { flex: 1; min-width: 0; }
.context-identity h2 { font-size: 15px; overflow-wrap: anywhere; }
.context-identity p { font-size: var(--fs-sub); overflow-wrap: anywhere; }
.context-state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sub); }
.context-state strong { color: var(--text); font-weight: 600; }
.audience { display: flex; flex: none; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; max-width: 340px; }
.audience-main { color: var(--muted); font-size: var(--fs-sub); }
.audience strong { color: #f1efff; font-size: var(--fs-kpi); font-variant-numeric: tabular-nums; }
.audience-delta { color: var(--muted); font-size: var(--fs-sub); }
.audience-delta.ok { color: var(--green); }
.audience-delta.warn { color: var(--amber); }
.audience small { width: 100%; }
.context-actions { display: flex; flex: none; flex-wrap: wrap; gap: 6px; }
.subbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.workspace-tabs { display: flex; gap: 14px; }
.workspace-tabs button { min-height: 34px; padding: 7px 2px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; }
.workspace-tabs button:hover { color: #f0edff; background: transparent; }
.workspace-tabs button[aria-current="page"] { color: var(--accent-text); border-bottom-color: var(--accent-line); }
.source-strip { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 4px 0; }
.source-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; color: var(--muted); font-size: var(--fs-min); line-height: 1.6; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; }
.source-chip.warn { color: var(--warn-text); background: var(--warn-bg); border-color: #54482c; }
.source-chip.error { color: var(--err-text); background: var(--err-bg); border-color: #69394a; }
#save-outcome:not(:empty), .focus-notice { margin: 8px 16px 0; }
#save-outcome .notice { margin: 0; }
.focus-notice { margin-bottom: 0; }
.content { max-width: 1680px; margin: 0 auto; padding: 12px 16px 32px; }

/* ---- pages: shared bar ---- */
.page-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 10px; }
.page-controls { display: flex; flex: 1 1 320px; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-controls select { width: 170px; }
.page-note { flex: 1 1 280px; margin: 0; color: var(--muted); font-size: var(--fs-sub); }
.page-actions { display: flex; gap: 6px; margin-left: auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar input { width: 260px; max-width: 100%; }
.toolbar select { width: 170px; }

/* ---- pages: overview dashboard ---- */
.scope-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0 0 8px; color: var(--muted); font-size: var(--fs-sub); }
.scope-line strong { color: var(--text); font-size: var(--fs-body); font-weight: 600; }
.scope-label { color: var(--faint); }
.scope-loaded { margin-left: auto; color: var(--faint); font-size: var(--fs-min); }
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 7px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.kpi-label { color: var(--muted); font-size: var(--fs-sub); }
.kpi-value { color: #f1efff; font-size: var(--fs-kpi); font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-unit { margin-left: 3px; color: var(--muted); font-size: var(--fs-sub); font-weight: 400; }
.kpi.warn .kpi-value { color: var(--amber); }
.kpi.unknown .kpi-value { color: var(--faint); }
.kpi-note { color: var(--faint); font-size: var(--fs-min); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 28%, 400px); gap: 10px; align-items: start; }
.dash-grid > .posts-panel { grid-column: 1; grid-row: 1; margin-bottom: 0; }
.dash-side { grid-column: 2; grid-row: 1; min-width: 0; }
.dash-side .panel:last-child { margin-bottom: 0; }
.attention-row { display: flex; align-items: flex-start; gap: 8px; padding: 7px 12px; border-bottom: 1px solid #2b313c; }
.attention-row:last-of-type { border-bottom: 0; }
.attention-main { flex: 1; min-width: 0; }
.attention-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; color: var(--muted); font-size: var(--fs-sub); }
.attention-meta strong { color: var(--text); font-weight: 600; }
.attention-account { color: var(--text); }
.attention-reason { margin: 2px 0 0; color: #d5d9e3; font-size: var(--fs-sub); overflow-wrap: anywhere; }
.readiness-row { display: grid; grid-template-columns: 112px 52px minmax(0, 1fr); align-items: center; gap: 4px 8px; padding: 6px 12px; border-bottom: 1px solid #2b313c; }
.readiness-row:last-child { border-bottom: 0; }
.readiness-name { display: flex; align-items: center; gap: 8px; }
.readiness-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.readiness-issues { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---- pages: posts table (summary rows on the overview, detail rows on the posts page) ---- */
.metrics-table td > strong, .metrics-table td > small { display: block; }
.metrics-table td > .sns-tag { margin-bottom: 2px; }
.posts-table { table-layout: fixed; }
.posts-table th:nth-child(1) { width: 112px; }
.posts-table th:nth-child(2) { width: 116px; }
.posts-table th:nth-child(3) { width: 26%; min-width: 200px; }
.posts-table th:nth-child(5) { width: 150px; }
.posts-table td { font-size: var(--fs-body); }
.col-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-target strong { margin: 0 6px 0 6px; font-weight: 600; }
.col-target small { margin-right: 6px; }
.col-body small { display: block; margin-top: 2px; }
.col-body small.danger { color: var(--red); white-space: normal; }
.col-actions .actions { gap: 4px; }
.post-text { color: var(--muted); }
.posts-panel.dense .posts-table th:nth-child(5) { width: 56px; }
.posts-panel.dense td { padding-top: 5px; padding-bottom: 5px; }
.posts-panel.dense .col-target, .posts-panel.dense .col-body { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.posts-panel.dense .col-body small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.posts-panel.dense .post-line { display: flex; gap: 8px; min-width: 0; }
.posts-panel.dense .post-title { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.posts-panel.dense .post-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.posts-panel:not(.dense) .post-title { display: block; overflow-wrap: anywhere; }
/* The posts page is the detail view: the saved text is shown in full (the overview rows are the summary). */
.posts-panel:not(.dense) .post-text { display: block; overflow-wrap: anywhere; white-space: pre-wrap; }
.posts-panel:not(.dense) td { vertical-align: top; padding-top: 8px; padding-bottom: 8px; }

/* ---- pages: people, drafts, settings ---- */
.person-heading small { color: var(--muted); font-size: var(--fs-sub); }
.person-heading .actions { margin-left: auto; }
.person-empty { margin: 0; padding: 8px 12px; color: var(--muted); font-size: var(--fs-sub); }
.account-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; min-width: 0; padding: 10px; }
.account-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; min-width: 0; padding: 8px 10px; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.account-card details { grid-column: 1 / -1; min-width: 0; }
.account-card details p { margin: 6px 0; font-size: var(--fs-sub); }
.account-card-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.account-card-state { color: var(--muted); font-size: var(--fs-sub); }
.drafts { display: grid; gap: 8px; }
.draft-card { padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.draft-card p { margin: 6px 0; white-space: pre-wrap; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.settings-row p { margin: 4px 0 0; font-size: var(--fs-sub); }

/* ---- pages: calendar, analytics, inbox ---- */
.calendar-labels { display: grid; grid-template-columns: repeat(7, 1fr); padding: 6px; color: var(--muted); font-size: var(--fs-sub); text-align: center; background: #1f2430; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); }
.day { min-height: 92px; padding: 6px; overflow-wrap: anywhere; background: var(--surface); }
.day > strong { color: var(--muted); font-size: var(--fs-sub); }
.calendar-event { display: block; width: 100%; margin-top: 5px; padding: 4px 6px; color: #e6e1ff; font-size: var(--fs-sub); font-weight: 400; line-height: 1.4; text-align: left; background: #2a2850; border: 0; border-left: 3px solid var(--accent-line); border-radius: 4px; }
.calendar-event small { display: block; color: #cbc5f2; font-size: var(--fs-min); }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.cap-card { padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.cap-card h3 { margin-bottom: 2px; font-size: var(--fs-body); }
.capability { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.capability p { margin: 4px 0; overflow-wrap: anywhere; font-size: var(--fs-sub); }
.inbox-item { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.inbox-item textarea { margin: 8px 0; min-height: 64px; }
.message { margin: 8px 0; padding: 8px 10px; overflow-wrap: anywhere; white-space: pre-wrap; background: #252b37; border-radius: var(--radius); }
.message small { display: block; margin-bottom: 2px; }
.comparison { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.comparison article { padding: 10px; background: #242a36; border-radius: var(--radius); }
.comparison strong { display: block; margin-top: 4px; }

/* ---- dialogs and forms ---- */
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > span { color: var(--muted); font-size: var(--fs-sub); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.check input { margin-top: 3px; }
.target { margin: 8px 0; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.target.unready { background: #22262e; }
.target summary { cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.target .target-fields { padding-top: 10px; }
.target details { margin-top: 8px; }
.target-select { display: flex; align-items: flex-start; gap: 8px; }
.target-select > div, .retained-target-notice { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.target-select input { margin-top: 3px; }
.form-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog { width: min(780px, calc(100vw - 24px)); max-height: 90vh; padding: 0; color: var(--text); background: #1e232c; border: 1px solid var(--border-strong); border-radius: 12px; }
dialog::backdrop { background: #080a10c9; backdrop-filter: blur(3px); }
.modal-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; background: #1e232c; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: var(--fs-title); }
.modal-body { padding: 14px 16px; }
.login { width: min(410px, calc(100vw - 24px)); margin: 12vh auto 0; padding: 24px; background: #1e232c; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 20px 70px #0005; }
.login h1 { margin-bottom: 6px; color: #e2dcff; font-size: 19px; }
.login .primary { width: 100%; }
#unified-toast { position: fixed; bottom: 16px; left: 50%; z-index: 5; max-width: calc(100vw - 24px); padding: 9px 14px; color: #f1edff; background: #38304c; border: 1px solid #7d6eb6; border-radius: 8px; transform: translateX(-50%); }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 256px minmax(0, 1fr); }
  .platforms button { font-size: var(--fs-min); }
  .topbar, .selected-context, .subbar, .content { padding-left: 12px; padding-right: 12px; }
  #save-outcome:not(:empty), .focus-notice { margin-left: 12px; margin-right: 12px; }
  .selected-context { flex-wrap: wrap; }
  .context-identity { flex-basis: 220px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-grid > .posts-panel, .dash-side { grid-column: 1; grid-row: auto; }
  .dash-side { order: -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; align-items: start; margin-bottom: 10px; }
  .dash-side .panel { margin-bottom: 0; }
}
@media (max-width: 1000px) {
  .calendar-grid { grid-template-columns: repeat(7, minmax(88px, 1fr)); }
  .calendar-labels { min-width: 616px; }
}
@media (max-width: 736px) {
  .layout { display: block; }
  /* Brand and menu share one row; the account browser (always visible, its own scroll area) is below. */
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 8px; height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { flex: none; padding: 0; }
  .brand small { display: none; }
  .main-nav { flex: 1 1 0; display: flex; min-width: 0; gap: 4px; overflow-x: auto; }
  .main-nav button { flex: none; flex-direction: row; gap: 5px; min-height: 32px; padding: 3px 10px; font-size: var(--fs-sub); }
  .main-nav button span { font-size: 13px; }
  .account-browser { flex: 1 1 100%; gap: 5px; padding-top: 6px; }
  .account-groups { flex: none; max-height: 128px; }
  .sidebar .footer { display: none; }
  .topbar { gap: 6px 8px; padding-top: 6px; padding-bottom: 8px; }
  .page-title { order: 1; }
  .top-actions { order: 2; }
  .scope-controls { order: 3; flex: 1 1 100%; gap: 6px; }
  .owner { flex: 1 1 100%; }
  .owner select { width: 100%; }
  .range { flex: 1 1 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; }
  .range-tz { display: none; }
  .range input { width: 100%; min-width: 0; }
  .selected-context { align-items: flex-start; }
  .audience, .context-actions { flex: 1 1 100%; max-width: none; }
  .subbar { gap: 0; }
  .source-strip { flex-wrap: nowrap; width: 100%; padding-bottom: 6px; overflow-x: auto; }
  .source-chip { flex: none; }
  .workspace-tabs { gap: 4px; justify-content: space-between; width: 100%; }
  .workspace-tabs button { padding-left: 8px; padding-right: 8px; }
  .content { padding-top: 8px; }
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .kpi { padding: 6px 10px; }
  .scope-line { gap: 2px 6px; }
  .scope-loaded { margin-left: 0; width: 100%; }
  .dash-side { order: 0; grid-template-columns: minmax(0, 1fr); }
  .table-scroll table { min-width: 600px; }
  /* Posts become stacked rows on a phone: status/time/action, target, then the post, with no sideways scrolling. */
  .table-scroll .posts-table { min-width: 0; }
  .posts-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .posts-table, .posts-table tbody { display: block; }
  .posts-table tr.data-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "status when actions" "target target target" "body body body"; align-items: center; gap: 3px 8px; padding: 7px 10px; border-bottom: 1px solid #2b313c; }
  .posts-table tbody tr:last-child { border-bottom: 0; }
  .posts-table td, .posts-panel td, .posts-panel:not(.dense) td, .posts-panel.dense td { display: block; min-width: 0; padding: 0; border: 0; }
  .posts-table .col-status { grid-area: status; }
  .posts-table .col-when { grid-area: when; }
  .posts-table .col-actions { grid-area: actions; }
  .posts-table .col-target { grid-area: target; }
  .posts-table .col-body { grid-area: body; }
  .posts-panel.dense .col-body { white-space: normal; }
  .posts-panel.dense .post-line { display: block; }
  .posts-panel.dense .post-title { display: block; max-width: none; }
  .posts-panel.dense .post-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; }
  .toolbar { flex: 1 1 100%; }
  .toolbar input { flex: 1; width: auto; min-width: 140px; }
  .page-controls select { flex: 1; width: auto; min-width: 120px; }
  .account-list { grid-template-columns: minmax(0, 1fr); padding: 8px; }
  .person-heading { flex-wrap: wrap; }
  .person-heading .actions { width: 100%; margin-left: 0; }
  .cap-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { display: block; }
  .settings-row { flex-wrap: wrap; align-items: flex-start; }
  .modal-header, .modal-body { padding-left: 12px; padding-right: 12px; }
  .form-footer button { flex: 1 1 auto; }
  .login { margin-top: 8vh; padding: 18px; }
}
@media (max-width: 360px) {
  .topbar, .selected-context, .subbar, .content { padding-left: 10px; padding-right: 10px; }
  .top-actions { flex: 1; justify-content: flex-end; }
  .platforms button { padding-left: 2px; padding-right: 2px; }
  /* Two date fields no longer fit beside their label on a 320px phone. */
  .range { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 2px 6px; }
  .range label { grid-column: 1 / -1; }
}
