/* Semios runtime — Aperture v1.0 (Void #0A0F1A · Haze #EEF1F5 · Edge #2EB8E0).
   Self-contained; no external fonts. Spatial, congruent, calm — a workspace,
   not a wall of forms. */

:root {
    --void: #0A0F1A;
    --void-2: #0E1524;
    --panel: #111A2B;
    --haze: #EEF1F5;
    --edge: #2EB8E0;
    --edge-dim: rgba(46, 184, 224, 0.14);
    --muted: #7C8A9C;
    --ok: #4caf6a;
    --warn: #e2b14b;
    --danger: #d4685c;
    --rule: rgba(238, 241, 245, 0.08);
    --rule-2: rgba(238, 241, 245, 0.045);
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --rail-w: 200px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: radial-gradient(1200px 600px at 80% -10%, #10203a 0%, var(--void) 55%) fixed;
    color: var(--haze); font-family: var(--ui); font-size: 15.5px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }
code, .sel { user-select: all; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ── shell ── */
#app-shell {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: "brand top" "rail stage";
    height: 100vh; height: 100dvh;
}
#topbar {
    grid-area: top; display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px; border-bottom: 1px solid var(--rule);
    background: rgba(10, 15, 26, 0.7); backdrop-filter: blur(8px);
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 9px; padding: 0 18px;
    border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); }
.brand-mark { color: var(--edge); font-size: 20px; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; font-size: 17px; }
.brand-tag { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; }

.chips { display: flex; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--void-2); border: 1px solid var(--rule); color: var(--haze);
    border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer;
    transition: border-color .15s;
}
.chip:hover { border-color: var(--edge); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(76,175,106,.6); }
.dot.warn { background: var(--warn); }
.dot.fail { background: var(--danger); }

/* ── rail ── */
#rail { grid-area: rail; display: flex; flex-direction: column; gap: 2px; padding: 14px 12px;
    border-right: 1px solid var(--rule); }
.nav-item {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    background: transparent; border: none; color: var(--muted); cursor: pointer;
    padding: 11px 13px; border-radius: 9px; font-size: 14.5px; transition: all .12s;
}
.nav-item:hover { background: var(--rule-2); color: var(--haze); }
.nav-item.active { background: var(--edge-dim); color: var(--haze); }
.nav-item.active .nav-ico { color: var(--edge); }
.nav-ico { font-size: 15px; width: 18px; text-align: center; }

/* ── stage ── */
#stage { grid-area: stage; overflow-y: auto; position: relative; }
.view { display: none; max-width: 860px; margin: 0 auto; padding: 26px 28px 40px; }
.view.active { display: flex; flex-direction: column; min-height: 100%; }
.view-head { margin-bottom: 18px; }
.view-head h1 { margin: 0; font-size: 25px; font-weight: 650; letter-spacing: -0.02em; }
.lede { margin: 7px 0 0; color: var(--muted); font-size: 14px; max-width: 64ch; line-height: 1.55; }

