/* MAIC 社群工作台 2.0. Tokens carried over from 1.0 so partners moving across see the same desk. */
:root {
  --blue: #1450f5;
  --blue-dark: #0d3dbd;
  --cyan: #32c7f9;
  --rail: rgba(255, 255, 255, .78);
  --canvas: #edf6ff;
  --ink: #0e1728;
  --muted: #536783;
  --line: #d7e7f8;
  --line-strong: #c2dafa;
  --amber: #7b5213;
  --amber-bg: #fff7df;
  --red: #ad3549;
  --red-bg: #fff1f4;
  --green: #12704f;
  --green-bg: #e7f7ef;
  --radius: 18px;
  --lift: 0 22px 48px -30px rgba(13, 61, 189, .45);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}
* { box-sizing: border-box; }
/* Classes set display (flex, grid); the hidden attribute must still win. */
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--canvas); }
body {
  min-height: 100vh; margin: 0; overflow-x: hidden;
  background: radial-gradient(circle at 85% 7%, #d5edff 0, transparent 29rem), linear-gradient(180deg, #e8f4ff 0%, #f7fbff 74%);
}
/* Checkboxes and radio buttons keep their own size (健檢 6-02: the field look made them 44 px grey squares). :where()
   adds no specificity, so a component's own `.switch input` still wins. */
button, input:where(:not([type=checkbox]):not([type=radio])), select, textarea { font: inherit; min-height: 44px; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; }
/* A button that cannot be pressed now says so; it is not loading (critique 2026-10-30). */
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--blue); text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
input:where(:not([type=checkbox]):not([type=radio])), select, textarea {
  width: 100%; border: 1px solid #cbdff5; border-radius: 11px; padding: 10px 13px;
  color: var(--ink); background: rgba(255, 255, 255, .94); box-shadow: inset 0 1px 0 #fff;
}
/* Placeholders read at 4.5:1 or better on a field (white 4.78, read-only #f5f9fe 4.52), still lighter than typed text. */
input::placeholder, textarea::placeholder { color: #61748e; }
textarea { resize: vertical; line-height: 1.7; }
input[readonly], textarea[readonly] { background: #f5f9fe; }
p { margin: 0; line-height: 1.7; }
/* Chinese headings keep their natural spacing: tightened, the characters crowd (critique 2026-10-30). */
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: 0; }
h3 { font-size: 15px; }
h1 { font-size: 28px; line-height: 1.3; }
h2 { font-size: 17px; }

.loading { padding: 40vh 16px 0; text-align: center; color: var(--muted); }
.shell { max-width: 1060px; margin: 0 auto; padding: 18px 16px 72px; }
/* Signed in: the sidebar on the left, the page beside it (redesign stage 1, 2026-11-02). */
.shell:has(> .sidebar:not([hidden])) { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 28px; align-items: start; max-width: 1340px; }
.shell-main { min-width: 0; }
.stack { display: grid; gap: 16px; align-content: start; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

/* Surfaces: one lifted card per task, with the topbar floating above them. */
.card {
  display: grid; gap: 14px; align-content: start; padding: 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, .9); box-shadow: var(--lift);
}
/* The sidebar keeps its old id and class (#topbar.topbar) so the shell's wiring and recovery code stay as they were. */
.topbar {
  position: sticky; top: 18px; z-index: 2;
  display: flex; flex-direction: column; gap: 18px; max-height: calc(100vh - 36px); overflow-y: auto;
  padding: 18px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--rail); box-shadow: var(--lift); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-weight: 800; letter-spacing: -.02em; }
