/* =============================================================================
   seven panel — design tokens

   One board, two shapes. On a phone the columns stack into a filtered list; from
   900px up the same markup becomes a real kanban grid. Nothing ever scrolls on
   two axes at once, because that is what made the first version unusable.
   ========================================================================== */

:root {
  color-scheme: dark light;

  /* space — 4px base */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;

  /* radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;

  /* type */
  --t-xs: 11.5px; --t-sm: 12.5px; --t-md: 14px;
  --t-base: 15px; --t-lg: 17px; --t-xl: 20px; --t-2xl: 26px;

  --rail: 196px;
  --tap: 44px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* dark is the default: this is read on a phone, often at night */
:root {
  --bg:       #0d0f13;
  --surface:  #14171d;
  --surface-2:#1b1f27;
  --surface-3:#232833;
  --line:     #262c37;
  --line-2:   #323a48;
  --text:     #e8eaef;
  --text-2:   #a6aebd;
  --text-3:   #737d8d;
  --accent:   #6b9bff;
  --accent-ink:#ffffff;
  --shadow:   0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm:0 1px 2px rgba(0,0,0,.3);

  --s-idea:        #9b8cf5;  --s-idea-bg:        #201d33;
  --s-ready:       #6b9bff;  --s-ready-bg:       #16203a;
  --s-in_progress: #e3b04b;  --s-in_progress-bg: #2a2313;
  --s-qa:          #4fb3d0;  --s-qa-bg:          #12262e;
  --s-blocked:     #ef7060;  --s-blocked-bg:     #2e1a17;
  --s-done:        #4ec18d;  --s-done-bg:        #122a20;
  --ok: #4ec18d; --warn: #e3b04b; --bad: #ef7060;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:       #f6f7f9;
    --surface:  #ffffff;
    --surface-2:#f1f3f6;
    --surface-3:#e6e9ee;
    --line:     #e0e4ea;
    --line-2:   #ccd3dc;
    --text:     #161a20;
    --text-2:   #59616e;
    --text-3:   #848d9b;
    --accent:   #2f6bdd;
    --accent-ink:#ffffff;
    --shadow:   0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.08);
    --shadow-sm:0 1px 2px rgba(16,24,40,.06);

    --s-idea:        #6b4fd8;  --s-idea-bg:        #f0ecfd;
    --s-ready:       #2f6bdd;  --s-ready-bg:       #e8f0ff;
    --s-in_progress: #a5720a;  --s-in_progress-bg: #fdf3dd;
    --s-qa:          #10708c;  --s-qa-bg:          #e2f4fa;
    --s-blocked:     #c5392a;  --s-blocked-bg:     #fdeae7;
    --s-done:        #12794f;  --s-done-bg:        #e3f7ed;
    --ok: #12794f; --warn: #a5720a; --bad: #c5392a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: var(--t-base); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { overscroll-behavior-y: none; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* =============================================================================
   shell
   ========================================================================== */

.app { min-height: 100dvh; }

.content { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3);
  display: flex; align-items: center; gap: var(--s3);
}
.topbar h1 { font-size: var(--t-lg); letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-3);
  flex: none; transition: background .3s;
}
.pulse.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }

main {
  flex: 1;
  padding: var(--s4) var(--s4) calc(var(--s8) + 68px);
  width: 100%; max-width: 1360px; margin: 0 auto;
}
section[hidden] { display: none !important; }

/* nav — bottom tab bar on phones, side rail from 900px */
.rail {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.rail .brand { display: none; }
.rail a, .rail button.navitem {
  flex: 1; border: 0; background: none; cursor: pointer;
  height: 62px; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: var(--t-xs); font-weight: 500; font-family: inherit;
  transition: color .15s;
}
.rail .navitem .ico { width: 22px; height: 22px; display: block; }
.rail .navitem.active { color: var(--accent); }
.rail .navitem .badge {
  position: absolute; transform: translate(14px, -12px);
  background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: var(--r-full); min-width: 16px; text-align: center;
}

/* =============================================================================
   primitives
   ========================================================================== */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s4);
  margin-bottom: var(--s4); box-shadow: var(--shadow-sm);
}
.panel > h2 {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); margin-bottom: var(--s3); font-weight: 700;
  display: flex; align-items: center; gap: var(--s2);
}
.panel > h2 .spacer { flex: 1; }

