:root {
  --bg: #f5f5f3; --surface: #fff; --sidebar: #ecebe8; --text: #1d1d1b; --muted: #6b6b66; --line: #dedcd6;
  --accent: #0a62d6; --accent-text: #fff; --err: #b3261e; --folder: #4aa3f0; --file: #9a9a94;
  --new: #6b6b66; --wip: #b26a00; --review: #2b59c3; --changes: #b3261e; --approved: #1e7a46;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614; --surface: #1f1f1d; --sidebar: #252523; --text: #ecebe6; --muted: #9b9a94; --line: #34332f;
    --accent: #3b82f0; --accent-text: #fff; --err: #f2867f; --folder: #5ab0f5; --file: #8a8a84;
    --new: #9b9a94; --wip: #e0a043; --review: #7ea2f0; --changes: #f2867f; --approved: #5cc48a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 1.4em; margin: 0; }
.spacer { flex: 1; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 5px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--err); margin-top: 22px; }
input, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(380px, 100%); display: grid; gap: 12px; }
.card h1 { margin: 0; font-size: 22px; }
.card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

#app { display: flex; flex-direction: column; height: 100vh; }
.top { display: flex; gap: 12px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.brand { font-weight: 650; }
#search { max-width: 260px; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill[data-state="ready"] { color: var(--approved); border-color: var(--approved); }
.pill[data-state="error"] { color: var(--err); border-color: var(--err); }
.pill[data-state="starting"] { color: var(--wip); border-color: var(--wip); }
.banner { margin: 0; padding: 8px 16px; font-size: 13px; background: color-mix(in srgb, var(--wip) 14%, var(--surface)); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }

/* ---- Finder-style browser ---- */
.browser { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.bbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.icon-btn { width: 28px; height: 26px; padding: 0; font-size: 20px; line-height: 1; border-radius: 6px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; font-size: 13px; }
.crumbs button { border: none; background: none; padding: 2px 5px; border-radius: 5px; color: var(--muted); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); border: none; }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--muted); }
.blist { flex: 1; overflow-y: auto; padding: 4px 6px; outline: none; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: default; user-select: none; min-height: 28px; }
.row .ico { flex: none; width: 20px; height: 20px; }
.row .ico.dir { color: var(--folder); }
.row .ico.file { color: var(--file); }
.row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .mt { flex: none; font-size: 12px; color: var(--muted); }
.row .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.row[aria-selected="true"] { background: color-mix(in srgb, var(--text) 14%, transparent); }
.blist:focus .row[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.blist:focus .row[aria-selected="true"] .mt, .blist:focus .row[aria-selected="true"] .ico { color: var(--accent-text); }
.blist:focus .row[aria-selected="true"] .dot { box-shadow: 0 0 0 2px var(--accent-text); }
.bempty { padding: 16px 12px; color: var(--muted); font-size: 13px; }
.bfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; }

/* ---- board ---- */
.board { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 12px; padding: 16px; overflow: auto; align-items: start; }
.col { background: color-mix(in srgb, var(--surface) 60%, var(--bg)); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 120px; }
.col h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 2px 4px 10px; display: flex; justify-content: space-between; color: var(--c); }
.col h2 span { color: var(--muted); }
.item { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.item .n { font-weight: 550; overflow-wrap: anywhere; }
.item .f { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.item .badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: color-mix(in srgb, var(--wip) 18%, transparent); color: var(--wip); margin: 4px 4px 0 0; }
.item.gone { opacity: .55; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 4px; }
.hint { grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 2px 4px; }

/* ---- detail panel ---- */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--surface); border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; box-shadow: -8px 0 24px rgba(0,0,0,.08); z-index: 5; }
.panel h2 { margin: 0 28px 4px 0; font-size: 17px; overflow-wrap: anywhere; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.close { position: absolute; top: 12px; right: 12px; border: none; font-size: 22px; line-height: 1; padding: 2px 8px; background: none; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.seg button[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: var(--accent-text); }
#cform { display: grid; gap: 8px; justify-items: end; }
.events { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.events li { border-left: 2px solid var(--line); padding-left: 10px; }
.events .h { font-size: 12px; color: var(--muted); }
.events .t { overflow-wrap: anywhere; white-space: pre-wrap; }

@media (max-width: 860px) {
  #app { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .browser { border-right: none; border-bottom: 1px solid var(--line); max-height: 50vh; }
  .board { grid-template-columns: 1fr; }
}