/* ── conversation (Semios) ── */
.conversation { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 8px 0 16px; min-height: 200px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; margin: auto; padding: 40px 0; }
.msg { display: flex; flex-direction: column; gap: 5px; max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg-body {
    white-space: pre-wrap; word-break: break-word; border-radius: 14px; padding: 11px 15px; font-size: 15px;
}
.msg.user .msg-body { background: var(--edge); color: var(--void); border-bottom-right-radius: 4px; }
.msg.assistant .msg-body { background: var(--panel); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
.msg.thinking .msg-body { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:.4 } 50% { opacity:.9 } }
.msg-prov { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 0 4px; }
.prov-pill { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
    padding: 1px 7px; border-radius: 3px; border: 1px solid var(--ok); color: var(--ok); }
.prov-pill.warn { border-color: var(--warn); color: var(--warn); }
.prov-pill.fail { border-color: var(--danger); color: var(--danger); }
.prov-meta { color: var(--muted); font-family: var(--mono); }

.composer { display: flex; gap: 10px; align-items: flex-end; position: sticky; bottom: 0;
    padding: 12px 0 6px; background: linear-gradient(transparent, var(--void) 24%); }
.composer textarea {
    flex: 1; resize: none; background: var(--void-2); color: var(--haze);
    border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.4;
    max-height: 180px; overflow-y: auto;
}
.composer textarea:focus { outline: none; border-color: var(--edge); }
.composer-foot { color: var(--muted); font-size: 12px; margin: 2px 2px 0; font-family: var(--mono); }

button#send, .actions button, button.ghost, button.danger {
    background: var(--edge); color: var(--void); border: none; border-radius: 10px;
    padding: 11px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
button#send:hover { opacity: .88; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--haze); border: 1px solid var(--rule); font-weight: 500; }
button.ghost:hover { border-color: var(--edge); opacity: 1; }
button.danger { background: transparent; color: var(--danger); border: 1px solid rgba(212,104,92,.4); font-weight: 500; }

/* ── banners ── */
.banner { border-radius: 10px; padding: 12px 15px; font-size: 13.5px; margin-bottom: 12px; line-height: 1.5;
    border: 1px solid var(--rule); background: var(--panel); }
.banner.warn { border-color: rgba(226,177,75,.4); background: rgba(226,177,75,.08); }
.banner.fail { border-color: rgba(212,104,92,.4); background: rgba(212,104,92,.08); }
.banner code { font-family: var(--mono); color: var(--edge); }
.banner .link { background: none; border: none; color: var(--edge); cursor: pointer; padding: 0; font-size: inherit; text-decoration: underline; }
.banner pre.plan { background: var(--void); border: 1px solid var(--rule); border-radius: 8px; padding: 12px;
    font-family: var(--mono); font-size: 11.5px; color: var(--haze); overflow-x: auto; margin: 10px 0 0; white-space: pre; }

/* ── cards / kv ── */
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; margin: 0 0 16px; }
.card h2 { margin: 0 0 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.grid .card { margin: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--rule-2); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex: none; }
.kv .v { font-family: var(--mono); font-size: 12.5px; text-align: right; word-break: break-all; }
.kv .v.small { font-size: 11.5px; }
.fingerprint { color: var(--edge); }
.card-body { font-size: 13.5px; }
.big-num { font-size: 34px; font-weight: 650; color: var(--edge); letter-spacing: -0.02em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.status { margin: 12px 0 0; font-size: 13px; }
.status.ok { color: var(--ok); } .status.fail { color: var(--danger); } .status.pending { color: var(--warn); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 10px 0 0; }
.btn-link { display: inline-block; margin-top: 6px; color: var(--edge); text-decoration: none; font-size: 14px; }
.btn-link:hover { text-decoration: underline; }
.inline-form { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.inline-form input { background: var(--void-2); border: 1px solid var(--rule); border-radius: 8px; color: var(--haze); padding: 8px 10px; font-size: 13px; flex: 1; min-width: 90px; }
.inline-form input:focus { outline: none; border-color: var(--edge); }

.meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; }
.pill { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--ok); color: var(--ok); }
.pill.fail { border-color: var(--danger); color: var(--danger); }

/* ── memory ── */
.memory-list { display: flex; flex-direction: column; gap: 12px; }
.mem-card { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; }
.mem-q { color: var(--muted); font-size: 13px; margin-bottom: 8px; padding-left: 12px; border-left: 2px solid var(--edge); }
.mem-a { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.mem-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11px; }

/* ── presence ── */
.presence-list { list-style: none; margin: 0; padding: 0; }
.presence-list li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 8px 0; border-bottom: 1px solid var(--rule-2); font-family: var(--mono); font-size: 13px; }
.presence-list li:last-child { border-bottom: none; }
.presence-list .pp { color: var(--edge); }
.presence-list .meta { color: var(--muted); font-size: 12px; }

/* ── explainer ── */
details.explainer { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; }
details.explainer summary { padding: 13px 16px; cursor: pointer; list-style: none; color: var(--muted); font-size: 13px; }
details.explainer summary::-webkit-details-marker { display: none; }
details.explainer summary::before { content: "▸"; color: var(--edge); margin-right: 10px; display: inline-block; transition: transform .15s; }
details.explainer[open] summary::before { transform: rotate(90deg); }
details.explainer .body { padding: 0 18px 16px; font-size: 14px; line-height: 1.6; }
details.explainer .body code { font-family: var(--mono); font-size: 12.5px; color: var(--edge); }

