:root {
    color-scheme: dark;
    --bg: #0b1111;
    --surface: #111b1a;
    --surface-raised: #172321;
    --surface-soft: #1c2a28;
    --line: #2b3a37;
    --text: #eef5ee;
    --muted: #98aaa4;
    --accent: #d6f06b;
    --accent-dark: #172009;
    --cyan: #67d7cc;
    --warning: #f0c36b;
    --danger: #f17c72;
    --success: #79d991;
    --radius: 14px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, textarea, input { font: inherit; }
button { color: inherit; }
code { color: var(--accent); }

.app-shell { min-height: 100vh; }
.topbar {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(11, 17, 17, .94);
    backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.brand-mark, .loading-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid #b9d553;
    border-radius: 10px;
    color: #0a1008;
    background: var(--accent);
    font-family: Georgia, serif;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 0 26px rgba(214, 240, 107, .12);
}
.brand h1 { margin: 0; font-size: 15px; letter-spacing: .01em; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.button {
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: border-color .15s ease, background .15s ease, transform .15s ease, opacity .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { background: var(--accent); color: #101709; border-color: var(--accent); }
.button-secondary { background: var(--surface-raised); border-color: var(--line); }
.button-secondary:hover:not(:disabled) { border-color: #50615d; }
.button-ghost { background: transparent; color: var(--muted); }
.button-danger { background: #4a201f; color: #ffd7d3; border-color: #723432; }
.file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.workspace {
    min-height: calc(100vh - 68px);
    display: grid;
    grid-template-columns: minmax(300px, 34vw) 1fr;
    gap: 14px;
    padding: 14px;
    transition: box-shadow .15s ease;
}
.workspace.drag-active { box-shadow: inset 0 0 0 3px var(--accent); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-heading.compact { padding: 14px 16px; }
.panel-heading h2 { margin: 2px 0 0; font-size: 16px; }
.muted { color: var(--muted); }
.count-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: #0e1716;
    font-size: 11px;
    white-space: nowrap;
}

.welcome-panel {
    grid-column: 1 / -1;
    align-self: center;
    justify-self: center;
    width: min(660px, calc(100vw - 32px));
    padding: 56px;
    border: 1px dashed #50615d;
    border-radius: 22px;
    background: radial-gradient(circle at top, rgba(103, 215, 204, .08), transparent 50%), var(--surface);
    text-align: center;
}
.welcome-panel h2 { margin: 0 0 8px; font-size: clamp(27px, 5vw, 42px); font-family: Georgia, serif; }
.welcome-panel > p { max-width: 520px; margin: 0 auto; color: var(--muted); line-height: 1.6; }
.welcome-actions { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 28px; color: var(--muted); font-size: 12px; }

.editor-pane { position: sticky; top: 82px; display: grid; grid-template-rows: auto auto minmax(420px, 1fr); height: calc(100vh - 96px); }
.file-tabs { display: flex; gap: 2px; padding: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); background: #0d1514; }
.file-tab { display: flex; min-width: 150px; border: 1px solid transparent; border-radius: 8px; overflow: hidden; }
.file-tab.active { border-color: var(--line); background: var(--surface-soft); }
.file-tab-select { display: flex; min-width: 0; flex: 1; align-items: center; gap: 7px; padding: 8px 6px 8px 10px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.file-tab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
.file-tab-status { flex: 0 0 auto; color: var(--cyan); font-size: 8px; }
.file-tab-remove { width: 30px; flex: 0 0 30px; border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.file-tab-remove:hover, .file-tab-remove:focus-visible { color: #fff; background: rgba(255, 255, 255, .08); outline: none; }
.yarn-editor {
    width: 100%;
    min-height: 420px;
    resize: none;
    padding: 18px;
    border: 0;
    outline: none;
    color: #dbe9df;
    background: #0d1514;
    font: 13px/1.58 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}
.yarn-editor::selection { background: rgba(103, 215, 204, .32); }
.yarn-editor.editor-flash { animation: editor-flash .9s ease-out; }
@keyframes editor-flash {
    from { box-shadow: inset 0 0 0 2px var(--cyan); }
    to { box-shadow: inset 0 0 0 2px transparent; }
}

.simulation-pane { display: flex; min-width: 0; flex-direction: column; gap: 14px; }
.diagnostics-panel { max-height: 310px; }
.diagnostic-list { max-height: 175px; overflow-y: auto; }
.empty-filter { margin: 0; padding: 18px 16px; font-size: 12px; }

.diagnostic-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #0d1514; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: transparent;
    font-size: 11px;
    cursor: pointer;
}
.filter-chip span { color: #dbe9df; font-weight: 700; }
.filter-chip:hover:not(:disabled) { border-color: #3a4c48; }
.filter-chip:disabled { opacity: .4; cursor: default; }
.filter-chip.on { color: #0d1514; background: var(--cyan); border-color: var(--cyan); }
.filter-chip.on span { color: #0d1514; }
.filter-chip.error.on { background: var(--danger); border-color: var(--danger); }
.filter-chip.warning.on { background: var(--warning); border-color: var(--warning); }
.filter-select { margin-left: auto; }
.filter-select select {
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #dbe9df;
    background: #0e1716;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.filter-clear { border: 0; background: transparent; color: var(--cyan); font-size: 11px; cursor: pointer; }

.diagnostic { display: grid; width: 100%; grid-template-columns: 24px 1fr; gap: 10px; padding: 10px 16px; border: 0; border-left: 2px solid transparent; border-top: 1px solid #202d2b; background: transparent; text-align: left; cursor: pointer; }
.diagnostic:hover:not(:disabled) { background: var(--surface-raised); }
.diagnostic.active { border-left-color: var(--cyan); background: var(--surface-raised); }
.diagnostic.no-location { cursor: default; }
.diagnostic.no-location strong { color: var(--muted); }
.diagnostic-symbol { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; font-weight: 800; }
.diagnostic.error .diagnostic-symbol { color: var(--danger); background: #3e201e; }
.diagnostic.warning .diagnostic-symbol { color: var(--warning); background: #392f1c; }
.diagnostic.info .diagnostic-symbol { color: var(--cyan); background: #173735; }
.diagnostic strong, .diagnostic small { display: block; }
.diagnostic strong { font-size: 12px; font-weight: 600; }
.diagnostic small { margin-top: 3px; color: var(--muted); font: 10px "Cascadia Code", monospace; }
.empty-simulator { min-height: 280px; display: grid; place-content: center; padding: 40px; text-align: center; }
.empty-simulator h2 { margin: 6px 0; }

.activity-dot { width: 9px; height: 9px; border-radius: 50%; background: #4c5d58; }
.activity-dot.active { background: var(--success); box-shadow: 0 0 12px rgba(121, 217, 145, .65); }
.dialogue-panel { min-height: 245px; }
.dialogue-card { display: grid; grid-template-columns: 54px 1fr; gap: 15px; padding: 20px; }
.speaker-avatar { display: grid; width: 54px; height: 54px; place-items: center; border: 1px solid #42645e; border-radius: 16px; color: var(--cyan); background: #162725; font: 700 22px Georgia, serif; }
.dialogue-copy strong { color: var(--cyan); }
.dialogue-copy p { max-width: 780px; min-height: 50px; margin: 8px 0 16px; font: 20px/1.5 Georgia, serif; }
.dialogue-panel > .muted { padding: 34px 20px; text-align: center; }
.choice-list { display: grid; gap: 8px; padding: 18px; }
.choice { padding: 13px 15px; border: 1px solid #3e514d; border-radius: 10px; background: var(--surface-raised); text-align: left; cursor: pointer; }
.choice:hover:not(:disabled) { border-color: var(--cyan); background: #1b302d; }
.choice:disabled { opacity: .4; }

.outcome-banner, .runtime-error { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 20px; border: 1px solid; border-radius: var(--radius); }
.outcome-banner.won { border-color: #376c46; background: #13291a; }
.outcome-banner.lost, .runtime-error { border-color: #703633; background: #321a19; }
.outcome-banner h2 { margin: 3px 0 0; }
.outcome-banner > strong { font-size: 22px; }
.runtime-error { flex-wrap: wrap; color: #ffd9d6; }

.case-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.accusation-panel { grid-column: 1 / -1; }
.debug-toggle { color: var(--muted); font-size: 11px; }
.debug-toggle input { accent-color: var(--accent); }
.pin-list, .clue-list, .suspect-list { display: grid; gap: 7px; padding: 12px; }
.pin-button { position: relative; display: flex; width: 100%; min-height: 58px; align-items: center; gap: 11px; padding: 10px 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); text-align: left; cursor: pointer; }
.pin-button:hover:not(:disabled) { border-color: var(--cyan); }
.pin-button:disabled { cursor: not-allowed; opacity: .58; }
.pin-state { z-index: 1; color: var(--muted); }
.pin-button.unlocked .pin-state { color: var(--success); }
.pin-button.processing .pin-state { color: var(--warning); }
.pin-copy { z-index: 1; min-width: 0; }
.pin-copy strong, .pin-copy small { display: block; }
.pin-copy strong { font-size: 13px; }
.pin-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.progress-track { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: #2b3325; }
.progress-track span { display: block; height: 100%; background: var(--warning); }

.clue-row { display: grid; grid-template-columns: 20px 1fr; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); }
.clue-row.selected { border-color: #6b7937; background: #202912; }
.clue-row input { margin-top: 4px; accent-color: var(--accent); }
.clue-row span { font-size: 12px; line-height: 1.45; }
.clue-row strong { display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }

.suspect-list { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.suspect { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); text-align: left; cursor: pointer; }
.suspect:disabled { cursor: not-allowed; opacity: .5; }
.suspect.selected { border-color: var(--accent); background: var(--accent-dark); }
.suspect strong, .suspect small { display: block; }
.suspect small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.accusation-footer { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.execution-log summary { padding: 14px 16px; cursor: pointer; font-size: 12px; font-weight: 700; }
.execution-log summary span { margin-left: 6px; color: var(--muted); font-weight: 500; }
.log-list { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--line); }
.log-entry { display: grid; grid-template-columns: 58px 70px 1fr; gap: 10px; padding: 7px 14px; border-top: 1px solid #202d2b; font: 10px/1.4 "Cascadia Code", monospace; }
.log-entry time { color: var(--muted); }
.log-entry strong { color: var(--cyan); text-transform: uppercase; }
.log-entry.erro strong { color: var(--danger); }
.log-entry.comando strong { color: var(--warning); }

.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
#blazor-error-ui { display: none; position: fixed; z-index: 1000; right: 18px; bottom: 18px; left: 18px; padding: 14px; border: 1px solid var(--danger); border-radius: 10px; background: #3b1d1b; }
#blazor-error-ui .reload { margin-left: 8px; color: white; }
#blazor-error-ui .dismiss { float: right; border: 0; background: transparent; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 1050px) {
    .topbar { align-items: flex-start; }
    .toolbar { max-width: 620px; }
    .workspace { grid-template-columns: 1fr; }
    .editor-pane { position: static; height: 620px; }
}

@media (max-width: 700px) {
    .topbar { position: static; flex-direction: column; padding: 13px; }
    .toolbar { justify-content: flex-start; }
    .workspace { min-height: auto; padding: 8px; }
    .editor-pane { height: 520px; }
    .case-grid { grid-template-columns: 1fr; }
    .accusation-panel { grid-column: auto; }
    .welcome-panel { padding: 36px 20px; }
    .welcome-actions { flex-direction: column; }
    .dialogue-card { grid-template-columns: 42px 1fr; padding: 15px; }
    .speaker-avatar { width: 42px; height: 42px; border-radius: 12px; }
    .dialogue-copy p { font-size: 17px; }
    .outcome-banner, .runtime-error { align-items: flex-start; flex-direction: column; }
}