button, .btn {
  font-family: inherit; font-size: var(--t-md); font-weight: 550;
  min-height: 38px; padding: 0 var(--s3);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2); white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s;
}
button:hover { background: var(--surface-3); }
button:active { transform: scale(.975); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: none; border-color: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.icon { min-width: 38px; padding: 0; }
button.danger { color: var(--bad); }
button.danger:hover { background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); }

/* Starts an unattended session. Deliberately not .primary: the accent belongs to the
   ordinary next step, and this is the button that goes off and acts on its own. Warm and
   outlined reads as "consequential" without borrowing the red that means destructive. */
button.launch {
  color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line-2));
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
button.launch:hover { background: color-mix(in srgb, var(--warn) 18%, var(--surface-2)); }

select, input, textarea {
  font-family: inherit; font-size: var(--t-md); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 0 var(--s3); min-height: 38px;
}
textarea { padding: var(--s3); line-height: 1.6; resize: vertical; width: 100%; }
select { padding-right: var(--s5); max-width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }

.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.tag {
  font-size: var(--t-xs); font-weight: 600; line-height: 1;
  padding: 4px var(--s2); border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.tag.status { background: var(--st-bg); color: var(--st); }
.tag.prio-1 { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.tag.assigned {
  background: color-mix(in srgb, var(--s-ready) 16%, transparent); color: var(--s-ready);
}
.kcard .mark.assigned { color: var(--s-ready); }
.tl.assigned::before { background: var(--s-ready); }
.tl.unassigned::before { background: var(--text-3); }

.tag.project {
  background: color-mix(in srgb, var(--proj) 16%, transparent);
  color: var(--proj); display: inline-flex; align-items: center; gap: 5px;
}
.tag.project .swatch { width: 7px; height: 7px; border-radius: 2px; background: var(--proj); }

/* the same colour identifies the project everywhere it appears */
.proj .light.brand { background: var(--proj); box-shadow: none; }
.proj .name .swatch {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  background: var(--proj); margin-right: 7px; vertical-align: 1px;
}

.empty { color: var(--text-3); font-size: var(--t-sm); padding: var(--s4) 0; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: var(--s3) var(--s4); font-size: var(--t-md);
  box-shadow: var(--shadow); max-width: min(92vw, 460px);
  animation: toastin .18s var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px) } }

/* =============================================================================
   overview
   ========================================================================== */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: var(--s2); }
.stat { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3); }
.stat .k {
  font-size: var(--t-xs); color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.stat .v {
  font-size: var(--t-xl); font-weight: 650; margin-top: 2px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.stat .v.warn { color: var(--warn); }
.stat .v.bad { color: var(--bad); }

.proj {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) 0; border-bottom: 1px solid var(--line);
}
.proj:last-child { border-bottom: 0; }
.proj:first-child { padding-top: 0; }
.proj .light {
  width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none;
  margin-top: 6px;
}
.proj .light.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.proj .light.fail { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.proj .body { flex: 1; min-width: 0; }
.proj .name { font-weight: 600; font-size: var(--t-md); }
.proj .meta { color: var(--text-3); font-size: var(--t-sm); margin-top: 1px; }
.proj .beat {
  font-size: var(--t-sm); color: var(--text-2); margin-top: var(--s2);
  padding: var(--s2) var(--s3); background: var(--surface-2);
  border-radius: var(--r-sm); border-left: 2px solid var(--accent);
}
.proj .acts { display: flex; gap: var(--s1); flex: none; }
.proj .acts button.ghost { border-color: var(--line); }
/* On a phone the row has no room for three words, so the label is hidden and the
   icon carries the meaning. The label comes back with the sidebar at 900px. */
.proj .acts button { min-width: 38px; padding: 0 var(--s2); }
.proj .acts button span { display: none; }
.proj .acts button svg { flex: none; }

/* =============================================================================
   board
   ========================================================================== */

.toolbar {
  display: flex; gap: var(--s2); align-items: center;
  margin-bottom: var(--s3); flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

/* the filter pills only exist in list mode */
.pills {
  display: flex; gap: var(--s2); overflow-x: auto; margin: 0 calc(-1 * var(--s4));
  padding: 0 var(--s4) var(--s3); scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }
@media (max-width: 899px) {
  .pills {
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
  }
}
.pill {
  flex: none; min-height: 34px; padding: 0 var(--s3);
  border-radius: var(--r-full); border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2);
  font-size: var(--t-sm); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill .n {
  font-size: var(--t-xs); font-weight: 700; color: var(--text-3);
  background: var(--surface-3); padding: 1px 6px; border-radius: var(--r-full);
}
.pill[aria-pressed="true"] {
  background: var(--st-bg, var(--surface-3)); color: var(--st, var(--text));
  border-color: color-mix(in srgb, var(--st, var(--line-2)) 45%, transparent);
}
.pill[aria-pressed="true"] .n { background: color-mix(in srgb, var(--st, var(--text-3)) 20%, transparent); color: inherit; }

.board { display: block; }

.group { margin-bottom: var(--s5); }
.group > h3 {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--st, var(--text-3)); margin-bottom: var(--s2);
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: var(--s2) 0;
}
.group > h3 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st); flex: none; }
.group > h3 .n {
  font-size: var(--t-xs); color: var(--text-3); background: var(--surface-2);
  padding: 1px 7px; border-radius: var(--r-full); font-weight: 700;
}
.group[hidden] { display: none; }