.log { position: fixed; bottom: 0; left: 0; right: 0; max-height: 160px; overflow-y: auto;
    background: rgba(0,0,0,.85); color: var(--haze); font-family: var(--mono); font-size: 11px;
    padding: 10px; white-space: pre-wrap; margin: 0; z-index: 50; }

/* ── deployment ── (Aperture v1.0 vocabulary; reuses .card/.grid/.pill/.dot) */
.view[data-view="deployment"] { max-width: 1080px; }
.dep-tile { display: flex; flex-direction: column; gap: 4px; }
.dep-tile h2 { margin: 0 0 4px; }
.dep-tile .big-num { font-size: 30px; line-height: 1; }

.dep-pill {
    font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .06em; padding: 2px 8px; border-radius: 3px;
    border: 1px solid var(--muted); color: var(--muted);
}
.dep-pill.ok { border-color: var(--ok); color: var(--ok); }
.dep-pill.warn { border-color: var(--warn); color: var(--warn); }
.dep-pill.fail { border-color: var(--danger); color: var(--danger); }
.dep-pill.edge { border-color: var(--edge); color: var(--edge); }
.dep-pill.await { border-color: #a78bfa; color: #a78bfa; }
.dep-pill.muted { border-color: var(--muted); color: var(--muted); }

.dep-chain { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.dep-chain-node { display: inline-flex; align-items: center; gap: 8px;
    background: var(--void-2); border: 1px solid var(--rule); padding: 6px 10px; border-radius: 8px; }
.dep-chain-node code { color: var(--edge); font-family: var(--mono); font-size: 11.5px; }
.dep-chain-title { color: var(--haze); font-size: 13px; }
.dep-arrow { color: var(--muted); font-family: var(--mono); }

.dep-action-list { list-style: none; padding: 0; margin: 0; counter-reset: depact; }
.dep-action-list li {
    display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
    padding: 10px 4px; border-bottom: 1px solid var(--rule-2); counter-increment: depact;
}
.dep-action-list li:last-child { border-bottom: none; }
.dep-action-list li::before { content: counter(depact); color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: center; }
.dep-action-id { display: none; } /* counter already gives the rank; id repeats in title */
.dep-action-id code, .dep-action-list code { font-family: var(--mono); color: var(--edge); font-size: 11.5px; }
.dep-action-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dep-action-title { font-size: 14px; }
.dep-action-todo { font-size: 12.5px; }
.dep-action-score { display: flex; flex-direction: column; align-items: flex-end; min-width: 64px; }
.dep-action-score strong { color: var(--edge); font-size: 18px; font-weight: 650; }
.dep-action-score .muted { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; }

.dep-decision { background: var(--void-2); border: 1px solid var(--rule); border-radius: 8px;
    padding: 12px 14px; margin: 0 0 10px; }
.dep-decision:last-child { margin-bottom: 0; }
.dep-decision-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.dep-decision-head code { color: var(--edge); font-family: var(--mono); font-size: 12px; }
.dep-decision-urgency { font-family: var(--mono); font-size: 10.5px; padding: 2px 8px; border-radius: 3px;
    border: 1px solid var(--muted); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dep-decision-urgency.u-high { border-color: var(--danger); color: var(--danger); }
.dep-decision-urgency.u-medium { border-color: var(--warn); color: var(--warn); }
.dep-decision-urgency.u-low { border-color: var(--muted); color: var(--muted); }
.dep-decision-q { font-size: 14px; margin-bottom: 8px; }
.dep-decision-options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.dep-option { font-size: 12px; padding: 3px 8px; border-radius: 4px;
    background: rgba(46, 184, 224, 0.08); color: var(--haze); border: 1px solid var(--rule); }
.dep-decision-meta { font-size: 12px; }
.dep-decision-meta code { color: var(--edge); font-family: var(--mono); font-size: 11px; }

.dep-chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.dep-chk { background: var(--void-2); border: 1px solid var(--rule); border-left: 3px solid var(--muted);
    border-radius: 6px; padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dep-chk.ok { border-left-color: var(--ok); }
.dep-chk.edge { border-left-color: var(--edge); }
.dep-chk.warn { border-left-color: var(--warn); }
.dep-chk.fail { border-left-color: var(--danger); }
.dep-chk.await { border-left-color: #a78bfa; }
.dep-chk.muted { border-left-color: var(--muted); }
.dep-chk-head { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.dep-chk-label { color: var(--edge); font-family: var(--mono); font-size: 11.5px; }
.dep-chk-sess { color: var(--muted); font-family: var(--mono); font-size: 10.5px; }
.dep-chk-title { font-size: 12.5px; line-height: 1.35; word-break: break-word; }
.dep-chk-foot { display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px;
    color: var(--muted); font-family: var(--mono); }

.dep-surface-list, .dep-activity-list, .dep-history-list { list-style: none; padding: 0; margin: 0; }
.dep-surface-list li { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px;
    align-items: center; padding: 7px 0; border-bottom: 1px solid var(--rule-2); font-size: 13px; }
.dep-surface-list li:last-child { border-bottom: none; }
.dep-surface-name strong { color: var(--haze); }
.dep-surface-meta { font-family: var(--mono); font-size: 11.5px; }
.dep-surface-link { color: var(--edge); text-decoration: none; font-size: 13px; padding-left: 6px; }
.dep-surface-link:hover { text-decoration: underline; }

.dep-activity-list li { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid var(--rule-2); font-size: 12.5px; align-items: center; }
.dep-activity-list li:last-child { border-bottom: none; }
.dep-repo { font-family: var(--mono); color: var(--edge); font-size: 11px; word-break: break-all; }
.dep-act-msg { word-break: break-word; }
.dep-act-when { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.dep-history-list li { display: flex; align-items: center; gap: 12px; padding: 5px 0;
    border-bottom: 1px solid var(--rule-2); font-family: var(--mono); font-size: 11.5px; }
.dep-history-list li:last-child { border-bottom: none; }
.dep-history-list code { color: var(--edge); }

@media (max-width: 720px) {
    .dep-action-list li { grid-template-columns: 30px 1fr auto; }
    .dep-surface-list li { grid-template-columns: 14px 1fr auto; }
    .dep-surface-list .dep-surface-link { grid-column: 4; }
    .dep-activity-list li { grid-template-columns: 1fr auto; }
    .dep-activity-list .dep-repo { grid-column: 1 / -1; }
}

/* ── mobile: rail becomes a bottom tab bar ── */
@media (max-width: 720px) {
    #app-shell { grid-template-columns: 1fr; grid-template-rows: 56px 1fr 64px;
        grid-template-areas: "top" "stage" "rail"; }
    .brand { display: none; }
    #topbar { grid-area: top; }
    #rail { grid-area: rail; flex-direction: row; border-right: none; border-top: 1px solid var(--rule);
        padding: 6px; justify-content: space-around; background: rgba(10,15,26,.92); }
    .nav-item { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 10.5px; flex: 1; align-items: center; }
    .nav-ico { font-size: 18px; }
    .view { padding: 18px 16px 28px; }
    .msg { max-width: 92%; }
}

/* ── UX-layer additions: messages · content viewer · curator ── */
#chip-curator { cursor: pointer; }
.msg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg-head .pp { font-weight: 600; font-size: 13px; }
button.mini, .ghost.mini { padding: 1px 7px; font-size: 12px; line-height: 1.4; }
#msg-to { flex: 1; min-width: 0; background: var(--surface, #11182a); color: inherit; border: 1px solid var(--rule, #232c46); border-radius: 6px; padding: 7px 8px; }
#msg-body { width: 100%; box-sizing: border-box; resize: vertical; background: var(--surface, #11182a); color: inherit; border: 1px solid var(--rule, #232c46); border-radius: 6px; padding: 8px; margin-top: 8px; font: inherit; }
.cv-out { margin-top: 10px; }
.cv-badge { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.cv-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--rule, #232c46); image-rendering: auto; }
.cv-pre { max-height: 320px; overflow: auto; background: rgba(0,0,0,.25); border-radius: 8px; padding: 10px; font-family: var(--mono, ui-monospace, Menlo, monospace); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
