@font-face { font-family: 'Hanken Grotesk'; src: url('/assets/fonts/HankenGrotesk-Variable.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/assets/fonts/IBMPlexMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/assets/fonts/IBMPlexMono-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }

:root {
  --paper: #f5f1e9;
  --paper-2: #ede7db;
  --ink: #141a22;
  --ink-2: #4a525c;
  --rule: #d6cebf;
  --accent: #b0186a;
  --accent-ink: #ffffff;
  --ok: #067132;
  --info: #076985;
  --wait: #83580c;
  --bad: #9b1c1c;
  --head: 'Hanken Grotesk', system-ui, sans-serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--body); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2 { font-family: var(--head); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; margin: 0 0 16px; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.mono { font-family: var(--mono); font-size: 0.85rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.8rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.masthead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px;
  padding: 16px var(--gutter); border-bottom: 1px solid var(--ink); }
.wordmark { font-family: var(--head); font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.wordmark .muted { font-weight: 400; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline; }
.nav a { text-decoration: none; padding: 4px 0; }
.nav a[aria-current='page'] { text-decoration: underline; text-decoration-thickness: 2px; }
main { max-width: 960px; margin: 0 auto; padding: 20px var(--gutter) 64px; }
.narrow { max-width: 440px; }
.flash { border-left: 3px solid var(--ink); padding: 6px 12px; margin: 0 0 20px; }
.warn { border-left: 3px solid var(--bad); padding: 6px 12px; }
.empty-state { color: var(--ink-2); padding: 32px 0; }
.back { margin: 0 0 12px; }

button, .button { font: 500 0.95rem/1 var(--body); color: var(--ink); background: transparent; border: 1px solid var(--ink);
  border-radius: 2px; padding: 11px 16px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
button:hover, .button:hover { background: var(--paper-2); color: var(--ink); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .button.primary:hover { background: #93125a; color: var(--accent-ink); }
button.link { border: 0; padding: 4px 0; min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
form.inline { display: inline; }

.tabs { display: flex; gap: 0 20px; overflow-x: auto; border-bottom: 1px solid var(--rule); margin-bottom: 8px; }
.tabs a { white-space: nowrap; text-decoration: none; padding: 10px 0; border-bottom: 2px solid transparent; }
.tabs a[aria-current='page'] { border-bottom-color: var(--ink); font-weight: 600; }

.article { padding: 20px 0; border-bottom: 1px solid var(--rule); }
.article-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.meta { margin: 0 0 4px; color: var(--ink-2); }
.items { list-style: none; margin: 0; padding: 0; }
.items li + li { border-top: 1px solid var(--rule); }
.item-row { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; padding: 12px 0; text-decoration: none; }
.item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-title { font-weight: 600; }
.item-time { overflow-wrap: anywhere; }
.item-main .status { margin: 2px 0; }
.item-error { color: var(--bad); font-size: 0.9rem; overflow-wrap: anywhere; }
.thumb { width: 72px; height: 90px; object-fit: cover; background: var(--paper-2); display: flex; align-items: center; justify-content: center; }
img.thumb[width='54'] { width: 54px; height: 96px; justify-self: center; }

.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.8rem; white-space: nowrap; }
.status .sq { width: 8px; height: 8px; display: none; }
.s-pending_approval .sq { display: inline-block; background: var(--wait); }
.s-scheduled .sq, .s-publishing .sq { display: inline-block; background: var(--info); }
.s-posted .sq { display: inline-block; background: var(--ok); }
.s-failed .sq { display: inline-block; background: var(--bad); }

.item-detail header p { margin: 4px 0; }
.detail-grid { display: grid; gap: 24px; margin-top: 20px; }
.preview { width: 100%; max-width: 360px; height: auto; display: block; background: var(--paper-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.preview { max-height: 70vh; width: auto; max-width: 100%; }
.actions form { margin: 0; }
.caption { white-space: pre-wrap; overflow-wrap: anywhere; }

label { display: block; font-weight: 500; margin: 14px 0 4px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 400; margin: 8px 0; }
input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--ink); }
input:not([type='checkbox']), textarea { width: 100%; font: inherit; color: var(--ink); background: #fffdf8;
  border: 1px solid var(--rule); border-radius: 2px; padding: 10px; min-height: 44px; }
textarea { resize: vertical; line-height: 1.45; }
.hint { font-size: 0.85rem; color: var(--ink-2); margin: 4px 0 16px; }
fieldset { border: 0; border-top: 1px solid var(--rule); padding: 16px 0; margin: 0; }
legend { font-family: var(--head); font-weight: 600; padding: 0 8px 0 0; }
.settings > button { margin-top: 16px; }

.accounts { list-style: none; padding: 0; margin: 0; }
.accounts li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.accounts p { margin: 4px 0; }

/* traffic */
.block { padding: 20px 0; border-top: 1px solid var(--rule); }
.block h2 { margin-bottom: 12px; }
.channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px 20px; margin: 0; }
.channels div { border-left: 1px solid var(--rule); padding-left: 10px; }
.channels .is-ai { border-left: 3px solid var(--accent); }
.channels dt { font-size: 0.9rem; }
.channels dd { margin: 2px 0 0; font-size: 1.3rem; }
.bars { margin: 0; }
.bars svg { width: 100%; height: 120px; display: block; border-bottom: 1px solid var(--ink); }
.bars figcaption { display: flex; justify-content: space-between; margin-top: 4px; }
.c-ai { fill: var(--accent); background: var(--accent); }
.c-search { fill: #3d4a5a; background: #3d4a5a; }
.c-social { fill: #7d8894; background: #7d8894; }
.c-direct { fill: #b5ad9f; background: #b5ad9f; }
.c-other { fill: #d9d1c3; background: #d9d1c3; }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sq { width: 10px; height: 10px; display: inline-block; }
.top-sources { list-style: none; padding: 0; margin: 0; }
.top-sources li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.top-sources li > span:first-child { overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table.traffic { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.traffic th, table.traffic td { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.traffic thead th { font-weight: 500; color: var(--ink-2); border-bottom-color: var(--ink); white-space: nowrap; }
table.traffic tbody th { font-weight: 400; min-width: 180px; }
.num { text-align: right !important; }
td.accent { color: var(--accent); font-weight: 500; }
summary { cursor: pointer; overflow-wrap: anywhere; }
.sources { list-style: none; padding: 6px 0 0 14px; margin: 0; font-size: 0.85rem; }

@media (min-width: 720px) {
  h1 { font-size: 1.9rem; }
  .detail-grid { grid-template-columns: 360px 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
