:root {
    --bg: #0c0d10;
    --bg-2: #14151b;
    --surface: #1b1d24;
    --line: rgba(244, 241, 234, 0.08);
    --text: #f4f1ea;
    --muted: #9a958b;
    --gold: #e8b86d;
    --gold-2: #c9923f;
    --danger: #ff7a6e;
    --ok: #7dcea0;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --sans: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--sans);
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(232, 184, 109, 0.12), transparent 50%),
        radial-gradient(900px 400px at 100% 0%, rgba(80, 110, 160, 0.12), transparent 45%),
        var(--bg);
    color: var(--text);
}

.app {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 {
    font-family: var(--serif);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0;
    font-size: 1.7rem;
}
.brand p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.mark {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(160deg, var(--gold), var(--gold-2));
    color: #1a1208;
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 700;
}

.top-actions { display: flex; gap: 8px; }

.banner {
    border: 1px solid rgba(232, 184, 109, 0.35);
    background: rgba(232, 184, 109, 0.08);
    color: var(--gold);
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.92rem;
}
.banner.error {
    border-color: rgba(255, 122, 110, 0.4);
    background: rgba(255, 122, 110, 0.08);
    color: var(--danger);
}

.mode-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.mode-chip {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
}
.mode-chip:hover { border-color: rgba(232, 184, 109, 0.45); }
.mode-chip.active {
    background: var(--gold);
    color: #1a1208;
    border-color: var(--gold);
    font-weight: 600;
}

.stage {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 20px;
}

.camera-card, .advice-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.camera-frame {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #09090c;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
}
video, #snapshot {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.camera-empty {
    position: absolute; inset: 0;
    display: grid; place-items: center; align-content: center; gap: 12px;
    padding: 24px; text-align: center; color: var(--muted);
    background: rgba(9, 9, 12, 0.72);
}
.camera-status {
    position: absolute; left: 12px; top: 12px;
    display: flex; align-items: center; gap: 8px;
    background: rgba(12, 13, 16, 0.7);
    padding: 6px 10px; border-radius: 999px; font-size: 0.78rem;
}
.dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
}
.dot.on { background: #ff4d4d; box-shadow: 0 0 10px #ff4d4d; }
.dot.busy { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.rec-badge {
    position: absolute;
    z-index: 4;
    right: 12px;
    top: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #ff2d2d;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 0 0 0 rgba(255, 45, 45, 0.7);
    animation: rec-pulse 1.2s ease-out infinite;
}
@keyframes rec-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 45, 45, 0.65); }
    100% { box-shadow: 0 0 0 12px rgba(255, 45, 45, 0); }
}
.hearing {
    margin: 6px 0 0;
    min-height: 1.45em;
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text);
}
.hearing.live { color: var(--text); }
.hearing.dead { color: var(--danger); font-weight: 650; }
.heard-flash {
    position: absolute;
    z-index: 5;
    left: 12px;
    bottom: 12px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--gold);
    color: #1a1208;
    font-weight: 700;
    font-size: 0.92rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.duration {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
}
.duration input {
    width: 4.2rem;
    padding: 8px 8px;
    text-align: center;
}
#reviewVideo {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.review-panel {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.18);
}
.review-lead { margin: 0; line-height: 1.45; }
.modality {
    border: 0;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.modality legend {
    width: 100%;
    padding: 0;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}
.modality label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}
.modality label:has(input:checked) {
    border-color: var(--gold);
    color: var(--gold);
}
.stop {
    font: inherit;
    cursor: pointer;
    border-radius: 999px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 122, 110, 0.7);
    background: transparent;
    color: var(--danger);
    font-weight: 650;
}
.advice-media {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    background: #09090c;
    border-radius: 12px;
    margin-bottom: 12px;
}
.history-actions { display: flex; gap: 8px; align-items: center; }

