/* patchnotes ops — mobile-first (bottom tab bar) with a desktop sidebar.
   Light/dark via prefers-color-scheme; ink/chart tokens follow the
   validated reference palette. */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --ok: #006300;
  --ok-dot: #0ca30c;
  --bad: #d03b3b;
  --warn-bg: #fdf6e3;
  --border: rgba(11, 11, 11, 0.10);
  --danger: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
  --tabbar-h: calc(58px + env(safe-area-inset-bottom));
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --ok: #0ca30c;
    --ok-dot: #0ca30c;
    --bad: #e66767;
    --warn-bg: #302a15;
    --border: rgba(255, 255, 255, 0.10);
    --danger: #e66767;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- layout: shell + sidebar (desktop) + tabbar (mobile) ---------- */
.shell { max-width: 780px; margin: 0 auto; padding: 0 14px var(--tabbar-h); }
main { padding-bottom: 24px; }

.pagehead {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 2px 10px;
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.pagehead-brand { font-size: 1.1rem; }
.pagehead-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { color: var(--muted); font-size: 0.85rem; margin: -6px 0 14px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none;
  font-size: 0.65rem; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 10px; min-width: 56px;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a.active { color: var(--accent); }

.sidebar { display: none; }

@media (min-width: 880px) {
  .tabbar { display: none; }
  :root { --tabbar-h: 0px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 0; left: 0; bottom: 0; width: 210px;
    padding: 18px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .sidebar .brand { font-weight: 700; font-size: 1rem; padding: 4px 10px 16px; }
  .sidebar a, .sidebar .linklike {
    display: block; width: 100%; text-align: left;
    color: var(--ink-2); text-decoration: none;
    padding: 8px 10px; border-radius: 8px; font-size: 0.92rem;
    background: none; border: 0; cursor: pointer; font-family: inherit;
  }
  .sidebar a:hover, .sidebar .linklike:hover { background: var(--surface-2); }
  .sidebar a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
  .sidebar-sep { height: 1px; background: var(--border); margin: 10px 6px; }
  .shell { margin-left: 210px; max-width: none; padding: 0 32px 32px; }
  .shell > header, .shell main { max-width: 760px; }
}

/* ---------- typography helpers ---------- */
h1 { font-size: 1.25rem; margin: 10px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 0.95rem; margin: 4px 0 8px; color: var(--ink-2); }
a { color: var(--accent); text-decoration: none; }
section { margin: 18px 0; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 0.8rem; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; word-break: break-all; }
td.ts { white-space: nowrap; word-break: normal; font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem; color: var(--ink-2); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.error { background: var(--warn-bg); border: 1px solid var(--border); color: var(--ink);
         padding: 9px 12px; border-radius: 10px; white-space: pre-wrap; font-size: 0.88rem; }
.notice { background: var(--surface); border: 1px solid var(--border);
          padding: 9px 12px; border-radius: 10px; white-space: pre-wrap; font-size: 0.88rem; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 2px; vertical-align: 1px; }
.ok-bg { background: var(--ok-dot); }
.bad-bg { background: var(--bad); }
.neutral-bg { background: var(--axis); }

/* ---------- panels & tiles ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); margin-bottom: 10px;
}
.panel-link { font-size: 0.78rem; text-transform: none; letter-spacing: 0; font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; border: 1px solid transparent; }
.tile.warn { background: var(--warn-bg); border-color: var(--border); }
.tile-label { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; }
.tile-value { font-size: 1.15rem; font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.linktile { color: inherit; display: block; }
.linktile:hover { border-color: var(--accent); }

.status-rows { margin-top: 12px; display: grid; gap: 6px; }
.status-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.status-row .muted { margin-left: auto; text-align: right; }

.trigger-list { display: grid; gap: 10px; }
.trigger-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.trigger-row form { margin: 0; }

/* ---------- cards (drafts / plan / sources lists) ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin: 8px 0;
  box-shadow: var(--shadow);
}
.card.burned { opacity: 0.6; }
.card-title { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; font-size: 0.95rem; }
.preview { margin: 6px 0; color: var(--ink-2); font-size: 0.86rem; overflow-wrap: anywhere; }
.prio { display: inline-block; background: var(--surface-2); border: 1px solid var(--border);
        border-radius: 6px; padding: 0 6px; font-size: 0.72rem; margin-right: 6px;
        font-variant-numeric: tabular-nums; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 2px 0 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 6px 13px; border-radius: 16px; border: 1px solid var(--border);
          color: var(--ink-2); font-size: 0.83rem; white-space: nowrap; background: var(--surface); }
.tabs a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---------- buttons & forms ---------- */
.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.row-actions form { margin: 0; }
button, .btn-sm {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 9px;
  padding: 9px 16px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
button:disabled { opacity: 0.55; cursor: default; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; display: inline-block; text-decoration: none; }
.btn-sm.danger, button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-quiet { background: transparent; color: var(--ink-2); border: 1px solid var(--border); }
.linklike { text-decoration: none; }

input[type="password"], input[type="url"], input[type="text"], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--axis);
  border-radius: 9px; background: var(--surface); color: var(--ink);
  font: inherit;
}
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 0.84rem; line-height: 1.5; }
.inline-form { display: flex; gap: 8px; margin: 10px 0; }
.inline-form input { flex: 1; min-width: 0; }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; background: var(--surface);
        border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
td, th { padding: 7px 10px; border-top: 1px solid var(--grid);
         text-align: left; font-variant-numeric: tabular-nums; font-size: 0.86rem; }
th { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; border-top: 0; }
tr:first-child td { border-top: 0; }
.panel table { border: 0; border-radius: 0; background: none; }
.panel td, .panel th { padding-left: 2px; padding-right: 10px; }
.scroll-x { overflow-x: auto; }

/* ---------- draft text / logs ---------- */
.post-text {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; white-space: pre-wrap;
  overflow-wrap: anywhere; font-family: inherit; font-size: 0.92rem; margin: 6px 0;
}
.logbox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; overflow-x: auto;
  font: 0.7rem/1.55 ui-monospace, Menlo, monospace; white-space: pre;
}

/* ---------- charts ---------- */
.chart-card { background: var(--surface); border: 1px solid var(--border);
              border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.spark { width: 100%; height: auto; display: block; margin-top: 6px; }
.spark .axis { stroke: var(--axis); stroke-width: 1; }
.spark .series { stroke: var(--accent); }
.spark .series-dot { fill: var(--accent); }
.spark .chart-ink { fill: var(--muted); font-size: 11px; }
.chart-range { margin-top: 4px; }
details summary { cursor: pointer; color: var(--ink-2); padding: 6px 0; font-size: 0.88rem; }

/* ---------- more page ---------- */
.menu-list { display: grid; gap: 8px; }
.menu-list a {
  display: grid; gap: 2px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px;
  box-shadow: var(--shadow);
}
.menu-list a span { color: var(--muted); font-size: 0.8rem; }
.signout { margin-top: 20px; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100dvh;
              margin: 0; background: var(--page); color: var(--ink);
              font: 16px system-ui, -apple-system, "Segoe UI", sans-serif; }
.login-card { width: min(320px, 88vw); display: grid; gap: 12px; text-align: center; }
.login-card h1 { font-size: 2.4rem; margin: 0; }
.login-card input { padding: 12px; border: 1px solid var(--axis); border-radius: 10px;
                    background: var(--surface); color: var(--ink); font: inherit; text-align: center; }
.login-card button { background: var(--accent); color: var(--accent-ink); border: 0;
                     border-radius: 10px; padding: 12px; font: inherit; font-weight: 600; cursor: pointer; }
.login-card .error { background: var(--warn-bg); border: 1px solid var(--border);
                     padding: 8px; border-radius: 8px; font-size: 0.85rem; }
