:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #15170f;
  --muted: #6b6f63;
  --line: #e4e6df;
  --brand: #53e01f;
  --brand-ink: #0d1a05;
  --brand-soft: #e9fbe0;
  --danger: #d6372b;
  --warn: #c98a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e100c; --panel: #171a14; --ink: #eef1e8; --muted: #9aa190; --line: #262a21;
    --brand-soft: #1b2a12; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 Inter, system-ui, sans-serif; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; }
a { color: inherit; }
code { background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.sidebar { width: 240px; flex-shrink: 0; border-right: 1px solid var(--line); background: var(--panel); padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 0 8px 22px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 13px; }
nav a { display: block; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
nav a:hover { background: var(--bg); color: var(--ink); }
nav a.active { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.side-foot { margin-top: auto; display: grid; gap: 6px; }

main { flex: 1; padding: 32px 40px 80px; max-width: 1240px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
header h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: 4px 0 22px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.create { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 960px) { .grid2, .create { grid-template-columns: 1fr; } .sidebar { display: none; } main { padding: 20px 16px; } }

.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 10px; }
.row.between { justify-content: space-between; align-items: center; margin: 0; }
.row > label { flex: 1; min-width: 160px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 10px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-top: 4px; }
input[type=checkbox] { width: auto; margin: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.row > input { flex: 1; margin: 0; }

button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 9px 16px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--muted); }
.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.primary:hover { filter: brightness(.95); border-color: var(--brand); }
.ghost { background: transparent; }
.small { padding: 6px 12px; font-size: 13px; }
.big { padding: 12px 22px; font-size: 15px; margin-top: 14px; width: 100%; justify-content: center; }
button:disabled { opacity: .45; cursor: not-allowed; }
.danger { color: var(--danger); }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.steps { padding-left: 18px; }
.steps li { margin-bottom: 4px; }
.pill { font-size: 12px; padding: 6px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.pill.ok { background: var(--brand-soft); border-color: transparent; color: var(--ink); }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.toolbar span { margin-right: auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tiles.small { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.tiles.mini { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; max-height: 520px; overflow: auto; padding: 2px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; cursor: default; }
.tile.selectable { cursor: pointer; }
.tile.selected { outline: 3px solid var(--brand); outline-offset: -1px; }
.thumb { aspect-ratio: 9/16; background: #222 center/cover no-repeat; display: grid; place-items: center; color: #fff; font-size: 12px; position: relative; }
.tiles.small .thumb { aspect-ratio: 1; background-size: contain; background-color: var(--bg); }
.thumb video { width: 100%; height: 100%; object-fit: cover; }
.tile .meta { padding: 8px 10px; font-size: 12px; }
.tile .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.tile .actions { display: flex; gap: 4px; padding: 0 8px 8px; flex-wrap: wrap; }
.tile .actions button, .tile .actions a { padding: 4px 8px; font-size: 11.5px; border-radius: 8px; }
.badge { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; z-index: 1; }
.badge.ok { background: var(--brand); color: var(--brand-ink); }
.badge.err { background: var(--danger); }
.badge.work { background: #111; }
.badge.work::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: 5px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.err-text { color: var(--danger); font-size: 11.5px; padding: 0 10px 8px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 960px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12px; font-weight: 600; }

.checklist { display: grid; gap: 8px; }
.checklist a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.checklist .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; display: grid; place-items: center; font-size: 11px; }
.checklist .done .dot { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.checklist .done { color: var(--muted); }

.prompt-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.prompt-item .row { margin: 0; align-items: center; }
.prompt-item p { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; white-space: pre-wrap; max-height: 4.5em; overflow: hidden; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); font-weight: 600; }

.table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.spark { width: 90px; height: 26px; }

.big-time { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.heat { display: grid; grid-template-columns: 44px repeat(5, 1fr); gap: 3px; font-size: 11px; margin-top: 10px; }
.heat div { padding: 6px 2px; text-align: center; border-radius: 5px; }
.heat .h { color: var(--muted); font-weight: 600; }
.windows li { margin-bottom: 4px; }

#toast { position: fixed; bottom: 22px; right: 22px; display: grid; gap: 8px; z-index: 50; }
#toast div { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 420px; }
dialog { border: 0; padding: 0; background: transparent; width: min(640px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .card { margin: 0; }
.empty { color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; grid-column: 1 / -1; }

.grid2.flat { gap: 24px; }
.summary { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-top: 14px; font-size: 13px; }
.summary .line { display: flex; justify-content: space-between; padding: 3px 0; }
.summary .line span:first-child { color: var(--muted); }
.summary .total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 15px; }
.summary .warn { color: var(--warn); margin-top: 6px; }
.sound { display: inline-flex; gap: 4px; align-items: center; font-size: 11.5px; background: var(--brand-soft); color: var(--ink); padding: 2px 8px; border-radius: 999px; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.badge.used { background: #555; }

/* ── v2 layout: shell, topbar, notifications, mobile ── */
body { display: block; }
.sidebar { position: fixed; left: 0; top: 0; z-index: 20; }
.shell { margin-left: 240px; min-height: 100vh; }
.logo { object-fit: contain; }
nav a i { font-style: normal; width: 22px; display: inline-block; opacity: .8; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 10px; padding: 10px 40px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .brand { padding: 0; font-size: 16px; }
.grow { flex: 1; }
.mobile-only { display: none !important; }
.icon-btn { position: relative; background: var(--panel); border-radius: 999px; padding: 7px 11px; font-size: 16px; }
.icon-btn .count { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.notif-panel { position: fixed; right: 16px; top: 58px; width: min(400px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.18); }
.ev { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.ev:last-child { border-bottom: 0; }
.ev .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--muted); }
.ev.success .dot { background: var(--brand); } .ev.error .dot { background: var(--danger); }
.ev.unread b::after { content: ' •'; color: var(--brand); }
.ev small { color: var(--muted); display: block; white-space: pre-wrap; word-break: break-word; }
.tabbar, .more-sheet { display: none; }
.nowrap { white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
select.inline { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.card > summary h3 { margin: 0; display: inline; }
details.card > summary::after { content: '▾'; float: right; color: var(--muted); }
details[open].card > summary { margin-bottom: 10px; }
.conn-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.conn-head h3 { margin: 0; }
.pill.err { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border-color: transparent; }
.table-wrap { overflow-x: auto; }
.links { padding-left: 18px; margin: 0; } .links li { margin: 6px 0; }
.sticky { position: sticky; top: 70px; }
.savebar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); }
.badge.hot { left: auto; right: 8px; background: #ff4d2e; }
.trend-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.trend { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.trend h4 { margin: 0; font-size: 15px; }
.trend .row { margin-top: auto; padding-top: 8px; }
.stage { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.stage.emerging { background: var(--brand); color: var(--brand-ink); } .stage.rising { background: #ffb020; color: #2a1a00; } .stage.peaking { background: var(--line); }
.hot-card { border-color: #ff4d2e; }
.warm-day { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.warm-day input { margin-top: 3px; }
.warm-day.today { background: var(--brand-soft); border-radius: 8px; padding: 8px; }
.ai-chip { font-size: 11.5px; color: var(--muted); display: block; margin-top: 3px; }
.caption { background: var(--bg); border-radius: 8px; padding: 6px 8px; font-size: 12px; margin-top: 6px; white-space: pre-wrap; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .shell { margin-left: 0; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .mobile-only { display: flex !important; }
  main { padding: 16px 16px 110px; }
  header h1 { font-size: 22px; }
  .card { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tiles.small { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles.mini { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: 360px; }
  .toolbar select.inline { flex: 1 1 100%; order: -1; }
  .statgrid { gap: 1px 6px; font-size: 11px; }
  .sticky { position: static; }
  .toolbar { flex-wrap: wrap; }
  .row > label { min-width: 100%; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 4px max(6px, env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; font-size: 10.5px; color: var(--muted); font-weight: 600; padding: 4px 0; border-radius: 10px; }
  .tabbar a i { display: block; font-style: normal; font-size: 18px; line-height: 1.3; }
  .tabbar a.active { color: var(--ink); background: var(--brand-soft); }
  .more-sheet { display: grid; position: fixed; bottom: 70px; right: 10px; z-index: 26; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 16px 48px rgba(0,0,0,.2); min-width: 220px; }
  .more-sheet[hidden] { display: none; }
  .more-sheet a { padding: 12px 14px; text-decoration: none; border-radius: 10px; font-weight: 600; }
  .more-sheet a:hover { background: var(--bg); }
  #toast { left: 16px; right: 16px; bottom: 84px; }
  .savebar { bottom: 64px; }
  .tile .actions button, .tile .actions a { padding: 7px 10px; font-size: 12px; }
}

.age { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin: 3px 0; }
.age.fresh { background: var(--brand-soft); color: #2a8a0a; }
.age.aging { background: #fff1d6; color: #9a6400; }
.age.stale { background: #fde2df; color: var(--danger); }
@media (prefers-color-scheme: dark) { .age.fresh { color: var(--brand); } .age.aging { background: #3a2a08; color: #ffc04d; } .age.stale { background: #3a1210; color: #ff7a6e; } }
.tiles.mini .age { font-size: 10px; padding: 0 5px; display: block; width: fit-content; }

.statgrid { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 11.5px; font-variant-numeric: tabular-nums; margin: 3px 0; }
.statgrid .age { margin: 0; }
tr.winner td { background: color-mix(in srgb, var(--brand) 12%, transparent); }

.badge.score { left: auto; right: 8px; background: #333; }
.badge.score.s1 { background: #8a6d00; } .badge.score.s2 { background: #c76a00; } .badge.score.s3, .badge.score.s4 { background: #ff4d2e; }
.acct { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; }
.acct img { width: 52px; height: 52px; border-radius: 50%; background: var(--bg); }
.acct-stats { display: flex; gap: 22px; margin-left: auto; }
.acct-stats div { display: flex; flex-direction: column; }
.acct-stats b { font-size: 22px; letter-spacing: -.02em; }
.acct-stats span { color: var(--muted); font-size: 12px; }
.acct-stats em { color: #2a8a0a; font-style: normal; font-weight: 700; }
.spark.big { width: 100%; height: 46px; flex-basis: 100%; }
.auto-fav { border: 1px dashed var(--line); border-radius: 10px; padding: 4px 12px; margin-bottom: 12px; }
#insights h4 { margin: 8px 0 0; font-size: 13px; }

.bp { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.bp-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 10px 0 4px; }
.bp-stats span { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); }
.bp-stats b { font-size: 18px; color: var(--ink); letter-spacing: -.02em; }
@media (max-width: 960px) { .bp-stats { grid-template-columns: repeat(3, 1fr); } }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; }
#radar-list .tile { display: flex; flex-direction: column; }
#radar-list .actions { margin-top: auto; padding-top: 8px; }

html, body { overflow-x: hidden; max-width: 100%; }
.tile, .card, .trend, main { min-width: 0; }
.tile .meta { overflow: hidden; }
textarea, input, select { max-width: 100%; }

.share-card { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 10px; margin-bottom: 14px; background: var(--brand-soft); }

.hooks { display: grid; gap: 5px; margin-top: 6px; }
.hook { text-align: left; white-space: normal; font-weight: 500; font-size: 12px; padding: 7px 9px; display: block; }
.hook.on { border-color: var(--brand); background: var(--brand-soft); }
