:root {
  --bg: #111317; --panel: #181b21; --panel2: #1f232b; --line: #2a2f39; --line2: #353b47;
  --text: #e7e9ee; --muted: #8d94a3; --accent: #f0a34b; --accent-ink: #1b1206;
  --ok: #5fc48a; --warn: #e7c25a; --bad: #e86a5e; --info: #6aa8f0;
  --r: 10px; --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
.hidden { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 22px 0 10px; }
h3 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .tiny { font-size: 12px; } .err { color: var(--bad); min-height: 1em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

.app { display: grid; grid-template-columns: 210px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; padding: 2px 8px 18px; letter-spacing: -.01em; }
.brand.big { font-size: 22px; padding: 0 0 8px; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #c9692a); box-shadow: 0 0 0 3px #f0a34b22; }
nav a { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; margin-bottom: 2px; }
nav a:hover { background: var(--panel2); }
nav a.on { background: #f0a34b1c; color: var(--accent); }
.badge { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 7px; font-weight: 700; }
.badge:empty { display: none; }
.badge.live { background: var(--info); color: #06121f; }
#conn { cursor: pointer; display: flex; align-items: center; gap: 6px; }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }

main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 22px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--bg); }
.view { padding: 20px 22px 60px; overflow: auto; flex: 1; }
.active-run { margin-left: auto; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--info); box-shadow: 0 0 0 0 #6aa8f088; animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px #6aa8f000; } 100% { box-shadow: 0 0 0 0 #6aa8f000; } }

select, input, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 10px; font: inherit; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
textarea.tall { min-height: 220px; font-family: var(--mono); font-size: 12.5px; }
input.wide { width: 100%; }
label.f { display: block; margin: 12px 0 4px; font-size: 12.5px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 13px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #4a5160; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: #1f3a2b; border-color: #2e5c41; color: #bdf0d2; }
.btn.danger { color: #ffb3ab; border-color: #5a2b28; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: default; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card.click { cursor: pointer; } .card.click:hover { border-color: var(--line2); }
.head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 12.5px; }
.empty { border: 1px dashed var(--line2); border-radius: var(--r); padding: 30px; text-align: center; color: var(--muted); }

.chip { display: inline-block; font-size: 11.5px; font-weight: 650; border-radius: 20px; padding: 1px 9px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line2); text-transform: capitalize; }
.chip.review, .chip.changes { color: var(--accent); border-color: #6a4a24; background: #f0a34b14; }
.chip.queued { color: var(--info); border-color: #2c4766; }
.chip.building, .chip.running, .chip.applying { color: #06121f; background: var(--info); border-color: var(--info); }
.chip.approved, .chip.done, .chip.applied { color: var(--ok); border-color: #2e5c41; }
.chip.failed { color: var(--bad); border-color: #5a2b28; }
.tag { display: inline-block; font-size: 11px; color: #c5cad6; background: #262b35; border-radius: 4px; padding: 0 6px; margin: 2px 3px 0 0; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 12px 0; }
.shot { position: relative; border-radius: 8px; overflow: hidden; background: #000; border: 1px solid var(--line); cursor: zoom-in; aspect-ratio: 16/9; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 5px; font-size: 12px; background: linear-gradient(transparent, #000c); }
.shot.plan { grid-column: span 2; grid-row: span 2; }

.prose { white-space: pre-wrap; }
details { margin-top: 8px; } summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }

.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.asset { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; }
.asset:hover { border-color: var(--line2); }
.asset img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #1a1c20; }
.asset .meta { padding: 6px 8px 8px; }
.asset .nm { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset.excluded { opacity: .38; }
.asset .fit { float: right; font-size: 11px; color: var(--accent); }
.drop { border: 1.5px dashed var(--line2); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--accent); }
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.refs .ref { position: relative; } .refs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.refs .x { position: absolute; top: 4px; right: 4px; }

table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 550; font-size: 12px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel); }

.log { background: #0b0c0f; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: 12.5px/1.5 var(--mono); max-height: 60vh; overflow: auto; }
.log div { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.log .tool { color: #9fb7d9; } .log .tool::before { content: "▸ "; color: var(--muted); }
.log .error { color: #f2a097; } .log .info { color: var(--muted); } .log .result { color: var(--ok); }
.log .text { color: var(--text); }
.log .ts { color: #545b69; margin-right: 8px; }

.checks div { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; transform: translateY(-1px); }
.dot.g { background: var(--ok); } .dot.y { background: var(--warn); } .dot.r { background: var(--bad); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch span { width: 34px; height: 20px; border-radius: 20px; background: var(--line2); position: relative; transition: .15s; flex: none; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 17px; }

.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 20; overflow: auto; }
.modal-card { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 20px; width: min(760px, 100%); }
.lightbox { position: fixed; inset: 0; background: #000e; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; gap: 12px; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 6px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--panel2); border: 1px solid var(--line2); padding: 9px 16px; border-radius: 10px; transition: .2s; z-index: 40; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: #5a2b28; color: #ffb3ab; }

.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(420px, 100%); display: grid; gap: 12px; }

.chat-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 16px; height: calc(100vh - 100px); }
.threads { display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.thread { display: block; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.thread b { display: block; font-weight: 550; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread:hover { background: var(--panel); } .thread.on { background: var(--panel2); }
.threads .btn { margin-bottom: 8px; }
.convo { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.convo > .empty { margin: 20px; }
.convo-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.title-in { background: transparent; border-color: transparent; font-weight: 600; flex: 1; min-width: 140px; }
.title-in:hover { border-color: var(--line2); }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; } .msg.user { justify-content: flex-end; }
.bubble { max-width: min(760px, 92%); padding: 10px 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.msg.user .bubble { background: #f0a34b18; border-color: #6a4a24; }
.bubble p { margin: 4px 0; } .bubble ul, .bubble ol { margin: 4px 0; padding-left: 20px; } .bubble h3 { margin: 10px 0 4px; }
.bubble .shots { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.atts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.atts img { height: 110px; border-radius: 6px; cursor: zoom-in; }
.act { border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; margin: 10px 0 4px; background: var(--panel); display: grid; gap: 6px; }
.act.applied { border-color: #2e5c41; } .act.dismissed { opacity: .55; }
.act-body { max-height: 220px; overflow: auto; font-size: 13px; color: #cfd3dc; border-left: 2px solid var(--line2); padding-left: 10px; }
.act-img { max-height: 120px; border-radius: 6px; cursor: zoom-in; justify-self: start; }
.typing { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.live { font: 12px/1.5 var(--mono); color: var(--muted); margin: 6px 0; }
.live .tool::before { content: "▸ "; } .live .error { color: #f2a097; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.composer.over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.composer textarea { min-height: 64px; max-height: 240px; }
.pend { display: flex; gap: 6px; flex-wrap: wrap; } .pend:empty { display: none; }
.pthumb { position: relative; } .pthumb img { height: 64px; border-radius: 6px; display: block; }
.pthumb .x { position: absolute; top: 2px; right: 2px; padding: 0 5px; }
.intro { display: grid; gap: 8px; justify-items: start; } .suggest { text-align: left; white-space: normal; }

.tabs { display: inline-flex; background: var(--panel2); border: 1px solid var(--line2); border-radius: 9px; padding: 3px; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 5px 14px; border-radius: 7px; font: inherit; font-weight: 550; cursor: pointer; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); }
.bible { display: grid; grid-template-columns: 220px 1fr; gap: 18px; margin-top: 14px; }
.cats { display: flex; flex-direction: column; gap: 1px; }
.cat { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 7px; cursor: pointer; color: var(--text); text-decoration: none; font-size: 13px; }
.cat span { color: var(--muted); font-size: 12px; margin-left: 6px; } .cat:hover { background: var(--panel); } .cat.on { background: #f0a34b1c; color: var(--accent); }
.cat.add { color: var(--muted); margin-top: 8px; } .cat-h { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 12px 10px 4px; }
.lib-main { min-width: 0; } .filters { margin-bottom: 12px; }
.upload { padding: 12px 14px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel2); border: 0; color: var(--muted); padding: 6px 10px; font: inherit; font-size: 12.5px; cursor: pointer; border-right: 1px solid var(--line2); }
.seg button:last-child { border-right: 0; }
.seg button.on.match { background: #1f3a2b; color: #bdf0d2; } .seg button.on.inspire { background: #1d2f47; color: #bcd8ff; } .seg button.on.avoid { background: #47201d; color: #ffc4bd; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.refcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.refcard:hover { border-color: var(--line2); }
.refcard.match { box-shadow: inset 0 3px 0 var(--ok); } .refcard.inspire { box-shadow: inset 0 3px 0 var(--info); } .refcard.avoid { box-shadow: inset 0 3px 0 var(--bad); }
.ri { position: relative; } .ri img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #0c0d10; }
.refcard.avoid .ri img { filter: saturate(.5); }
.upill { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 20px; background: #000b; }
.upill.match { color: #9be7bb; } .upill.inspire { color: #a9cbf7; } .upill.avoid { color: #ffaaa1; }
.star { position: absolute; top: 6px; right: 6px; background: #000a; border: 0; color: #777; border-radius: 50%; width: 28px; height: 28px; font-size: 15px; cursor: pointer; }
.star.on { color: #ffd166; }
.refcard .meta { padding: 7px 10px 9px; } .refcard .nm { font-weight: 600; font-size: 12.5px; }
.refcard .note { font-size: 12px; color: #c5cad6; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ref-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; } .ref-edit > img { width: 100%; border-radius: 8px; cursor: zoom-in; align-self: start; }
.refs .ref .upill { bottom: 4px; left: 4px; }

@media (max-width: 760px) {
  .bible { grid-template-columns: 1fr; } .lib-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } .cats { flex-direction: row; flex-wrap: wrap; gap: 4px; } .cat-h { display: none; }
  .cat { background: var(--panel); } .ref-edit { grid-template-columns: 1fr; }
  .chat-wrap { grid-template-columns: 1fr; height: auto; }
  .threads { flex-direction: row; overflow-x: auto; } .threads .btn { width: auto !important; margin: 0; }
  .thread { flex: none; max-width: 160px; }
  .convo { min-height: 70vh; } .msgs { max-height: 60vh; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 0 6px; }
  nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  main { height: auto; } .app { height: auto; min-height: 100vh; }
  .grid2 { grid-template-columns: 1fr; }
  .shot.plan { grid-column: auto; grid-row: auto; }
}