.controls {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 14px; align-items: center;
}
.shutter {
    width: 56px; height: 56px; border-radius: 50%;
    border: 3px solid var(--text);
    background: radial-gradient(circle at 50% 50%, #fff 48%, transparent 52%), #111;
    color: transparent;
    cursor: pointer;
}
.shutter:disabled { opacity: 0.35; cursor: not-allowed; }
.shutter:not(:disabled):hover { border-color: var(--gold); }

.primary, .ghost, .save {
    font: inherit; cursor: pointer; border-radius: 999px; padding: 10px 16px;
}
.primary {
    border: 0; background: var(--gold); color: #1a1208; font-weight: 650;
}
.primary:disabled, .ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.listen-on {
    border-color: rgba(232, 184, 109, 0.7);
    color: var(--gold);
}
.ghost, .save {
    border: 1px solid var(--line); background: transparent; color: var(--text);
}
.save { background: var(--gold); color: #1a1208; border: 0; min-width: 5.5rem; }
.save.ok { background: var(--ok); color: #0d1f16; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }
.custom-box { margin-top: 14px; }
.custom-box label, .mode-edit label {
    display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px;
}
textarea, input[type="number"], input[type="text"] {
    width: 100%;
    background: #101116;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
}
textarea { resize: vertical; min-height: 90px; }

.advice-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.advice-head h2, .drawer-panel h2 { font-family: var(--serif); margin: 0 0 12px; font-size: 1.35rem; }
.iris-byline {
    margin: 0 0 2px;
    color: var(--gold);
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.meta { color: var(--muted); font-size: 0.8rem; }
.empty { color: var(--muted); line-height: 1.5; }
.advice-body {
    white-space: pre-wrap;
    font-family: var(--sans);
    line-height: 1.55;
    margin: 0;
    font-size: 0.98rem;
}
.error { color: var(--danger); }
.advice-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-fallback {
    font-size: 0.82rem; color: var(--gold); cursor: pointer;
}
.file-fallback input { display: none; }

[hidden] { display: none !important; }

.drawer {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: grid; justify-items: end;
    z-index: 20;
}
.drawer-panel {
    width: min(520px, 100%);
    height: 100%;
    overflow: auto;
    background: var(--bg-2);
    border-left: 1px solid var(--line);
    padding: 22px;
}
.drawer-panel.wide { width: min(720px, 100%); }
.drawer-panel header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}

.history-list { display: grid; gap: 12px; margin: 16px 0; }
.history-item {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    cursor: pointer;
}
.history-item > img {
    width: 88px; height: 88px; object-fit: cover; border-radius: 10px; background: #000;
}
.history-item h3 { margin: 0 0 4px; font-size: 0.95rem; }
.history-item p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.history-item p.history-response {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.history-item p.history-sent { color: var(--text); margin-bottom: 6px; }
.history-item p.history-kicker {
    margin: 10px 0 4px;
    color: var(--gold);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.request-review {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    cursor: auto;
}
.request-review summary {
    cursor: pointer;
    color: var(--gold);
    font-size: 0.88rem;
}
.request-meta {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 6px 10px;
    margin: 12px 0 4px;
    font-size: 0.82rem;
}
.request-meta dt { color: var(--muted); }
.request-meta dd { margin: 0; word-break: break-word; }
.request-image {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    background: #09090c;
    border-radius: 10px;
    margin-top: 8px;
}
.request-prompt, .request-json {
    white-space: pre-wrap;
    word-break: break-word;
    background: #101116;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.75rem;
    line-height: 1.45;
    max-height: 220px;
    overflow: auto;
    margin: 0;
}
.request-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--gold);
    font-size: 0.82rem;
}

.mode-edit {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    margin: 12px 0;
    background: var(--surface);
}
.mode-edit h3 { margin: 0 0 10px; font-size: 1rem; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 8px; }
.save-status { margin: 8px 0 0; font-size: 0.82rem; color: var(--ok); min-height: 1.2em; }
.hidden { display: none !important; }

@media (max-width: 860px) {
    .stage { grid-template-columns: 1fr; }
    .top { align-items: flex-start; flex-direction: column; }
    .drawer-panel, .drawer-panel.wide { width: 100%; }
}
