@import "./theme.css";
@import "./site-navigation.css";
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--background); color: var(--text); font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow: hidden; }
button, select, input { font: inherit; }
button, select { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); min-height: 34px; padding: 5px 10px; }
button, select, summary { cursor: pointer; }
button:hover:not(:disabled), select:hover:not(:disabled) { background: var(--surface-soft); }
button:disabled, select:disabled { cursor: default; opacity: .45; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible, [role="separator"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
a { color: var(--muted); text-decoration: none; }
a:hover { color: var(--accent); }
.mobile-tabs button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.workspace-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 24px; border-bottom: 1px solid var(--border); }
.file-picker, .compile-controls { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-picker label { color: var(--muted); font-size: 12px; }
.file-picker select { min-width: 260px; max-width: 100%; }
.compile-controls { font-size: 12px; flex-wrap: wrap; }
.workspace-toolbar { flex-wrap: wrap; }
input[type="checkbox"] { accent-color: var(--accent); }
.primary { background: var(--accent); color: var(--button-text); border-color: var(--accent); font-weight: 550; }
.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(.93); }
kbd { margin-left: 14px; font: inherit; opacity: .75; }
.main-layout { flex: 1; min-height: 0; display: flex; }
.guide { width: 282px; flex: 0 0 282px; overflow: auto; border-right: 1px solid var(--border); }
.guide summary { padding: 17px 22px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); }
.guide summary span { float: right; font-variant-numeric: tabular-nums; }
.guide-content { padding: 22px; }
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; font-weight: 650; margin: 0 0 10px; }
h1 { font-size: 26px; line-height: 1.18; letter-spacing: -.6px; font-weight: 550; margin: 0 0 16px; }
.guide p, .guide li { font-size: 13px; }
.guide p { margin: 0 0 16px; }
.guide ul { padding-left: 17px; margin: 0 0 24px; }
.guide li { margin: 10px 0; color: var(--muted); }
h2 { font-size: 13px; font-weight: 650; margin: 0 0 9px; }
.lesson-section { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 24px; }
.lesson-section p { color: var(--muted); margin-bottom: 8px; }
.text-button { color: var(--accent); background: transparent; border: 0; padding: 2px 0; font-size: 12px; }
.challenge { background: var(--accent-soft); padding: 16px; border-radius: 8px; margin: 22px 0; }
.challenge h2 { color: var(--accent); }
.challenge p { margin: 0; }
.lesson-navigation { display: flex; justify-content: space-between; gap: 8px; }
.lesson-navigation button { font-size: 12px; padding: 5px 8px; }
.guide .guide-footnote { color: var(--muted); font-size: 11px; margin: 17px 0 0; }
.editor-workspace { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.editors { display: flex; flex: 1; min-height: 0; background: var(--surface); }
.editor-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.source-pane { width: var(--source-width, 50%); }
.output-pane { flex: 1; }
.panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; min-height: 54px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.file-title, .panel-actions, .output-picker { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-title { overflow-wrap: anywhere; }
.file-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.panel-actions button { border-color: transparent; background: transparent; color: var(--muted); min-height: 28px; padding: 3px 6px; font-size: 11px; }
.output-picker select { font-size: 12px; min-height: 28px; padding: 3px 6px; max-width: 180px; }
.output-picker label { color: var(--muted); }
.subtle-label { font-size: 10px; color: var(--muted); }
.editor { flex: 1; min-height: 0; }
.editor-loading { padding: 20px; color: var(--muted); }
.stage-description { border-bottom: 1px solid var(--border); background: var(--background); padding: 10px 14px; font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.stage-description code { font-size: 10px; }
#resize-handle { width: 5px; flex: 0 0 5px; background: var(--background); border-inline: 1px solid var(--border); cursor: col-resize; touch-action: none; }
#resize-handle:hover, #resize-handle:focus, #resize-handle.dragging { background: var(--accent); }
.status-bar { min-height: 34px; padding: 7px 14px; display: flex; align-items: center; gap: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
#compile-status { margin-right: auto; }
#compile-status[data-state="success"] { color: var(--accent); }
#compile-status[data-state="error"] { color: var(--error); }
#cursor-position { white-space: nowrap; }
.problems { max-height: 45%; overflow: auto; background: var(--error-bg); border-top: 1px solid var(--border); padding: 14px; }
.problems-header { display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--error); }
.problems-header button { color: var(--error); background: transparent; font-size: 11px; }
.problems pre { font: 12px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.simulation-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; border-top: 1px solid var(--border); background: var(--background); padding: 14px; overflow: auto; }
.simulation-title { display: flex; align-items: baseline; gap: 10px; color: var(--text); }
.simulation-title span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.simulation-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.simulation-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.simulation-controls label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; }
.simulation-controls input { min-height: 27px; border: 1px solid var(--border); border-radius: 5px; padding: 3px 5px; background: var(--surface); color: var(--text); font-size: 11px; }
.simulation-inputs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.simulation-inputs label { display: inline-flex; align-items: center; gap: 4px; font: 12px/1.4 "SFMono-Regular", Consolas, monospace; }
.simulation-inputs input[type="text"] { width: 92px; min-height: 27px; border: 1px solid var(--border); border-radius: 5px; padding: 3px 5px; background: var(--surface); color: var(--text); }
#simulation-options { margin: 12px 0 0; color: var(--muted); font-size: 11px; }
#simulation-options summary { display: inline-block; }
#simulation-options .simulation-note { margin: 7px 0 0; font-size: 11px; color: var(--muted); }
#simulation-options .simulation-controls { margin: 8px 0 0; }
#simulation-output { flex: 1; min-height: 80px; margin: 12px 0 0; font: 12px/1.5 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow: auto; overflow-wrap: anywhere; color: var(--text); }
#simulation-framebuffer { display: block; width: min(640px, 100%); max-width: 100%; max-height: 360px; object-fit: contain; image-rendering: pixelated; margin-top: 8px; background: #000; border: 1px solid var(--border); }
.output-pane[data-view="simulation"] .stage-description, .output-pane[data-view="simulation"] #output-panel { display: none; }
.output-pane[data-view="simulation"] > .panel-header { display: none; }
.output-pane[data-view="simulation"] #simulation-panel { border-top: 0; }
.output-pane:not([data-view="simulation"]) #simulation-panel { display: none; }
.notice { padding: 9px 24px; color: var(--text); background: var(--accent-soft); font-size: 12px; }
.notice button { margin-left: 12px; padding: 2px 7px; min-height: 25px; }
.mobile-tabs { display: none; }
dialog { width: min(520px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); }
dialog::backdrop { background: #0008; }
dialog h2 { font-size: 18px; }
dialog p { color: var(--muted); font-size: 13px; }
dialog input { display: block; width: 100%; padding: 10px; margin: 8px 0; border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--text); }
.dialog-header, .dialog-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 1100px) {
    .guide { width: 245px; flex-basis: 245px; }
    .guide-content { padding: 18px; }
    .panel-header { padding: 8px 10px; }
    .status-bar #save-status { display: none; }
}
@media (max-width: 820px) {
    .workspace-toolbar { padding: 10px 16px; }
    .main-layout { flex-direction: column; }
    .guide { width: 100%; flex: 0 0 auto; max-height: 42%; border-right: 0; border-bottom: 1px solid var(--border); }
    .guide summary { padding: 10px 16px; }
    .guide-content { max-width: 680px; margin: auto; }
    .guide-content h1 { font-size: 23px; }
    .file-picker select { min-width: 0; max-width: 300px; width: 100%; }
    .auto-label { font-size: 11px; }
}
@media (max-width: 580px) {
    .workspace-toolbar { flex-wrap: wrap; gap: 9px; }
    .file-picker { width: 100%; }
    .file-picker select { max-width: none; flex: 1; }
    .compile-controls { width: 100%; justify-content: space-between; }
    .mobile-tabs { display: flex; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
    .mobile-tabs button { flex: 1; font-size: 12px; border: 0; background: transparent; }
    #resize-handle { display: none; }
    .source-pane, .output-pane { width: 100%; flex: 1; }
    .editors[data-view="source"] .output-pane, .editors[data-view="output"] .source-pane { display: none; }
    .status-bar { gap: 8px; }
    #cursor-position { display: none; }
    .guide { max-height: 35%; }
}
@media (pointer: coarse) {
    button, select { min-height: 40px; }
    .panel-actions button { min-height: 36px; }
}

.source-files { display: flex; flex-shrink: 0; gap: 2px; overflow-x: auto; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.source-files button { flex-shrink: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 11px; padding: 5px 8px; }
.source-files button[aria-pressed="true"] { color: var(--text); border-color: var(--border); background: var(--surface); }

/* Shared fixed header rows keep both code surfaces aligned at every split. */
.editor-pane > .panel-header { height: 54px; min-height: 54px; flex: 0 0 54px; flex-wrap: nowrap; overflow: hidden; }
.file-title { flex: 1; overflow: hidden; white-space: nowrap; }
#input-filename { overflow: hidden; text-overflow: ellipsis; }
.panel-actions, #source-kind, #draft-badge { flex-shrink: 0; }
.source-files, .stage-description { box-sizing: border-box; height: 44px; min-height: 44px; flex: 0 0 44px; align-items: center; flex-wrap: nowrap; }
.stage-description { overflow: hidden; }
#stage-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stage-command { flex-shrink: 0; }

/* Collapse both secondary rows when there is only one source file. */
.editors[data-imports="false"] .stage-description { display: none; }