.kcard {
  /* a <button> for keyboard and screen readers, but it must wrap like prose:
     the generic button rule sets nowrap, which clipped every title. */
  white-space: normal;
  position: relative; display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s3);
  margin-bottom: var(--s2); cursor: pointer; min-height: 0;
  box-shadow: var(--shadow-sm); font-family: inherit;
  transition: border-color .15s, transform .08s, box-shadow .15s;
}
.kcard::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; border-radius: var(--r-md) 0 0 var(--r-md); background: var(--proj);
}

/* project attribution: an eyebrow above the title, readable at a glance in a mixed list */
.kcard .eyebrow {
  display: flex; align-items: center; gap: 6px; margin-bottom: 5px;
  font-size: var(--t-xs); font-weight: 700; color: var(--proj);
  letter-spacing: .01em;
}
.kcard .eyebrow .swatch {
  width: 8px; height: 8px; border-radius: 2px; background: var(--proj); flex: none;
}
.kcard .eyebrow .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .eyebrow .cid { color: var(--text-3); font-weight: 600; flex: none; }
.kcard:hover { border-color: var(--line-2); box-shadow: var(--shadow); background: var(--surface); }
.kcard:active { transform: scale(.995); }
.kcard .t {
  font-size: var(--t-md); font-weight: 600; line-height: 1.35; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.kcard .lead {
  color: var(--text-3); font-size: var(--t-sm); margin-top: var(--s1); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kcard .m {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  margin-top: var(--s2); font-size: var(--t-xs); color: var(--text-3);
}
.kcard .m .sep { color: var(--line-2); }
.kcard .marks { margin-left: auto; display: flex; gap: var(--s1); align-items: center; }
.kcard .mark { color: var(--text-3); display: inline-flex; }
.kcard .mark svg { width: 13px; height: 13px; }

/* ---- board layout ----------------------------------------------------------
   Columns only once they can actually hold a card. Six of them need roughly
   1280px next to the rail; below that they squeeze titles into two-letter
   fragments, so 900-1279px gets three wider columns over two rows instead.
   -------------------------------------------------------------------------- */
@media (min-width: 900px) {
  .pills { display: none; }
  .board {
    display: grid; gap: var(--s3);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
  .group { margin-bottom: 0; display: flex; flex-direction: column; min-width: 0;
    background: var(--surface-2); border-radius: var(--r-md); padding: var(--s2); }
  .group[hidden] { display: flex !important; }   /* pills do not apply in board mode */
  .group > h3 { background: none; padding: var(--s1) var(--s2) var(--s2); position: static; }
  .group .stack { min-width: 0; padding: 0 var(--s1); }
  .kcard { padding: var(--s3) var(--s3) var(--s3) calc(var(--s3) + 2px); }
  .kcard .t { font-size: var(--t-sm); -webkit-line-clamp: 4; overflow-wrap: break-word; }
  .kcard .lead { -webkit-line-clamp: 2; }
}

@media (min-width: 1280px) {
  .board { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  /* one row of columns, so each scrolls inside itself rather than stretching the page */
  .group { max-height: calc(100dvh - 210px); }
  .group .stack { overflow-y: auto; overflow-x: hidden; flex: 1; }
  .group .stack::-webkit-scrollbar { width: 6px; }
  .group .stack::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
  .kcard .lead { display: none; }
}

/* activity feed */
.act {
  display: block; width: 100%; text-align: left; white-space: normal;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; padding: var(--s3) 0; min-height: 0; font-family: inherit;
  cursor: pointer;
}
.act:hover { background: none; }
.act:last-child { border-bottom: 0; }
.act .who {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--t-xs); font-weight: 700; color: var(--proj); margin-bottom: 2px;
}
.act .who .swatch { width: 7px; height: 7px; border-radius: 2px; background: var(--proj); flex: none; }
.act .who .when { margin-left: auto; color: var(--text-3); font-weight: 500; flex: none; }
.act .what {
  font-size: var(--t-sm); color: var(--text-2); line-height: 1.45;
  overflow-wrap: anywhere;
}
.act .what b { color: var(--text); font-weight: 600; }

/* =============================================================================
   card detail — full screen on a phone, a dialog on a desktop
   ========================================================================== */

.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5);
  display: flex; align-items: stretch; justify-content: center;
  animation: fade .15s var(--ease);
}
@keyframes fade { from { opacity: 0 } }

.sheet {
  background: var(--bg); display: flex; flex-direction: column;
  width: 100%; max-height: 100dvh; overflow: hidden;
  animation: rise .2s var(--ease);
}
@keyframes rise { from { transform: translateY(16px); opacity: .6 } }

.sheet .head {
  display: flex; align-items: center; gap: var(--s3); flex: none;
  padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.sheet .head .spacer { flex: 1; }
.sheet .head .cid { font-size: var(--t-sm); color: var(--text-3); font-weight: 600; }
.sheet .scroll { flex: 1; overflow-y: auto; padding: var(--s5) var(--s4) var(--s8); }
.sheet .inner { max-width: 720px; margin: 0 auto; }

.sheet .title {
  font-size: var(--t-xl); line-height: 1.25; letter-spacing: -.015em;
  margin-bottom: var(--s3); font-weight: 650;
}
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s5); }

