/* The IDE: explorer, tabs, editor, bottom panel, status bar. */

.ide { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.ide-main { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(170px, var(--ide-side, 19%), 420px) 5px minmax(0, 1fr); position: relative; }
.ide.no-side .ide-main { grid-template-columns: minmax(0, 1fr); }
.ide.no-side .ide-side, .ide.no-side .ide-main > .gutter { display: none; }
body.dragging { user-select: none; cursor: default; }
body.dragging iframe, body.dragging .monaco-editor { pointer-events: none; }

/* explorer */
.ide-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); }
.ide-side-head { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 6px 0 12px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); flex: none; }
.ide-side-head .tools { margin-left: auto; display: flex; gap: 1px; }
.ide-side-head.fold { cursor: pointer; border-top: 1px solid var(--line); user-select: none; padding-left: 8px; }
.ide-side-head.fold:hover { color: var(--ink-soft); }
.ide-side-head.fold > svg { width: 12px; height: 12px; transition: transform .15s var(--ease); transform: rotate(-90deg); }
.ide-side-head.fold.open > svg { transform: none; }
.icon-btn.flat { width: 26px; height: 26px; border-radius: 6px; flex: none; }
.icon-btn.flat svg { width: 15px; height: 15px; }
.icon-btn.flat.on { color: var(--accent); }
.ide-tree { flex: 1 1 55%; min-height: 60px; overflow-y: auto; padding: 2px 0 10px; outline: none; }
.ide-outline { flex: 1 1 45%; min-height: 0; overflow-y: auto; padding: 2px 0 10px; }
.ide-none { padding: 8px 14px; font-size: 12px; color: var(--faint); line-height: 1.5; }
.tree-row { display: flex; align-items: center; gap: 7px; height: 26px; padding-right: 10px; font-size: 13px; color: var(--ink-soft); cursor: pointer; white-space: nowrap; user-select: none; position: relative; }
.tree-row:hover { background: var(--hover); color: var(--ink); }
.tree-row.on { background: var(--selected); color: var(--ink); }
.tree-row.on::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--accent); }
.tree-row .n { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tree-row svg { width: 14px; height: 14px; flex: none; color: var(--muted); }
.tree-row svg.chev { width: 11px; height: 11px; color: var(--faint); }
.tree-row svg.fold { color: var(--accent); opacity: .85; }
.tree-row.err .n { color: var(--bad); }
.tree-row.warn .n { color: var(--warn); }
.tree-row .count { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--bad); }
.tree-row.warn .count { color: var(--warn); }
.tree-row .tag { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); border: 1px solid var(--line); border-radius: 8px; padding: 0 5px; line-height: 13px; }
.tree-row.editing { padding-right: 8px; }
.tree-row.editing input { flex: 1; min-width: 0; height: 22px; padding: 0 6px; border-radius: 5px; font-size: 13px; border-color: var(--accent); }
.tree-row.sym { height: 23px; font-size: 12.5px; }
.tree-row.sym .d { color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.tree-row.sym svg { width: 13px; height: 13px; }
.tree-row.sym.function svg, .tree-row.sym.method svg, .tree-row.sym.constructor svg { color: var(--c-lesson); }
.tree-row.sym.class svg, .tree-row.sym.struct svg, .tree-row.sym.enum svg, .tree-row.sym.alias svg { color: var(--c-drill); }
.tree-row.sym.field svg, .tree-row.sym.variable svg { color: var(--c-build); }
.tree-row.sym.decl { opacity: .7; }
.ficon { width: 16px; height: 16px; border-radius: 4px; flex: none; display: grid; place-items: center; font-family: var(--font-mono); font-size: 9px; font-weight: 700; line-height: 1; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); --c: var(--muted); }
.ficon.src { --c: var(--c-drill); } .ficon.hdr { --c: var(--c-lesson); } .ficon.data { --c: var(--c-project); } .ficon.doc { --c: var(--muted); }

