:root {
  --bg: #f4f1ea; --panel: #fffdf9; --panel-2: #ece8df; --line: #ddd7ca;
  --text: #23211d; --muted: #6f6a60; --accent: #c8421b; --accent-ink: #fff;
  --danger: #b92f22; --shadow: 0 1px 2px rgb(60 50 30 / .12), 0 6px 18px rgb(60 50 30 / .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a; --panel: #1f2127; --panel-2: #292c34; --line: #363943;
    --text: #eceae4; --muted: #a3a3ab; --accent: #ff7a55; --accent-ink: #1c0f0a;
    --danger: #ff8473; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 22px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15161a; --panel: #1f2127; --panel-2: #292c34; --line: #363943;
  --text: #eceae4; --muted: #a3a3ab; --accent: #ff7a55; --accent-ink: #1c0f0a;
  --danger: #ff8473; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 22px rgb(0 0 0 / .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; min-height: 36px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.icon-only { padding: 6px; min-width: 32px; min-height: 32px; }
.btn:disabled { opacity: .55; cursor: default; }
.input {
  width: 100%; padding: 8px 10px; min-height: 38px; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--line);
}
textarea.input { min-height: 110px; resize: vertical; }
input[type="color"].input { padding: 3px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 14px; }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(3, 5px); gap: 2.5px; align-items: start; height: 20px; }
.brand-mark i { display: block; background: var(--accent); border-radius: 1.5px; }
.brand-mark i:nth-child(1) { height: 20px; } .brand-mark i:nth-child(2) { height: 12px; } .brand-mark i:nth-child(3) { height: 16px; }
.auth-card h1 { font-size: 26px; letter-spacing: -.02em; margin: 26px 0 4px; }
.auth-card > p { color: var(--muted); margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-switch { margin-top: 18px; color: var(--muted); text-align: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }

/* Shell */
.shell { height: 100%; display: grid; grid-template-columns: 212px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 22px; padding: 18px 12px 14px; border-right: 1px solid var(--line); }
.sidebar .brand { padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 4px; padding-left: 8px; }
.side-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 16px 24px 12px; }
.topbar h1 { font-size: 21px; letter-spacing: -.02em; }
.topbar .spacer { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; min-height: 28px; border-radius: 99px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--panel-2); color: var(--text); border-color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.view { flex: 1; min-height: 0; overflow: auto; padding: 4px 24px 24px; }
.view.board-view { padding: 4px 0 0; overflow: hidden; display: flex; }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* Board */
.board { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 0 24px 18px; overflow-x: auto; height: 100%; }
.column {
  flex: 0 0 286px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--panel-2); border-radius: 10px;
}
.column-head { display: flex; align-items: center; gap: 7px; padding: 9px 7px 7px 13px; }
.column-head h2 { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-right: auto; }
.cards { display: flex; flex-direction: column; gap: 7px; padding: 2px 8px; overflow-y: auto; min-height: 12px; flex: 0 1 auto; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; flex: none;
  padding: 9px 11px 9px 13px; border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c, transparent); }
.card:hover .card-title { color: var(--accent); }
.card.dragging { display: none; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 10px; min-height: 22px; font-size: 12px; color: var(--muted); }
.card-meta:empty { display: none; }
.prio-high { color: var(--danger); font-weight: 700; }
.due-late { color: var(--danger); font-weight: 700; }
.avatar {
  margin-left: auto; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--panel-2); color: var(--text); font-size: 11px; font-weight: 700; flex: none;
}
.drop-slot { flex: none; border: 2px dashed var(--muted); border-radius: 7px; opacity: .55; }
.column-foot { padding: 5px 8px 8px; }
.column-foot .btn { width: 100%; justify-content: flex-start; }
.add-column { flex: 0 0 200px; justify-content: flex-start; }

