:root {
  --bg: #f4f5f8; --card: #ffffff; --ink: #14213d; --muted: #5b6478; --line: #dde1ea;
  --accent: #2b59c3; --accent-ink: #ffffff; --ok: #1b7f4b; --warn: #b4690e; --bad: #b3261e; --urgent: #b3261e;
  --alt: #e9edf6; --shadow: 0 1px 2px rgba(20, 33, 61, .08);
  --tabh: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1424; --card: #172036; --ink: #e8ecf6; --muted: #9aa5bd; --line: #26324d;
    --accent: #7aa2ff; --accent-ink: #0b1226; --ok: #4cd08a; --warn: #f0a548; --bad: #ff8a80; --urgent: #ff8a80;
    --alt: #22304f; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(var(--tabh) + env(safe-area-inset-bottom) + 12px) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
a { color: var(--accent); word-break: break-word; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }

#hdr { display: flex; align-items: center; gap: 10px; padding: 10px 16px; position: sticky; top: 0; background: var(--bg); z-index: 5; border-bottom: 1px solid var(--line); min-height: 48px; }
#hdr h1 { font-size: 18px; }
.upd { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live i { width: 10px; height: 10px; border-radius: 50%; background: #8a93a8; display: inline-block; }
.live.on i { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.modetag { font-size: 11px; background: var(--alt); border-radius: 6px; padding: 2px 6px; color: var(--muted); }
.link { background: none; border: 0; color: var(--accent); font: inherit; min-height: 44px; padding: 0 6px; cursor: pointer; }

main { padding: 12px 16px; }
.view { display: none; }
body[data-tab="needs"] #view-needs, body[data-tab="teams"] #view-teams, body[data-tab="ideas"] #view-ideas,
body[data-tab="tonight"] #view-tonight, body[data-tab="usage"] #view-usage, body[data-tab="shop"] #view-shop { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0 0 10px; box-shadow: var(--shadow); }
.card.urgent { border-left: 4px solid var(--urgent); }
.ct { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.tag { font-size: 11px; background: var(--alt); color: var(--muted); border-radius: 6px; padding: 2px 7px; white-space: nowrap; flex: none; }
.tag.ok { color: var(--ok); } .tag.warn { color: var(--warn); }
.meta { color: var(--muted); font-size: 13px; margin: 6px 0 0; overflow-wrap: anywhere; }
.why { margin: 8px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 12px 0; }

.steps { margin: 10px 0 0; padding-left: 22px; }
.steps li { margin: 0 0 8px; overflow-wrap: anywhere; }
.where { font-size: 11px; font-weight: 600; background: var(--alt); border-radius: 5px; padding: 1px 6px; margin-right: 4px; }
.stepurl { margin-left: 4px; }
.cmd { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.cmd code { flex: 1; min-width: 0; background: var(--alt); border-radius: 8px; padding: 8px 10px; font: 12px/1.4 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 8.5em; overflow: auto; }
.copy { min-width: 64px; min-height: 44px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; }

.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.abtn { min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.abtn.alt { background: var(--alt); color: var(--ink); }
.abtn.on { outline: 2px solid var(--ok); }
.abtn:disabled { opacity: .55; cursor: default; }
.pc { font-size: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
.cstate { margin-top: 8px; font-size: 13px; font-weight: 600; }
.cstate.sent { color: var(--warn); } .cstate.done { color: var(--ok); } .cstate.error { color: var(--bad); }

.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.line .bar { flex: 1; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.day { width: 44px; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #8a93a8; }
.dot.run { background: #22c55e; }
.bar { height: 8px; border-radius: 4px; background: var(--alt); overflow: hidden; margin-top: 8px; }
.line .bar { margin-top: 0; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.stats { display: flex; gap: 10px; margin-top: 10px; }
.stats div { flex: 1; background: var(--alt); border-radius: 10px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 20px; } .stats span { font-size: 12px; color: var(--muted); }
details { margin: 10px 0; } summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-weight: 600; }

.authcard { max-width: 420px; margin: 40px auto; }
.authcard label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.authcard input { width: 100%; min-height: 44px; font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); margin-bottom: 12px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tab { flex: 1; min-height: var(--tabh); background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: 4px 0; }
.tab .ti { width: 26px; height: 26px; line-height: 26px; border-radius: 50%; background: var(--alt); font-weight: 700; font-size: 13px; }
.tab.on { color: var(--accent); font-weight: 700; }
.tab.on .ti { background: var(--accent); color: var(--accent-ink); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.toast.on { opacity: 1; }

/* desktop: Needs you wide on the left, the other views on the right, tabs in the header row */
@media (min-width: 1000px) {
  body { padding-bottom: 24px; }
  #hdr { padding-right: 640px; }
  .tabs { top: 0; bottom: auto; left: auto; right: 0; width: 620px; border: 0; background: transparent; padding: 0 16px 0 0; height: 56px; align-items: center; z-index: 6; }
  .tab { flex-direction: row; min-height: 44px; gap: 6px; font-size: 13px; border-radius: 10px; padding: 0 10px; }
  .tab .ti { width: 22px; height: 22px; line-height: 22px; font-size: 11px; }
  .tab[data-tab="needs"] { display: none; }
  .grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; padding: 16px 24px; }
  #view-needs { display: block !important; }
  .view:not(#view-needs) { grid-column: 2; grid-row: 1; }
  #view-needs { grid-column: 1; grid-row: 1; }
  body[data-tab="needs"] #view-teams { display: block; }
  #view-needs .card { padding: 14px 18px; }
  .toast { bottom: 24px; }
}
@media (min-width: 1500px) {
  #view-needs { column-count: 1; }
}