/* tabs and toolbar */
.ide-work { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) 5px clamp(84px, var(--ide-bottom, 34%), 86%); }
.ide-work.panel-min { grid-template-rows: auto auto minmax(0, 1fr) 0 37px; }
.ide-work.panel-min .ide-panel-body, .ide-work.panel-min > .gutter { display: none; }
.ide-work.panel-max { grid-template-rows: auto 0 0 0 minmax(0, 1fr); }
.ide-work.panel-max .ed-host, .ide-work.panel-max .ide-crumbs, .ide-work.panel-max > .gutter { display: none; }
.ide-bar { display: flex; align-items: stretch; gap: 4px; background: var(--sidebar); border-bottom: 1px solid var(--line); min-height: 38px; padding: 0 8px 0 6px; min-width: 0; }
.ide-bar > .icon-btn { align-self: center; }
.ide-tabs { display: flex; align-items: stretch; min-width: 0; flex: 1; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.ide-tabs::-webkit-scrollbar { display: none; }
.ide-tab { display: flex; align-items: center; gap: 7px; padding: 0 6px 0 11px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; border-right: 1px solid var(--line); position: relative; user-select: none; flex: none; }
.ide-tab:first-child { border-left: 1px solid var(--line); }
.ide-tab:hover { color: var(--ink); background: var(--hover); }
.ide-tab.on { color: var(--ink); background: var(--code-bg); }
.ide-tab.on::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }
.ide-tab.on::before { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--code-bg); }
.ide-tab.err .n { color: var(--bad); } .ide-tab.warn .n { color: var(--warn); }
.ide-tab .d { font-size: 11px; color: var(--faint); }
.ide-tab .x { width: 20px; height: 20px; border: 0; background: none; border-radius: 5px; display: grid; place-items: center; cursor: pointer; color: var(--muted); opacity: 0; padding: 0; }
.ide-tab:hover .x, .ide-tab.on .x { opacity: .75; }
.ide-tab .x:hover { background: var(--selected); opacity: 1; color: var(--ink); }
.ide-tab .x svg { width: 11px; height: 11px; }
.ide-tools { display: flex; align-items: center; gap: 4px; flex: none; padding-left: 6px; }
.ide-tools .btn.run { background: color-mix(in srgb, var(--good) 16%, var(--panel)); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); color: var(--good); font-weight: 600; }
.ide-tools .btn.run:hover { background: color-mix(in srgb, var(--good) 26%, var(--panel)); }
.ide-crumbs { display: flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 14px; font-size: 11.5px; color: var(--faint); background: var(--code-bg); border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); overflow: hidden; white-space: nowrap; }
.ide-crumbs:empty { display: none; }
.ide-crumbs svg { width: 10px; height: 10px; flex: none; }
.ide-crumbs .sym { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--muted); }
.ide-crumbs .sym:hover { color: var(--ink); }
.ide-crumbs .sym svg { width: 12px; height: 12px; }
.ide-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); background: var(--code-bg); }
.ide-empty svg { width: 34px; height: 34px; color: var(--faint); }
.ide-empty p { margin: 6px 0 0; }

/* bottom panel */
.ide-panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: var(--bg); }
.ide-panel .pane-tabs { min-height: 36px; padding: 0 6px 0 8px; overflow-x: auto; scrollbar-width: none; }
.ide-panel .pane-tabs::-webkit-scrollbar { display: none; }
.ide-panel .pane-tabs button.tab { padding: 8px 11px; font-size: 12.5px; }
.ide-panel .pane-tabs .hint { font-size: 11px; color: var(--faint); white-space: nowrap; padding-right: 6px; }
.ide-panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ide-output { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--code-bg); }
.ide-output .head { padding: 8px 16px; font-size: 12px; border-bottom: 1px solid var(--line); color: var(--muted); }
.ide-output .head.ok { color: var(--good); } .ide-output .head.no { color: var(--bad); }
.ide-output pre { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 12px 16px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--ink-soft); }
.ide-input { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.ide-input label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ide-input label.row { flex-direction: row; align-items: center; gap: 9px; color: var(--ink-soft); cursor: pointer; }
.ide-input label.row input { accent-color: var(--accent); }
.ide-input .cap { font-family: var(--font-mono); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--faint); }
.ide-input .hint { font-size: 12px; color: var(--faint); }
.ide-input input[type="text"], .ide-input textarea { font-family: var(--font-mono); font-size: 13px; }
.empty.small { padding: 26px 16px; border: 0; }
.empty.small h3 { font-size: 17px; }