/* Journal */
.journal { max-width: 820px; }
.week { margin-bottom: 26px; }
.week-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.week-head h2 { font-size: 15px; }
.week-head span { color: var(--muted); font-size: 13px; }
.week-head .now { color: var(--accent); font-weight: 700; }
.entry { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry-date { text-align: right; padding-right: 12px; border-right: 2px solid var(--c, var(--line)); }
.entry-date b { display: block; font-size: 21px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.entry-date span { font-size: 12px; color: var(--muted); }
.entry-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.entry-top h3 { font-size: 16px; overflow-wrap: anywhere; }
.kind { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 7px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }
.kind.plan { background: var(--accent); color: var(--accent-ink); }
.entry-body { margin-top: 5px; }
.text-line { white-space: pre-wrap; overflow-wrap: anywhere; min-height: .7em; }
.check-line { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; cursor: pointer; overflow-wrap: anywhere; }
.check-line input { margin-top: 4px; accent-color: var(--accent); flex: none; }
.check-line.done span { color: var(--muted); text-decoration: line-through; }
.entry-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-top: 7px; font-size: 12px; color: var(--muted); }
.entry-foot .btn { margin-left: auto; min-height: 26px; padding: 2px 8px; font-size: 13px; }

/* Ideas */
.idea-capture { display: flex; gap: 8px; max-width: 640px; margin-bottom: 18px; }
.idea-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 14px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.segmented button { background: transparent; border: 0; padding: 5px 11px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.ideas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 13px; align-items: start; }
.idea {
  display: flex; flex-direction: column; gap: 8px; padding: 13px 13px 10px; border-radius: 3px 3px 16px 3px; box-shadow: var(--shadow);
  background: color-mix(in srgb, var(--c, var(--muted)) 17%, var(--panel));
}
.idea.parked { opacity: .62; }
.idea h3 { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; cursor: pointer; }
.idea h3:hover { color: var(--accent); }
.idea-body { font-size: 14px; }
.idea-body.collapsed { max-height: 8.7em; overflow: hidden; }
.idea-body.overflowing { -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.idea-toggle { align-self: flex-start; font-size: 13px; }
.idea-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.idea-head .tag { color: var(--text); }
.idea-status { font-size: 12px; color: var(--muted); font-weight: 600; }
.idea-foot { display: flex; align-items: center; gap: 7px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.vote { display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 1px 8px 1px 5px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); background: transparent; font-weight: 700; font-size: 13px; cursor: pointer; }
.vote[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.idea-foot .author { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idea-foot .to-board { margin-left: auto; min-height: 28px; padding: 1px 9px; font-size: 13px; background: transparent; border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.idea-foot .on-board { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* Team */
.team { max-width: 620px; display: flex; flex-direction: column; gap: 28px; }
.team h2 { font-size: 16px; margin-bottom: 9px; }
.team section > p { color: var(--muted); font-size: 14px; margin-bottom: 9px; }
.invite { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.invite code { font: 700 18px/1 ui-monospace, Consolas, monospace; letter-spacing: .08em; padding: 10px 13px; border-radius: 7px; background: var(--panel-2); user-select: all; }
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); min-height: 44px; }
.row-list li > span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-form { display: flex; gap: 8px; }

/* Filters and shared bits */
.game-select { width: auto; max-width: 190px; min-height: 32px; padding: 3px 8px; font-size: 13px; font-weight: 600; }
.dot.square { border-radius: 2px; }
.crumb { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumb:hover { color: var(--text); }
.muted { color: var(--muted); font-size: 14px; }
.role { display: block; color: var(--muted); font-size: 13px; }
.idea-tags { display: flex; flex-wrap: wrap; gap: 3px 10px; min-width: 0; }
.mobile-account { display: none; }

/* Games */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.game-tile {
  display: flex; flex-direction: column; gap: 9px; padding: 14px 15px 13px; border-radius: 10px; background: var(--panel);
  color: inherit; text-decoration: none; box-shadow: var(--shadow); border-top: 4px solid var(--c);
}
.game-tile:hover h2 { color: var(--accent); }
.game-tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.game-tile h2 { font-size: 17px; overflow-wrap: anywhere; }
.game-tile-desc { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-counts { display: flex; gap: 20px; margin: auto 0 0; }
.game-counts div { display: flex; flex-direction: column; }
.game-counts dd { margin: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.game-counts dt { color: var(--muted); font-size: 12px; }
.game-detail { display: flex; flex-direction: column; gap: 26px; }
.game-detail h2 { font-size: 16px; }
.game-summary { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; max-width: 760px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 11px; }
.section-head .btn { margin-left: auto; }
.game-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 26px; }
.game-columns h2, .game-detail > section > h2 { margin-bottom: 7px; }
.row-link { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.row-link:hover { color: var(--accent); }

/* Analytics */
.sources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 14px; align-items: start; }
.source { display: flex; flex-direction: column; gap: 12px; padding: 14px 15px 12px; border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); min-width: 0; }
.source-head { display: flex; align-items: center; gap: 6px; }
.source-title { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 3px 9px; }
.source-title h3 { font-size: 16px; overflow-wrap: anywhere; }
.source-title a { color: inherit; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 7px; }
.metric { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; min-width: 0; }
.metric:disabled { cursor: default; opacity: .6; }
.metric[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.metric b { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.metric-delta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-note { color: var(--muted); font-size: 14px; padding: 18px 0; text-align: center; }
.chart-body { display: flex; height: 150px; margin-top: 7px; }
.chart-y { position: relative; flex: 0 0 72px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-y span { position: absolute; right: 9px; transform: translateY(-50%); white-space: nowrap; }
.chart-plot { position: relative; flex: 1; min-width: 0; touch-action: pan-y; cursor: crosshair; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: .7; }
.chart-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); pointer-events: none; }
.chart-cross { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--muted); pointer-events: none; }
.chart-tip { position: absolute; top: 2px; display: flex; flex-direction: column; padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 2; }
.chart-x { display: flex; justify-content: space-between; margin: 5px 0 0 72px; font-size: 11px; color: var(--muted); }
.source-more summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.source-more[open] summary { margin-bottom: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; }
.data-table th, .data-table td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.data-table td a { overflow-wrap: anywhere; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; padding-left: 12px; white-space: nowrap; }
.source-foot { font-size: 12px; color: var(--muted); }

/* Modal */
dialog.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
dialog.modal::backdrop { background: rgb(15 14 12 / .55); }
.modal form { display: flex; flex-direction: column; gap: 15px; padding: 18px 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 18px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.modal-actions .danger { margin-right: auto; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 9px 15px; border-radius: 8px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 50; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .main { grid-row: 1; }
  .sidebar { grid-row: 2; flex-direction: row; align-items: center; gap: 4px; padding: 4px 8px; border-right: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .side-foot { display: none; }
  .mobile-account { display: block; }
  .nav { flex: 1; flex-direction: row; justify-content: space-between; }
  .nav a { flex-direction: column; gap: 1px; padding: 5px 3px; font-size: 11px; }
  .nav a[aria-current="page"] { box-shadow: inset 0 2px 0 var(--accent); }
  .side-foot { margin: 0; padding: 0; }
  .topbar { padding: 12px 16px 9px; }
  .view { padding: 4px 16px 18px; }
  .board { padding: 0 16px 12px; }
  .column { flex-basis: min(286px, 82vw); }
  .form-grid { grid-template-columns: 1fr; }
  .entry { grid-template-columns: 46px minmax(0, 1fr); gap: 10px; }
  .entry-date { padding-right: 8px; }
}