.brand-logo { flex: none; width: 40px; height: 40px; }
.brand-name { display: grid; justify-items: start; gap: 2px; line-height: 1.3; }
.brand small { padding: 2px 8px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: 12px; }
.topbar select { width: 100%; min-width: 0; border-radius: 12px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, box-shadow .15s, transform .1s;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button.wide { width: 100%; }
/* Small in type and padding, never in height: every button is at least 44 px to tap (critique 2026-10-30). */
.button.small { min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.button.primary { background: var(--blue); color: #fff; box-shadow: 0 12px 24px -14px var(--blue); }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.button.ghost:hover:not(:disabled) { border-color: var(--blue); color: var(--blue-dark); }
.button.danger { background: var(--red-bg); color: var(--red); }
.button.danger:hover:not(:disabled) { background: #ffe1e8; }
.button.link { background: none; color: var(--blue); padding: 0 6px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 700; }
form { display: grid; gap: 12px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Status colours carry meaning: amber = heads-up, red = something stopped you, green = done. A notice can quote a name
   that is one long word, so it breaks anywhere rather than run past a phone's edge. */
.notice { padding: 12px 14px; border-radius: 12px; background: var(--amber-bg); color: var(--amber); font-size: 15px; overflow-wrap: anywhere; }
.notice.error { background: var(--red-bg); color: var(--red); }
.notice.ok { background: var(--green-bg); color: var(--green); }
/* A notice with nothing to say yet is not drawn as an empty coloured bar (健檢 6-補4). */
.notice:empty { display: none; }
#invite-slot > .invite-card { margin-top: 14px; }

/* Login: what this is on the left, how to get in on the right. */
.login { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); gap: 40px; align-items: start; margin-top: 9vh; }
.eyebrow { color: var(--blue); font-weight: 800; letter-spacing: .04em; }
.intro h1 { margin: 10px 0 14px; font-size: clamp(32px, 5vw, 46px); line-height: 1.18; }
.intro .lead { max-width: 30em; color: var(--muted); font-size: 17px; }
.points { display: grid; gap: 12px; margin: 26px 0 0; padding: 0; list-style: none; }
.points li { position: relative; padding-left: 26px; }
.points li::before { content: ""; position: absolute; left: 0; top: .55em; width: 12px; height: 12px; border-radius: 4px; background: linear-gradient(135deg, var(--blue), var(--cyan)); }
.invite-card { border-color: var(--line-strong); background: linear-gradient(140deg, #fff 30%, #e9f3ff); }
.invite-card strong { font-size: 20px; }

/* Workspace: the member list is the main column, actions sit beside it. */
.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(290px, 1fr); gap: 20px; align-items: start; margin-top: 22px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
/* A workspace name can be one long word: it breaks instead of pushing the card past a phone's edge. */
.workspace-title h1 { min-width: 0; overflow-wrap: anywhere; }
.workspace-title h1 small { margin-left: 4px; color: var(--muted); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.members, .invites { display: grid; margin: 0; padding: 0; list-style: none; }
.member, .invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.member:first-child, .invite-row:first-child { border-top: 0; }
.who { flex: 1 1 180px; min-width: 0; }
.who .email { font-weight: 700; overflow-wrap: anywhere; }
.actions select { width: auto; min-height: 38px; padding: 6px 10px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill.owner { background: #e3ebff; color: var(--blue-dark); }
.pill.admin { background: #def5fd; color: #0a6582; }
.pill.editor { background: var(--green-bg); color: var(--green); }
.pill.viewer { background: #eef2f7; color: var(--muted); }
.link-box { display: flex; gap: 8px; }
.link-box input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.empty { display: grid; gap: 16px; max-width: 560px; margin: 10vh auto 0; }

@media (max-width: 860px) {
  .login, .workspace { grid-template-columns: minmax(0, 1fr); }
  .login { gap: 24px; margin-top: 28px; }
  .shell:has(> .sidebar:not([hidden])) { display: block; }
  .topbar { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; }
  .topbar select { flex: 1 1 100%; order: 2; }
}
@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}

/* ---------- M2: shell pieces ---------- */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; }
.skip-link:focus { top: 12px; }
.visually-hidden, .clipboard-proxy {
  position: fixed; left: 0; top: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0;
  opacity: 0; pointer-events: none; overflow: hidden;
}
.noscript { margin: 20vh auto 0; max-width: 30em; padding: 16px; text-align: center; }
#main { outline: none; margin-top: 18px; }
#main:focus-visible, [tabindex="-1"]:focus-visible { outline: none; }
.notices { display: grid; gap: 8px; margin-top: 14px; }
.notices:empty, #notice-alert:empty, #notice-status:empty { display: none; }
.notices .notice { display: grid; gap: 6px; }
.notices .notice .row { justify-content: flex-start; }
.button.link.small { min-height: 44px; }
.loading-line { padding: 18px 0; }
.empty-state { display: grid; gap: 6px; padding: 28px 8px; text-align: center; }
.empty-title { font-weight: 700; }

/* Sidebar links: 首頁 / 貼文 / 行事曆 / 媒體庫 / 成效分析 / 設定 (sidebar-nav.js). The page you are on is the blue one. */
.tabs { display: grid; gap: 4px; }
.tab { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 12px; color: var(--muted); font-weight: 700; text-decoration: none; }
.tab:hover { color: var(--blue-dark); background: var(--canvas); }
.tab.active { background: var(--blue); color: #fff; box-shadow: 0 12px 24px -16px var(--blue); }
.tab-count { margin-left: 3px; padding: 1px 6px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: 11px; line-height: 1.4; }
.settings-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.settings-link { display: grid; gap: 4px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); text-decoration: none; }
.settings-link:hover { border-color: var(--blue); }
.settings-link-title { color: var(--blue-dark); font-weight: 700; }
.topbar .account { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); flex-wrap: nowrap; }
.topbar .email { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) {
  .topbar .account { order: 1; margin: 0 0 0 auto; padding: 0; border: 0; }
  .topbar .email { max-width: 22ch; }
  .tabs { order: 3; display: flex; width: 100%; overflow-x: auto; }
  .tab { flex: 1 0 auto; justify-content: center; }
}

/* Tags: platform names and the manual-scheduling states. Amber = needs you, red = act now, green = done. */
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; background: #eef2f7; color: var(--muted); }
.tag.platform.threads { background: #eceff3; color: #1f2833; }
.tag.platform.instagram { background: #fbe9f1; color: #9b2c5d; }
.tag.platform.facebook { background: #e6eeff; color: #1d4fc4; }
.tag.on { background: var(--green-bg); color: var(--green); }
.tag.off { background: #eef2f7; color: var(--muted); }
.tag.manual-scheduled { background: var(--green-bg); color: var(--green); }
.tag.manual-stale, .tag.manual-removed, .tag.urgent { background: var(--red-bg); color: var(--red); }
.tag.manual-pending, .tag.manual-checking, .tag.manual-newer { background: var(--amber-bg); color: var(--amber); }
.tag.manual-due { background: #e3ebff; color: var(--blue-dark); }

/* ---------- drafts list ---------- */
.drafts { display: grid; gap: 14px; }
.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.list-tools input[type="search"] { flex: 1 1 220px; width: auto; }
.filters { display: flex; gap: 6px; }
.filter { min-height: 44px; padding: 0 14px; border-radius: 999px; background: #fff; color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px var(--line-strong); }
.filter[aria-pressed="true"] { background: var(--blue); color: #fff; box-shadow: none; }
.filter.alert:not([aria-pressed="true"]) { color: var(--red); box-shadow: inset 0 0 0 1px #f1b8c4; }
.draft-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.draft-row {
  display: grid; gap: 6px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px;
  background: rgba(255, 255, 255, .92); color: var(--ink); text-decoration: none; min-width: 0;
}
.draft-row:hover { border-color: var(--blue); }
.todo-row.urgent { border-color: #f1b8c4; background: #fffafb; }
.row-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.row-title { font-size: 17px; overflow-wrap: anywhere; }
.row-summary { color: var(--ink); overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: 14px; }
.list-more { justify-content: center; }

/* ---------- editor ---------- */
.editor { display: grid; gap: 16px; }
.editor-head { display: grid; gap: 4px; }
.editor-head .back { justify-self: start; padding: 0; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.title-row h1 { font-size: 26px; overflow-wrap: anywhere; min-width: 0; }
.pill.version { background: #e3ebff; color: var(--blue-dark); }
.editor-banners { display: grid; gap: 10px; }
.editor-banners:empty { display: none; }
.banner { display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--amber-bg); color: var(--amber); }
.banner.error { background: var(--red-bg); color: var(--red); }
.banner .card { color: var(--ink); box-shadow: none; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.counter { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.counter.over { color: var(--red); font-weight: 700; }
.field-error { color: var(--red); font-size: 14px; }
[aria-invalid="true"] { border-color: var(--red); }
.platforms { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.platforms legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.switches { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-weight: 700; cursor: pointer; }
.switch input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--blue); }
.switch:has(input:checked) { border-color: var(--blue); background: #edf3ff; color: var(--blue-dark); }
.switch:has(input:focus-visible) { outline: 3px solid var(--cyan); outline-offset: 3px; }
.platform-section { gap: 12px; }
.platform-body { display: grid; gap: 14px; }
.time-row input { flex: 1 1 14rem; width: auto; min-width: 0; }
.time-row select { flex: 0 0 auto; width: auto; }
.workbench { display: grid; gap: 8px; }
.workbench .button { justify-self: start; }
.workbench-frame:empty { display: none; }
.ig-workbench-frame { display: block; width: 100%; height: 900px; min-height: 320px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }

/* The manual panel: what to do next for this platform, kept visually separate from the writing above. */
.manual-slot { border-top: 1px dashed var(--line-strong); padding-top: 14px; }
.manual-panel { display: grid; gap: 8px; }
.manual-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.manual-panel[data-status="stale"], .manual-panel[data-status="removed"] { padding: 12px; border-radius: 12px; background: var(--red-bg); }
.manual-next { font-weight: 700; }
.manual-mark-form { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); gap: 10px; }
.manual-tools { padding-top: 4px; }
.manual-copy-wrap { display: grid; gap: 6px; }
.manual-copy { font-size: 14px; }
.revisions summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.revision-list { display: grid; gap: 4px; margin: 0; padding-left: 1.2em; }
.revision { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.danger-zone { border-color: #f6d2da; }
.missing { max-width: 640px; }
.relogin h3 { margin-bottom: 2px; }

/* The save bar stays in view at the bottom of the editor while the page scrolls. */
.save-bar {
  position: sticky; bottom: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 0 -4px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px 16px 0 0;
  background: rgba(255, 255, 255, .96); box-shadow: 0 -12px 30px -24px rgba(13, 61, 189, .45);
}
.save-status { flex: 1 1 240px; font-size: 14px; color: var(--muted); }
.save-status.ok { color: var(--green); }
.save-status.error { color: var(--red); font-weight: 700; }
.save-actions { flex: 0 0 auto; }
.link-slot:empty { display: none; }
.link-slot { flex-basis: 100%; }

/* 「模板」: the IG template card (public/ig-custom-templates.js) uses these generic class names. */
.templates-view { display: grid; gap: 14px; }
.ig-templates-card .stack { display: grid; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: 12px; background: var(--blue); color: #fff; font-weight: 700;
}
.btn:hover:not(:disabled) { background: var(--blue-dark); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.btn.secondary:hover:not(:disabled) { background: #fff; border-color: var(--blue); color: var(--blue-dark); }
.btn.small { min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.small { font-size: 14px; }
.muted { color: var(--muted); }
.card-title { font-size: 17px; }
.field-label { font-size: 14px; font-weight: 700; }
.error-text { color: var(--red); }
.ig-template-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.ig-template-field { display: grid; gap: 6px; }
.ig-template-page { display: grid; gap: 10px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.ig-template-format-tools { gap: 6px; }
.ig-template-format-preview { padding: 10px; border: 1px dashed var(--line-strong); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .ig-workbench-frame { max-height: calc(100vh - 32px); }
}
@media (max-width: 700px) {
  input, select, textarea { font-size: 16px; }
  .title-row h1 { font-size: 22px; }
  .card { padding: 18px; }
  .manual-mark-form { grid-template-columns: minmax(0, 1fr); }
  .save-actions { flex: 1 1 100%; }
  .save-actions .button { flex: 1 1 0; }
  .manual-tools .button, .manual-actions .button, .banner .row .button { flex: 1 1 auto; white-space: normal; text-align: center; }
  .topbar .email { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .draft-row, .filter, .switch { transition: border-color .15s, background-color .15s; }
}

/* ---------- M3: 連結的帳號 ---------- */
.reminder-slot { margin-top: 14px; }
.reminder-slot:empty { display: none; }
.page-reminder { display: grid; gap: 6px; }
.connections-view { display: grid; gap: 16px; }
.connection-banners:empty, .connection-load:empty, .connection-history:empty, .connection-notes:empty,
.connection-tools:empty, .form-slot:empty { display: none; }
/* One card per row: each holds the account's facts, notes and tools, which need the width. */
.connection-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
/* Permission names such as instagram_business_content_publish are one long word: they may break, so a card never
   grows wider than a phone. */
.connection-card { grid-template-columns: minmax(0, 1fr); overflow-wrap: anywhere; }
.connection-card .section-head h2 { font-size: 19px; }
.connection-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.connection-facts dt { color: var(--muted); font-size: 14px; line-height: 1.7; }
.connection-facts dd { margin: 0; line-height: 1.7; overflow-wrap: break-word; min-width: 0; }
.connection-facts .account { font-weight: 700; }
.connection-tools .row .button { white-space: normal; text-align: center; }
/* 5-補1: the page's first line answers 「all fine?」. 5-B: 「連線細節」 keeps what only debugging needs, closed. */
.connection-summary { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.6; }
.connection-details summary { cursor: pointer; min-height: 44px; padding: 10px 0; box-sizing: border-box; color: var(--muted); font-size: 14px; font-weight: 700; }
.connection-details[open] summary { color: var(--ink); }
.connection-details .codes { font-size: 14px; color: var(--muted); }
.tag.warn { background: var(--amber-bg); color: var(--amber); }
.plain-list { display: grid; gap: 4px; margin: 0; padding-left: 1.2em; line-height: 1.7; }
.missing-scopes { display: grid; gap: 6px; }
.token-form { gap: 10px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 14px; background: #f8fbff; }
/* The paste field is a text field (no password manager offers to save it), shown as dots like one where supported. */
.token-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; -webkit-text-security: disc; }
.token-problem { display: grid; gap: 4px; }
.connection-links { font-size: 14px; }
.agreement-card { border-color: var(--line-strong); }
.agreement-form { gap: 10px; }
.agree-row { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 700; line-height: 1.6; cursor: pointer; }
.check input { flex: 0 0 auto; width: 20px; height: 20px; min-height: 0; margin: 3px 0 0; accent-color: var(--blue); }
.check:has(input:focus-visible) { outline: 3px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
.document-links { gap: 6px 16px; font-size: 14px; }
.history { gap: 10px; }
.history summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.safety-note { padding: 0 4px; }
/* The terms and notices under every view; on a phone the links wrap onto a second line. */
.legal-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 16px; margin-top: 36px; color: var(--muted); font-size: 13px; }
.legal-footer a { display: inline-flex; align-items: center; min-height: 32px; color: var(--muted); }

@media (max-width: 700px) {
  .tabs { flex-wrap: nowrap; gap: 2px; }
  .tab { flex: 1 0 auto; padding: 0 10px; white-space: nowrap; font-size: 14px; }
  .connection-tools .row .button { flex: 1 1 auto; }
  .connection-facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .connection-facts dd { margin-bottom: 6px; }
}
.page-choice { gap: 10px; }
.plain-fieldset { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.plain-fieldset legend { padding: 0; margin-bottom: 6px; font-weight: 700; }

/* ---------- M4: 排出去、發文狀態、「發文」頁、發文方式 ---------- */
.publish-slot:empty, .publish-panel-slot:empty, .publish-load:empty, .publish-thumbnails:empty, .publish-actions:empty, .mode-tools:empty,
.publish-warnings:empty, .publish-results:empty, .publish-confirm-warnings:empty { display: none; }
/* The publish block sits under a platform's manual panel, set apart the same way. */
.publish-slot { border-top: 1px dashed var(--line-strong); padding-top: 14px; }
.publish-block { display: grid; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.publish-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.publish-next, .publication-next { font-weight: 700; }
.publish-block[data-status="failed"], .publish-block[data-status="partial"] { padding: 12px; border-radius: 12px; background: var(--red-bg); }
/* Tags: ok = done, info = moving, warn = needs you, alert = act now, off = nothing pending. */
.tag.publish-ok { background: var(--green-bg); color: var(--green); }
.tag.publish-info { background: #e3ebff; color: var(--blue-dark); }
.tag.publish-warn { background: var(--amber-bg); color: var(--amber); }
.tag.publish-alert { background: var(--red-bg); color: var(--red); }
.tag.publish-off { background: #eef2f7; color: var(--muted); }
/* The pictures that will be posted (the block and the 排出去 confirmation): a thumb-strip (below, Part 1), 160 px each,
   about 45vw on a phone, that scrolls sideways inside its column; every picture opens large. */
.publish-thumbnails { max-width: 100%; }
/* The 排出去 panel: an inline card above the save bar, one row per platform, each with its own time. */
.publish-panel { border-color: var(--line-strong); }
.publish-rows { display: grid; gap: 14px; }
.publish-row { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; min-width: 0; overflow-wrap: anywhere; }
.publish-switch { justify-self: start; max-width: 100%; min-height: 44px; height: auto; padding: 8px 14px; white-space: normal; }
.publish-account { color: var(--muted); font-weight: 400; }
.publish-shortcuts { gap: 4px 12px; }
.publish-shortcuts .button { white-space: normal; text-align: left; min-height: 44px; }
.publish-progress li, .publish-summary-lines li { line-height: 1.7; overflow-wrap: anywhere; }
.publish-confirm-line { font-weight: 700; }
.publish-time-form { padding: 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #f8fbff; }
/* The 排出去 time field's lines, 6 px apart by margins rather than the field's gap: its day line (a status that stays on
   the page so a screen reader hears it change) then takes no room while it has nothing to say. */
.publish-time { gap: 0; }
.publish-time > * + * { margin-top: 6px; }
.publish-time > .publish-day:empty { margin-top: 0; }
.publish-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.publish-summary .button.link { white-space: normal; text-align: left; }
.publish-recent summary, .publish-history summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.publish-history-list li { line-height: 1.6; overflow-wrap: anywhere; }
/* 「發文」: small cards, never a table, grouped by day. */
.publishing { gap: 18px; }
.publishing-section { display: grid; gap: 10px; }
.publication-list { display: grid; gap: 10px; }
.publication-day { display: grid; gap: 8px; }
.publication-day-label { color: var(--muted); font-size: 14px; }
.publication-card { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .92); min-width: 0; overflow-wrap: anywhere; }
.publication-card[data-status="failed"], .publication-card[data-status="partial"] { border-color: #f1b8c4; background: #fffafb; }
.publication-top { justify-content: space-between; }
.publication-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.publication-draft { font-weight: 700; }
/* 發文方式 under each platform card of 連結的帳號. */
.mode-card { display: grid; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.mode-switch { gap: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #f8fbff; }
.mode-marked { padding-left: 1.2em; }
/* Module D's editors: the Threads chain (threads-posts-editor.js) and the pictures placed directly (post-media-picker.js).
   A Threads segment's thumbnails are 72 px wide, so five fit a 390 px phone; the IG post's own strip is a thumb-strip. */
.threads-posts, .post-media { display: grid; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.threads-posts-list { display: grid; gap: 12px; }
.threads-post { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; min-width: 0; }
.segment-head { justify-content: space-between; align-items: center; }
.picture-strip-host:empty, .picture-chooser:empty { display: none; }
.picture-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.picture-item { display: grid; gap: 4px; justify-items: center; width: 72px; max-width: 100%; }
.picture-thumb { display: block; width: 72px; height: 90px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.picture-thumb.picture-missing { display: grid; place-items: center; color: var(--red); background: var(--red-bg); font-weight: 700; }
.picture-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.picture-meta .button { min-height: 44px; padding: 2px 6px; }
.picture-chooser { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #f8fbff; }
/* The library chooser (review 2026-10-31: 72 px tiles all read 1080×1350): pictures big enough to tell apart (two to a
   row on a phone), a ticked one ringed with its place in the post (「第 3 張」), and 放大 under each for the lightbox. */
.picture-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.picture-choice-cell { display: grid; gap: 0; align-content: start; min-width: 0; }
.picture-choice { display: grid; gap: 4px; justify-items: center; cursor: pointer; min-width: 0; }
.picture-choice input { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); }
.picture-choice .picture-thumb { width: 100%; height: auto; aspect-ratio: 4 / 5; }
.picture-choice:has(input:checked) .picture-thumb { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue); }
.picture-order { color: var(--blue-dark); font-weight: 700; }
.picture-choice-cell .picture-zoom { justify-self: center; }
@media (max-width: 700px) {
  .picture-choices { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
.crop-offer { align-items: center; gap: 8px 12px; }
.crop-offer input { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); }
.crop-preview { display: block; width: 96px; height: 120px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 700px) {
  .publish-actions .button, .publish-shortcuts .button, .mode-tools .row .button, .publish-time-form .row .button { flex: 1 1 auto; white-space: normal; text-align: center; }
  .save-actions .button.schedule { flex: 2 1 0; }
}

/* ---------- Part 1 (critique 2026-10-30): which pictures a post uses, pictures big enough to proofread ---------- */
/* A strip of pictures: one row that scrolls sideways and snaps, inside its column (the page itself never scrolls
   sideways), 160 px a picture and about 45vw on a phone. Every picture is a button that opens the lightbox. nowrap:
   the IG post's own strip is also a .picture-strip, whose rule above wraps. contain: inline-size keeps the row's
   own width (8 × 160 px) out of the grids around it, so they never grow past the column (seen at 1440 px). The 6 px
   inside the strip's edges hold a picture's whole focus ring (3 px outside it, 3 px wide): a strip that scrolls cuts
   off whatever reaches past its padding, and the ring lost its top edge (review 2026-10-31). */
.thumb-strip {
  display: flex; flex-wrap: nowrap; gap: 12px; margin: 0; padding: 6px 6px 10px; list-style: none; contain: inline-size;
  max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding-inline: 6px;
}
.thumb-strip > li { flex: 0 0 160px; width: 160px; min-width: 0; scroll-snap-align: start; }
.thumb-open { position: relative; display: block; width: 100%; min-height: 0; padding: 0; border-radius: 10px; background: none; line-height: 0; cursor: zoom-in; }
.thumb-open img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.thumb-open:hover img { border-color: var(--blue); }
/* The IG post's own strip (post-media-picker.js): the same big pictures, each with its size and 往前／往後／移除 under it. */
.thumb-strip > .picture-item { justify-items: stretch; align-content: start; }
.thumb-strip .picture-thumb { width: 100%; height: auto; aspect-ratio: 4 / 5; }
.thumb-strip .picture-meta { justify-content: flex-start; }
.thumb-strip .picture-caption { overflow-wrap: normal; }
.thumb-strip .picture-tools { gap: 2px; }
.thumb-strip .picture-tools .button { min-height: 44px; padding: 0 8px; }
.picture-actions { gap: 8px 12px; }

/* 「IG 圖片」 (ig-pictures.js): the kind of pictures in use beside the heading, the one switch on the right. */
.ig-pictures { display: grid; gap: 12px; min-width: 0; }
.ig-pictures-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.ig-pictures-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.ig-pictures-title h3 { font-size: 16px; letter-spacing: 0; }
.tag.ig-mode-photos, .tag.ig-mode-design { background: #e3ebff; color: var(--blue-dark); }
.tag.ig-mode-none { background: #eef2f7; color: var(--muted); }
.tag.ig-mode-both { background: var(--red-bg); color: var(--red); }
.ig-mode-hint { max-width: 65ch; }
.ig-switch, .ig-switch-box { display: grid; gap: 10px; }
.ig-switch-text { max-width: 65ch; }
/* On a scheduled post the switch also stops the scheduled version: said in bold, before anything changes. */
.ig-switch-schedule { max-width: 65ch; font-weight: 700; }
.ig-choices { gap: 10px; }
.ig-switch-open { white-space: normal; text-align: left; }
.workbench-note { max-width: 65ch; }
/* What a switch did, its 還原 and what 還原 did (ig-switch-outcome.js): it stays in sight under the top bar while the
   person works anywhere in the section, the long workbench included, and leaves with the section (review 2026-10-31:
   in the page's notices at the very top it was 800–2,500 px above the workbench in use). */
.ig-switch-outcome { position: sticky; top: var(--sticky-offset); z-index: 1; }
.ig-switch-outcome:empty { display: none; }
.ig-switch-outcome .notice { display: grid; gap: 6px; max-width: 72ch; box-shadow: 0 14px 30px -18px rgba(13, 61, 189, .5); }
.ig-switch-outcome .notice .row { justify-content: flex-start; }
.ig-switch-outcome .field-error { margin: 0; }
/* Every control here is at least 44 px tall (the desk's .small is 38 px; critique 2026-10-30), like 「數據」. */
.ig-pictures .button.small, .reschedule-line .button.small { min-height: 44px; }

/* The line under a draft's title while a scheduled post waits for 用新版重排 (reschedule-line.js). */
.reschedule-lines { display: grid; gap: 8px; margin-top: 8px; }
.reschedule-line { display: grid; gap: 6px; }
.reschedule-line .button { white-space: normal; text-align: center; }

/* 「發文」: an IG card shows its first picture beside its first four lines (the time, the title, the account and the
   sentence, always there); the button opens all of the post's pictures. What comes after them (the next step, a note,
   the buttons) takes the card's whole width below the picture: beside it, a phone wrapped them at about ten characters
   a line (review 2026-10-31). */
.publication-card.has-picture { grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; }
.publication-card.has-picture > * { grid-column: 1 / -1; }
.publication-card.has-picture > :nth-child(-n + 4) { grid-column: 1; }
.publication-card.has-picture > .publication-picture { grid-column: 2; grid-row: 1 / span 4; align-self: start; width: 80px; }
.publication-picture-count {
  position: absolute; right: 5px; bottom: 5px; padding: 0 7px; border-radius: 999px;
  background: rgba(14, 23, 40, .78); color: #fff; font-size: 12px; font-weight: 700; line-height: 1.7;
}

/* The lightbox (lightbox.js): a native modal <dialog> over a dark backdrop, the picture at 4:5 as large as the screen
   allows, 「第 3／8 張」 and 關閉 on top, 上一張／下一張 at the sides (under the picture on a phone). The dialog sits in the
   top layer, so it needs no z-index; the page behind does not scroll while it is open. */
html.lightbox-open { overflow: hidden; }
.lightbox {
  width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 16px; border: 0;
  background: transparent; color: #fff; overflow: hidden;
}
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
/* Solid: even at 97% the page's own words ghosted through behind 「第 3／8 張」 (walk-through at 1440 and 390 px). */
.lightbox::backdrop { background: #080d18; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: 1100px; margin: 0 auto; }
.lightbox-count { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.lightbox-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; min-height: 0; }
/* The middle column even when 上一張／下一張 are hidden (one picture): auto-placed, it sat in the first, at the left. */
.lightbox-figure { display: grid; place-items: center; grid-column: 2; height: 100%; min-width: 0; min-height: 0; margin: 0; touch-action: pan-y pinch-zoom; }
/* Pinch-zoomed in (lightbox.js is-zoomed): one finger moves across the enlarged picture in every direction, never to the next one. */
.lightbox.is-zoomed .lightbox-figure { touch-action: manipulation; }
.lightbox-image {
  display: block; width: min(100%, calc((100vh - 120px) * .8)); width: min(100%, calc((100dvh - 120px) * .8)); height: auto;
  aspect-ratio: 4 / 5; object-fit: contain; border-radius: 12px; background: #0e1728; user-select: none; -webkit-user-drag: none;
}
.lightbox-broken { max-width: 30ch; color: #fff; text-align: center; }
.lightbox .button.ghost { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .4); }
.lightbox .button.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .2); border-color: #fff; color: #fff; }
.lightbox .button:disabled { cursor: default; }
.lightbox-nav { min-width: 44px; min-height: 44px; }
@media (max-width: 700px) {
  .thumb-strip > li { flex-basis: 45vw; width: 45vw; }
  /* A phone's 64 px picture is as tall as three lines: the sentence goes under it too, at the card's whole width. */
  .publication-card.has-picture > :nth-child(4) { grid-column: 1 / -1; }
  .publication-card.has-picture > .publication-picture { width: 64px; grid-row: 1 / span 3; }
  .lightbox { padding: 12px; }
  .lightbox-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 12px; }
  .lightbox-figure { grid-column: 1 / -1; grid-row: 1; }
  .lightbox-previous { grid-column: 1; grid-row: 2; }
  .lightbox-next { grid-column: 2; grid-row: 2; }
  .lightbox-image { width: min(100%, calc((100vh - 170px) * .8)); width: min(100%, calc((100dvh - 170px) * .8)); }
}
@media (prefers-reduced-motion: no-preference) {
  .thumb-open img { transition: border-color .15s; }
  .lightbox[open] { animation: lightbox-in .2s cubic-bezier(.22, 1, .36, 1); }
  .lightbox[open]::backdrop { animation: lightbox-fade .2s ease-out; }
}
@keyframes lightbox-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
@keyframes lightbox-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Part 2 (critique 2026-10-30): 發文's calendar, what the sticky bar must not cover, whole numbers ---------- */
/* What the page scrolls to (scrollIntoView) keeps a small gap at the top: the sidebar sits beside the page above 860 px
   and in the flow below that, so nothing sticky covers it (redesign stage 1; it was a sticky top bar before). */
:root { --sticky-offset: 16px; }
.platform-section, .ig-pictures, .workbench, .picture-chooser, .publish-panel, .calendar-day-heading, .ig-switch-outcome { scroll-margin-top: var(--sticky-offset); }
/* A number or version that reads as one piece (「1080×1350」, 「2026-10-29.2」) never breaks inside; the words around it wrap. */
.token { white-space: nowrap; }
/* A Threads segment's 72 px pictures: the size fits under its picture at 13 px. */
.picture-caption { font-size: 13px; }

/* 「發文」: 日曆／清單 beside the platform filter (publishing-view.js). */
.publishing-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
/* The calendar (publishing-calendar.js): a month grid from 960 px up, a week strip below that (narrower, a cell left the
   title one clipped character beside the time: 「12:23 T 不…」 at 720–900 px), the chosen day's cards under either. Each
   day is a cell of the same size; a post is one line (time, platform, the title cut short with 「…」). */
.publishing-calendar { display: grid; gap: 12px; min-width: 0; }
.calendar-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.calendar-title { font-size: 19px; font-variant-numeric: tabular-nums; }
.calendar-heading { align-items: baseline; gap: 4px 12px; }
.calendar-loading { margin: 0; }
.publishing-calendar[aria-busy="true"] .calendar-month, .publishing-calendar[aria-busy="true"] .calendar-week { opacity: 0.5; }
.calendar-nav { gap: 6px; }
.calendar-month { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 4px; }
.calendar-month th { padding: 0 0 2px; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.calendar-day {
  height: 108px; padding: 6px 6px 8px; vertical-align: top; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
.calendar-day:hover { border-color: var(--line-strong); }
/* Past days are quieter, and so are the other months' dates (the coming week can be the next month's: its posts stay as
   they are); days older than the record the page reads are dashed (nothing ended shows there). */
.calendar-day.is-past { background: #f6f9fd; }
.calendar-day.is-unrecorded { border-style: dashed; }
/* A week wholly in the past with nothing in it is short: the weeks with posts get the room. */
.calendar-month tr.is-quiet > .calendar-day { height: 48px; }
.calendar-day.is-selected { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.calendar-day-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 2px; }
/* The whole cell chooses the day by pointer; the date is the keyboard's way in (one tab stop, arrow keys). */
.calendar-date {
  min-width: 30px; min-height: 30px; padding: 0 6px; border-radius: 999px; background: none;
  color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums;
}
.calendar-day.is-past .calendar-date, .calendar-day.is-other .calendar-date { color: var(--muted); }
.calendar-day.is-today .calendar-date { background: var(--blue); color: #fff; }
.calendar-today-tag { color: var(--blue-dark); font-size: 12px; font-weight: 700; }
/* One column no wider than the cell, so a long title ends in 「…」 instead of running past the edge. */
.calendar-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; margin: 0; padding: 0; list-style: none; min-width: 0; }
.calendar-items > li { min-width: 0; }
.calendar-item {
  display: flex; align-items: baseline; gap: 4px; min-width: 0; padding: 0 4px; border-radius: 6px;
  color: var(--ink); font-size: 12px; line-height: 1.6; text-decoration: none; white-space: nowrap;
}
a.calendar-item:hover { background: #eef4ff; }
.calendar-time { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.calendar-platform { flex: none; color: var(--muted); font-size: 11px; font-weight: 700; }
.calendar-platform.instagram { color: #9b2c5d; }
.calendar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* A post that needs a look says so in words, in the colours the tags use. */
.calendar-item[data-tone="warn"] { background: var(--amber-bg); color: var(--amber); }
.calendar-item[data-tone="alert"] { background: var(--red-bg); color: var(--red); }
.calendar-item[data-tone="info"] { color: var(--blue-dark); }
.calendar-item[data-tone="warn"] .calendar-platform, .calendar-item[data-tone="alert"] .calendar-platform { color: inherit; }
.calendar-status { font-weight: 700; }
.calendar-more { min-height: 0; padding: 0 4px; background: none; color: var(--blue-dark); font-size: 12px; font-weight: 700; line-height: 1.6; text-align: left; }
.calendar-note { font-size: 13px; }
/* The phone's week: seven days in a row, each with its count; the chosen one filled. */
.calendar-week { display: none; gap: 8px; }
.calendar-week-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar-week-day {
  display: grid; justify-items: center; align-content: center; min-width: 0; min-height: 66px; padding: 6px 0;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); line-height: 1.35;
}
.calendar-week-day.is-past { background: #f6f9fd; }
.calendar-week-name { color: var(--muted); font-size: 12px; }
.calendar-week-date { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calendar-week-count { min-height: 1.35em; color: var(--blue-dark); font-size: 11px; font-weight: 700; white-space: nowrap; }
.calendar-week-day.is-today .calendar-week-date { color: var(--blue); }
.calendar-week-day.is-selected { border-color: var(--blue); background: var(--blue); }
/* As specific as the today rule above and after it: today chosen reads white on blue too. */
.calendar-week-day.is-selected .calendar-week-name, .calendar-week-day.is-selected .calendar-week-date, .calendar-week-day.is-selected .calendar-week-count { color: #fff; }
/* The chosen day: a click brings its heading up from below the screen with room for its first card. */
.calendar-day-panel { display: grid; gap: 10px; padding-top: 4px; }
.calendar-day-heading { font-size: 17px; scroll-margin-bottom: 45vh; }
.calendar-history summary { padding: 10px 0; min-height: 44px; cursor: pointer; font-weight: 700; }
.calendar-history[open] > .publication-list { margin-top: 6px; }
/* CAL-07: a phone shows the first card sooner. The introduction and the 14-day note step aside (a day before the record
   says so itself), and ‹ › for the weeks sit beside 今天, where a wide screen has 上個月／下個月. */
.calendar-week-arrow { min-width: 44px; padding: 0; font-size: 20px; line-height: 1; }
@media (min-width: 960px) { .calendar-week-arrow { display: none; } }
@media (max-width: 959px) {
  .calendar-month, .calendar-previous-month, .calendar-next-month, .publishing-intro, .calendar-note { display: none; }
  .calendar-week { display: grid; }
}
/* By touch the whole cell chooses its day: its items are 19 px lines a finger cannot tell apart from the day around them
   (a tap meant for the day opened a draft). The day's cards below open the drafts. */
@media (pointer: coarse) {
  .calendar-items, .calendar-more { pointer-events: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .calendar-day, .calendar-week-day, a.calendar-item { transition: border-color .15s, background-color .15s; }
}

/* ---------- M5: 「數據」 ---------- */
.insights { gap: 18px; }
.insights-load:empty { display: none; }
/* What is going on with collecting (insights-text.js collectionNote): an explanation in the page's own ink, not an error. */
.insights-explain { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: #f5f9ff; }
.insights-explain-title { font-weight: 700; }
/* One line (「要開啟，請告訴 Mike。」) is a sentence, not a list of one. */
.insights-explain-lines.is-single { padding-left: 0; list-style: none; }
.insights-filters { display: grid; gap: 10px; }
.insights-selects { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 10px; }
.insights-section { display: grid; gap: 10px; min-width: 0; }
/* A section's own buttons (重新讀取狀態, 載入更多…) keep their size: a grid row made them the page's widest control (6-08). */
.insights-section > .button { justify-self: start; }
/* 資料回補與匯入 (insights-maintenance.js): the backfill and the FB import folded under the table. */
.insights-maintenance-body { display: grid; gap: 18px; padding: 4px 0 10px; min-width: 0; }
/* A backfill card's buttons keep their own width: a whole-row 取消回補 read as the thing to press (第二波 U1, 6-補7). */
.backfill-card > .button { justify-self: start; }
/* Account cards: as many to a row as fit, the whole column on a phone; long names and permission names break. */
.insights-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.insights-account { display: grid; gap: 8px; align-content: start; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .92); min-width: 0; overflow-wrap: anywhere; }
.insights-account[data-state="missing_permission"], .insights-account[data-state="needs_reconnect"] { border-color: #f1b8c4; background: #fffafb; }
.insights-account-name { min-width: 0; overflow-wrap: anywhere; }
/* A card keeps its nodes across reads in a few parts; each part's lines sit in the card's own grid. */
.insights-account-part { display: contents; }
/* The number under a dash in a card says why it is missing, in the small type of a hint. */
.insights-number .insights-why { display: block; font-size: 13px; font-weight: 400; }
/* Freshness and tags by what they mean: amber = has not updated for a while, red = over a day or needs a person. */
.insights-fresh { font-size: 14px; }
.insights-fresh.insights-warn { color: var(--amber); font-weight: 700; }
.insights-fresh.insights-alert { color: var(--red); font-weight: 700; }
.insights-fresh.insights-muted { color: var(--muted); }
.tag.insights-warn { background: var(--amber-bg); color: var(--amber); }
.tag.insights-alert { background: var(--red-bg); color: var(--red); }
.tag.insights-ok { background: var(--green-bg); color: var(--green); }
.tag.insights-info, .tag.insights-desk { background: #e3ebff; color: var(--blue-dark); }
a.tag.insights-desk { text-decoration: none; }
.insights-numbers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; }
.insights-number { min-width: 0; }
.insights-number dt, .insights-metric dt { color: var(--muted); font-size: 13px; }
.insights-number dd { margin: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.insights-change { font-size: 13px; font-weight: 400; }
.insights-daily summary, .insights-detail summary, .insights-glossary summary, .insights-maintenance summary { cursor: pointer; font-weight: 700; padding: 10px 0; min-height: 44px; }
/* Every control on the page is at least 44 px tall (05 §3.9), the desk's smaller pills and buttons included. */
.insights .filter, .insights .button.small { min-height: 44px; }
.insights-days { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.insights-day { display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid var(--line); }
.insights-day-values { font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.insights-summary { font-weight: 700; overflow-wrap: anywhere; }
/* The posts table (05 §3.9): one DOM for both widths. Every cell may shrink and break, so the table never grows past
   its column; at 700 px and below each post (its <tbody>) becomes a card. Child selectors only: a post's detail holds
   a table of its own (the eight windows), which keeps its rows. */
.insights-table { width: 100%; border-collapse: collapse; }
.insights-table > thead > tr > th, .insights-table > tbody > tr > td { padding: 10px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; min-width: 0; overflow-wrap: anywhere; }
.insights-table > thead > tr > th { border-top: 0; color: var(--muted); font-size: 13px; }
/* A number keeps to one line, at 14 px, beside the text columns (which break anywhere, tags included): at 701 px six
   7-digit columns still fit beside the narrowest text columns, tags with their padding. */
.insights-table > thead > tr > .num, .insights-table > tbody > tr > .num { padding-left: 3px; padding-right: 3px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.insights-table > tbody > tr > .num { font-size: 14px; }
.insights-table .insights-row .tag { white-space: normal; }
.insights-table .insights-detail-cell { padding-top: 0; border-top: 0; }
.insights-post-links { gap: 4px 10px; font-size: 14px; }
.insights-excerpt, .insights-excerpt-full { overflow-wrap: anywhere; }
.insights-post-title { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.insights-elsewhere { color: var(--muted); }
.insights-detail-body, .insights-glossary-body { display: grid; gap: 10px; padding: 4px 0 10px; min-width: 0; overflow-wrap: anywhere; }
.insights-latest { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: 6px 16px; margin: 0; }
.insights-metric { min-width: 0; }
.insights-metric dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* The eight windows: four columns (the window and when it was read, then three numbers), about 72 px each on a phone.
   A number never breaks: three 7-digit columns fit from 361 px, and at 12 px with less padding on the narrowest phones. */
.insights-windows { width: 100%; border-collapse: collapse; font-size: 14px; }
.insights-windows th, .insights-windows td { padding: 6px 4px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; min-width: 0; overflow-wrap: anywhere; }
.insights-windows .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.insights-windows tbody th { font-weight: 700; }
.insights-slot-state { display: block; font-weight: 400; font-size: 13px; }
.insights-terms { display: grid; gap: 6px; margin: 0; }
.insights-terms > div { display: grid; grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr); gap: 2px 12px; }
.insights-terms dt { font-weight: 700; }
.insights-terms dd { margin: 0; color: var(--muted); }
@media (max-width: 700px) {
  .insights-selects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-table, .insights-table > tbody > tr > td { display: block; }
  .insights-table > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .insights-table > .insights-post { display: grid; gap: 8px; margin-bottom: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .92); min-width: 0; }
  .insights-table > .insights-post > .insights-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; }
  .insights-table > .insights-post > .insights-detail-row { display: block; }
  .insights-table .insights-row > td, .insights-table .insights-detail-cell { padding: 0; border: 0; }
  .insights-table .insights-row > td:not(.num) { grid-column: 1 / -1; }
  .insights-table .insights-row > td.num { padding: 0; text-align: left; font-size: 15px; font-weight: 700; white-space: normal; }
  .insights-table .insights-row > td.num::before { content: attr(data-label); display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
  .insights-terms > div { grid-template-columns: minmax(0, 1fr); }
}
/* The narrowest phones: smaller numbers, so a 7-digit number stays whole in a post card's columns and in the windows. */
@media (max-width: 360px) {
  .insights-table .insights-row > td.num { font-size: 12px; }
  .insights-windows th, .insights-windows td { padding: 6px 3px; }
  .insights-windows .num { font-size: 12px; }
}
/* A handle (「@name」) stays whole in the table where there is room for it (critique 2026-10-30: 「@name202」 above 「0」):
   from 1000 px the 帳號 column takes the whole handle, a 30-character one included, beside six 7-digit columns; narrower, it
   breaks like every text column, so the table never grows past its card. */
@media (min-width: 1000px) {
  .insights-table .insights-row .insights-handle { overflow-wrap: normal; }
}