.callout {
  background: var(--st-bg); border: 1px solid color-mix(in srgb, var(--st) 30%, transparent);
  border-radius: var(--r-md); padding: var(--s3) var(--s4);
  font-size: var(--t-sm); color: var(--text-2); margin-bottom: var(--s5);
  display: flex; gap: var(--s3); align-items: flex-start;
}
.callout b { color: var(--st); font-weight: 650; }

.field { margin-bottom: var(--s5); }
.field > label {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); margin-bottom: var(--s2); font-weight: 700;
}
.field > label .spacer { flex: 1; }
.field textarea { background: var(--surface); min-height: 96px; font-size: var(--t-md); }
.field textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-sm); min-height: 168px; }
.field .hint { color: var(--text-3); font-size: var(--t-xs); margin-top: var(--s1); }
.saved { color: var(--ok); font-size: var(--t-xs); font-weight: 600; text-transform: none;
  letter-spacing: 0; opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }

.timeline { position: relative; padding-left: var(--s5); }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl { position: relative; padding-bottom: var(--s4); }
.tl:last-child { padding-bottom: 0; }
.tl::before {
  content: ''; position: absolute; left: calc(-1 * var(--s5) + 1px); top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line-2); border: 2px solid var(--bg);
}
.tl.moved::before { background: var(--accent); }
.tl.note::before { background: var(--warn); }
.tl.progress::before { background: var(--s-qa); }
.tl .when { font-size: var(--t-xs); color: var(--text-3); }
.tl .what { font-size: var(--t-md); margin-top: 2px; white-space: pre-wrap; line-height: 1.5; }
.tl .what .arrow { color: var(--text-3); }

.actionbar {
  flex: none; border-top: 1px solid var(--line); background: var(--surface);
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none;
}
.actionbar::-webkit-scrollbar { display: none; }
.actionbar .label {
  font-size: var(--t-xs); color: var(--text-3); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  display: flex; align-items: center; padding-right: var(--s1); flex: none;
}