/* status bar */
.ide-status { display: flex; align-items: stretch; min-height: 25px; background: var(--sidebar); border-top: 1px solid var(--line); font-size: 11.5px; padding: 0 4px; flex: none; overflow: hidden; }
.ide-status .st { display: flex; align-items: center; gap: 6px; padding: 0 9px; border: 0; background: none; color: var(--ink-soft); cursor: pointer; white-space: nowrap; font-size: inherit; }
.ide-status .st:hover { background: var(--hover); color: var(--ink); }
.ide-status .st svg { width: 12px; height: 12px; }
.ide-status .st.dim { color: var(--muted); }
.ide-status .st.bad { color: var(--bad); } .ide-status .st.warn { color: var(--warn); } .ide-status .st.run { color: var(--good); }
.ide-status .st.busy svg { animation: blink 1s ease-in-out infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: .25; } }

/* pop-up menu */
.menu { position: fixed; z-index: 90; min-width: 220px; max-width: 340px; padding: 5px; background: var(--panel); border: 1px solid var(--line-hover); border-radius: 10px; box-shadow: var(--shadow); animation: fadeIn .1s; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; font-size: 13px; text-align: left; color: var(--ink); }
.menu-item:hover { background: var(--selected); }
.menu-item[disabled] { opacity: .4; pointer-events: none; }
.menu-item svg, .menu-gap { width: 15px; height: 15px; flex: none; color: var(--muted); }
.menu-item .grow { flex: 1; min-width: 0; }
.menu-item.danger { color: var(--bad); } .menu-item.danger svg { color: var(--bad); }
.menu-item kbd { border: 0; background: none; padding: 0; color: var(--faint); font-size: 10.5px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* history */
.overlay.center { place-items: center; padding: 0; }
.modal.wide { width: min(760px, 94vw); }
.modal.hist { width: min(1180px, 95vw); height: min(760px, 88vh); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.hist-head { display: flex; align-items: baseline; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--line); }
.hist-head h3 { margin: 0; }
.hist-head .icon-btn { align-self: center; }
.hist-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.hist-list { overflow-y: auto; border-right: 1px solid var(--line); padding: 6px; background: var(--sidebar); }
.hist-row { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.hist-row:hover { background: var(--hover); }
.hist-row.on { background: var(--selected); box-shadow: inset 2px 0 0 var(--accent); }
.hist-row b { font-size: 13px; font-weight: 600; }
.hist-row span { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row small { font-size: 11px; color: var(--faint); }
.hist-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.hist-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hist-bar select { padding: 5px 9px; font-family: var(--font-mono); font-size: 12px; max-width: 260px; }
.hist-note { font-size: 12px; color: var(--muted); }
.hist-diff { flex: 1; min-height: 0; position: relative; }
@media (max-width: 760px) { .hist-body { grid-template-columns: 1fr; grid-template-rows: 150px minmax(0, 1fr); } .hist-list { border-right: 0; border-bottom: 1px solid var(--line); } }

/* small windows: the explorer slides over the editor instead of squeezing it */
.ide.narrow .ide-main { grid-template-columns: minmax(0, 1fr); }
.ide.narrow .ide-side { position: absolute; z-index: 12; top: 0; bottom: 0; left: 0; width: min(270px, 82%); box-shadow: var(--shadow); display: flex; }
.ide.narrow.no-side .ide-side { display: none; }
.ide.narrow .ide-main > .gutter { display: none; }
.ide.narrow .ide-tools .btn span, .ide.tight .ide-status .st.dim { display: none; }
.ide.narrow .ide-tools .btn { padding: 5px 8px; }
.ide.narrow .ide-panel .pane-tabs .hint { display: none; }
.ide.tight .ide-crumbs { display: none; }
