@font-face {
  font-family: "Oli Fraunces";
  src: url("/assets/site/fonts/Fraunces.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Oli Fraunces";
  src: url("/assets/site/fonts/Fraunces-Italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Oli Geist";
  src: url("/assets/site/fonts/Geist-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Oli Geist";
  src: url("/assets/site/fonts/Geist-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Oli Mono";
  src: url("/assets/site/fonts/JetBrainsMono.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #f7f5f1;
  --surface: #fffefa;
  --surface-raised: #ffffff;
  --ink: #0f1419;
  --ink-soft: #2c2826;
  --muted: #6b6661;
  --line: #ddd8d0;
  --line-strong: #c8c1b7;
  --accent: #e84a1f;
  --accent-soft: #ffe4dc;
  --accent-ink: #ffffff;
  --success: #4f7a3c;
  --warning: #a86422;
  --danger: #a73b32;
  --glass: rgba(255, 254, 250, .82);
  --shadow: 0 12px 34px rgba(43, 35, 29, .08);
  --radius: 8px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b0f14;
  --surface: #11161b;
  --surface-raised: #151a20;
  --ink: #fafaf6;
  --ink-soft: #d6cfc2;
  --muted: #9a948d;
  --line: #2a2d30;
  --line-strong: #414449;
  --accent: #ff6a3d;
  --accent-soft: #2a1813;
  --accent-ink: #0b0f14;
  --success: #8bae71;
  --warning: #e3a259;
  --danger: #ef8d84;
  --glass: rgba(11, 15, 20, .84);
  --shadow: 0 14px 38px rgba(0, 0, 0, .24);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --canvas: #0b0f14;
    --surface: #11161b;
    --surface-raised: #151a20;
    --ink: #fafaf6;
    --ink-soft: #d6cfc2;
    --muted: #9a948d;
    --line: #2a2d30;
    --line-strong: #414449;
    --accent: #ff6a3d;
    --accent-soft: #2a1813;
    --accent-ink: #0b0f14;
    --success: #8bae71;
    --warning: #e3a259;
    --danger: #ef8d84;
    --glass: rgba(11, 15, 20, .84);
    --shadow: 0 14px 38px rgba(0, 0, 0, .24);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 "Oli Geist", -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 72%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-140%);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--canvas);
}
.skip-link:focus { transform: none; }

.wordmark {
  color: var(--accent);
  font: italic 500 36px/1 "Oli Fraunces", Georgia, serif;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2 { margin-bottom: 0; font-family: "Oli Fraunces", Georgia, serif; font-weight: 500; }
h1 { font-size: 28px; line-height: 1.12; }
h2 { font-size: 25px; line-height: 1.15; }
h3 { margin-bottom: 16px; font-size: 15px; font-weight: 600; }
.supporting { color: var(--muted); }
.supporting.compact { margin: -8px 0 14px; font-size: 13px; }

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.auth-panel {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 54px;
}
.environment-label { color: var(--muted); font-size: 12px; }
.auth-step h1 { margin-bottom: 10px; }
.auth-step h1:focus { outline: none; }
.auth-step > .supporting { margin-bottom: 28px; }
form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--ink);
}
textarea { min-height: 112px; resize: vertical; }
.primary-action, .secondary-action, .text-action {
  min-height: 44px;
  border-radius: 6px;
  font-weight: 600;
}
.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.secondary-action {
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.text-action {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.compact-action { width: auto; padding: 0 16px; }
.status-message { min-height: 22px; margin: 18px 0 0; color: var(--danger); font-size: 13px; }
.status-message.is-success { color: var(--success); }
.qr-frame {
  display: grid;
  width: min(100%, 260px);
  aspect-ratio: 1;
  place-items: center;
  margin: 0 auto 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.qr-frame img { width: 100%; height: 100%; object-fit: contain; }
.secret-row {
  display: grid;
  gap: 4px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 12px;
}
.secret-row code { overflow-wrap: anywhere; color: var(--ink); font: 13px "Oli Mono", monospace; }

.dashboard-shell {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  grid-template-columns: 224px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 25px 18px 18px;
  border-right: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: saturate(130%) blur(18px);
}
.sidebar-brand { display: flex; align-items: baseline; gap: 10px; margin: 0 10px 34px; color: var(--muted); font-size: 12px; }
.sidebar nav { display: grid; gap: 3px; }
.nav-item {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.is-active { border-color: var(--line); background: var(--surface); color: var(--ink); font-weight: 600; }
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.workspace { min-width: 0; }
.toolbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: saturate(130%) blur(18px);
}
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.freshness { color: var(--muted); font-size: 12px; white-space: nowrap; }
.window-control { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.window-control select { min-height: 44px; width: auto; }
.theme-control { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.theme-control button { min-width: 44px; min-height: 44px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; }
.theme-control button.is-active { background: var(--ink); color: var(--canvas); }

#main-content { padding: 36px clamp(20px, 4vw, 48px) 64px; }
.view { display: none; }
.view.is-active { display: block; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.section-heading > p { max-width: 420px; margin-bottom: 2px; color: var(--muted); font-size: 13px; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  margin-bottom: 38px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metric {
  min-width: 0;
  padding: 18px 20px 20px 0;
  border-right: 1px solid var(--line);
}
.metric + .metric { padding-left: 20px; }
.metric:last-child { border-right: 0; }
.metric-label { display: block; min-height: 34px; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.metric-value { display: block; overflow-wrap: anywhere; font: 600 28px/1.15 "Oli Mono", monospace; }
.metric-detail { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
#traffic-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}
#traffic-summary .metric:nth-child(2) { border-right: 0; }
#traffic-summary .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
#traffic-summary .metric:nth-child(3) { padding-left: 0; }
.infrastructure-grid .metric:nth-child(4) { border-right: 0; }
.infrastructure-grid .metric:nth-child(n+5) { border-top: 1px solid var(--line); }
.infrastructure-grid .metric:nth-child(5) { padding-left: 0; }
.split-section { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 44px; }
.split-section > section, .view > section { min-width: 0; padding-top: 22px; border-top: 1px solid var(--line); }
.data-table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
td.numeric { font-family: "Oli Mono", monospace; font-variant-numeric: tabular-nums; text-align: right; }
.empty-row { color: var(--muted); text-align: center; }
.trend-chart { display: grid; min-height: 260px; grid-template-columns: repeat(14, minmax(14px, 1fr)); align-items: end; gap: 8px; }
.trend-day { display: grid; min-width: 0; gap: 7px; align-items: end; }
.trend-bars { display: flex; height: 200px; align-items: end; justify-content: center; gap: 2px; }
.trend-bar { width: 28%; min-height: 2px; background: var(--accent); }
.trend-bar.height-1 { height: 10%; }
.trend-bar.height-2 { height: 20%; }
.trend-bar.height-3 { height: 30%; }
.trend-bar.height-4 { height: 40%; }
.trend-bar.height-5 { height: 50%; }
.trend-bar.height-6 { height: 60%; }
.trend-bar.height-7 { height: 70%; }
.trend-bar.height-8 { height: 80%; }
.trend-bar.height-9 { height: 90%; }
.trend-bar.height-10 { height: 100%; }
.trend-bar.workout { background: var(--success); }
.trend-bar.ask { background: var(--warning); }
.trend-bar.is-suppressed {
  background: var(--muted);
  opacity: 0.45;
}
.trend-label { overflow: hidden; color: var(--muted); font-size: 10px; text-align: center; text-overflow: clip; }
.inline-note { max-width: 760px; color: var(--muted); font-size: 13px; }
.inline-alert { margin-bottom: 22px; padding: 12px 14px; border: 1px solid var(--warning); background: var(--accent-soft); color: var(--ink-soft); }
.publication-list { border-top: 1px solid var(--line); }
.publication-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 170px auto;
  gap: 18px;
  align-items: center;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}
.publication-row h3 { margin: 0 0 3px; }
.publication-row p { margin: 0; color: var(--muted); font-size: 12px; }
.status-pill { width: fit-content; padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-actions button { min-height: 44px; }

dialog {
  width: min(900px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(15, 20, 25, .58); backdrop-filter: blur(3px); }
#publication-form {
  display: block;
  max-height: calc(100vh - 32px);
  padding: 24px;
  overflow-y: auto;
}
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.dialog-header { margin-bottom: 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.publication-preview {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.preview-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.preview-heading h3 { margin: 0; }
.preview-heading > span { color: var(--muted); font-size: 12px; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.popup-preview, .feed-preview {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 9px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
}
.preview-surface {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.preview-mark {
  color: var(--accent);
  font: italic 500 27px/1 "Oli Fraunces", Georgia, serif;
}
.popup-preview strong, .feed-preview strong {
  overflow-wrap: anywhere;
  font: 600 20px/1.18 "Oli Fraunces", Georgia, serif;
}
.popup-preview p, .feed-preview p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}
.preview-action {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 8px 12px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-align: center;
}
fieldset { display: flex; flex-wrap: wrap; gap: 14px 22px; margin: 22px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
legend { padding: 0 6px; color: var(--muted); font-size: 12px; }
fieldset label { display: flex; min-height: 44px; align-items: center; gap: 7px; }
fieldset input { width: 18px; min-height: 18px; }
.dialog-message { margin: 22px 0 0; }
.dialog-actions { justify-content: flex-end; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }

@media (max-width: 980px) {
  .dashboard-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    z-index: 20;
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-brand { margin: 0 0 10px; }
  .sidebar nav { display: flex; min-width: 0; max-width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .nav-item { flex: 0 0 auto; }
  .sidebar-footer { position: absolute; top: 14px; right: 16px; margin: 0; padding: 0; border: 0; }
  .toolbar { top: 99px; align-items: flex-start; }
  .toolbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .metric-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .metric:nth-child(3) { padding-left: 0; }
  .infrastructure-grid .metric:nth-child(even) { border-right: 0; }
  .infrastructure-grid .metric:nth-child(odd) { padding-left: 0; }
  .split-section { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .auth-shell { padding: 0; }
  .auth-panel { min-height: 100vh; padding: 24px 20px; border: 0; box-shadow: none; }
  .sidebar { position: static; }
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    gap: 4px;
  }
  .nav-item { width: 100%; }
  .toolbar { position: static; display: block; }
  .toolbar-actions { margin-top: 16px; justify-content: flex-start; }
  .freshness { width: 100%; }
  .theme-control { width: 100%; }
  .theme-control button { flex: 1; }
  .section-heading { display: block; }
  .section-heading > p, .section-heading > button { margin-top: 14px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding-right: 12px; }
  .metric + .metric { padding-left: 12px; }
  .metric:nth-child(odd) { padding-left: 0; }
  .metric-value { font-size: 23px; }
  .trend-chart { gap: 4px; }
  .trend-day:nth-child(even) .trend-label { visibility: hidden; }
  .publication-row { grid-template-columns: 1fr; gap: 10px; }
  .row-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .preview-grid { grid-template-columns: 1fr; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
}

@media (prefers-reduced-transparency: reduce) {
  .sidebar, .toolbar { background: var(--surface); backdrop-filter: none; }
  dialog::backdrop { backdrop-filter: none; }
}

@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease; }
}