@media (min-width: 760px) {
  .scrim { align-items: center; padding: var(--s6); }
  .sheet { max-width: 880px; max-height: min(92dvh, 940px);
    border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .sheet .head { border-radius: var(--r-lg) var(--r-lg) 0 0; padding-top: var(--s3); }
  .actionbar { border-radius: 0 0 var(--r-lg) var(--r-lg); padding-bottom: var(--s3); }
}

/* =============================================================================
   logs
   ========================================================================== */

#logbox {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s3); height: clamp(320px, 60dvh, 720px); overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-sm); line-height: 1.55; white-space: pre-wrap;
  word-break: break-word; color: var(--text-2);
}
#logbox:empty::after { content: 'Noch nichts — Projekt wählen und auf Start tippen.'; color: var(--text-3); }

/* =============================================================================
   login
   ========================================================================== */

.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: var(--s5);
}
form.login { width: 100%; max-width: 360px; }
form.login .mark {
  width: 44px; height: 44px; border-radius: var(--r-md); background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-ink); font-weight: 700; font-size: var(--t-xl);
  margin-bottom: var(--s4);
}
form.login h1 { font-size: var(--t-2xl); letter-spacing: -.02em; }
form.login p.sub { color: var(--text-3); margin: var(--s1) 0 var(--s6); font-size: var(--t-md); }
form.login label {
  display: block; font-size: var(--t-xs); font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--s1);
}
form.login input {
  width: 100%; height: var(--tap); font-size: 16px; /* 16px stops iOS zooming on focus */
  margin-bottom: var(--s4); background: var(--surface);
}
form.login button { width: 100%; height: var(--tap); font-size: var(--t-base); }
.error {
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  color: var(--bad); padding: var(--s3); border-radius: var(--r-sm);
  font-size: var(--t-sm); margin-bottom: var(--s4);
}

/* =============================================================================
   desktop shell: the tab bar becomes a side rail
   ========================================================================== */

@media (min-width: 900px) {
  .app { display: flex; }
  .rail {
    position: sticky; top: 0; bottom: auto; left: 0; right: auto;
    width: var(--rail); flex: none; height: 100dvh;
    flex-direction: column; align-items: stretch;
    border-top: 0; border-right: 1px solid var(--line);
    padding: var(--s3) var(--s2) var(--s2); gap: 2px;
    background: var(--surface);
  }
  .rail .brand {
    display: flex; align-items: center; gap: var(--s2);
    padding: var(--s1) var(--s2) var(--s3); margin-bottom: var(--s2);
    border-bottom: 1px solid var(--line);
    font-weight: 650; font-size: var(--t-md); letter-spacing: -.01em;
  }
  .rail button.navitem, .rail a.navitem {
    flex: none; flex-direction: row; justify-content: flex-start;
    height: 34px; min-height: 34px; padding: 0 var(--s2); border-radius: var(--r-sm);
    font-size: var(--t-md); font-weight: 500; gap: var(--s2);
    color: var(--text-2);
  }
  .rail button.navitem .ico { width: 17px; height: 17px; flex: none; opacity: .85; }
  .rail button.navitem:hover { background: var(--surface-2); color: var(--text); }
  .rail button.navitem.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
  .rail button.navitem.active .ico { opacity: 1; color: var(--accent); }
  .rail button.navitem .badge {
    position: static; transform: none; margin-left: auto;
    background: var(--surface-3); color: var(--text-2);
  }
  .rail button.navitem.active .badge { background: var(--accent); color: var(--accent-ink); }
  .rail .foot {
    margin-top: auto; padding-top: var(--s2); border-top: 1px solid var(--line);
  }
  .rail .foot form { display: block; }
  .rail .foot button.navitem { width: 100%; color: var(--text-3); }
  .content { flex: 1; min-width: 0; }
  .topbar { display: none; }
  main { padding: var(--s6) var(--s6) var(--s7); }
  .proj .acts button span { display: inline; }
  .proj .acts button { min-width: 0; padding: 0 var(--s3); }
}

@media (min-width: 900px) {
  #activitypanel .act .what { max-width: 70ch; }
  .overview-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--s4);
    align-items: start; }
  .overview-grid .panel { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
