/* minikotlin studio — a small multi-file Kotlin IDE in the browser.
   Warm "Ledger" theme: ink-on-paper with a single rust/amber accent, matching
   the landing-page Studio mock. Console is a dark panel docked under the editor. */

:root {
  --paper:    #f4f1ea;
  --paper-2:  #ece7dc;
  --panel:    #fbfaf6;
  --ink:      #1b1916;
  --ink-soft: #4b463e;
  --ink-faint:#857d6e;
  --line:     #dcd6c8;
  --line-strong:#c2baa8;
  --accent:   #bb4a18;
  --accent-deep:#933810;
  --term-bg:  #16140f;
  --term-fg:  #e9e3d4;
  --term-faint:#857f70;
  --term-prompt:#9aa86a;
  --term-ok:  #d39a3a;
  --term-err: #e06a52;
  /* syntax (light) — restrained, ink-family, matches the mock */
  --kw:   #bb4a18;
  --type: #2c6354;
  --str:  #766325;
  --num:  #7d4576;
  --fn:   #2a4d8f;
  --com:  #9a9484;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--ui); font-size: 13px;
  display: grid; grid-template-rows: auto 1fr auto;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4ccba; border-radius: 5px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 50px; padding: 0 16px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand .mark { width: 22px; height: 22px; display: block; flex: none; }
.brand .name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand .name .mini { color: var(--ink-faint); font-weight: 500; }
.brand .name .core { color: var(--ink); }
.topbar .sep { width: 1px; height: 20px; background: var(--line); }

.project-name {
  background: transparent; border: 1px solid transparent; color: var(--ink);
  font-family: var(--ui); font-size: 13px; font-weight: 600;
  padding: 5px 9px; border-radius: 6px; min-width: 80px; max-width: 220px;
}
.project-name:hover  { background: var(--panel); border-color: var(--line); }
.project-name:focus  { background: #fff; border-color: var(--accent); outline: none; }

.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 13px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font-size: 12.5px; font-weight: 500; line-height: 1;
}
.btn:hover { border-color: var(--ink-faint); }
.btn svg { width: 12px; height: 12px; }
.btn.ghost { background: transparent; }
.btn.run {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; letter-spacing: .02em; padding: 0 15px;
}
.btn.run:hover:not(:disabled) { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.run:disabled { opacity: .5; cursor: default; }
.kbd {
  font-family: var(--mono); font-size: 10px; opacity: .85;
  padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.22);
}

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-soft); font-family: var(--mono);
  padding: 3px 10px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line);
}
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.status-badge.busy .dot { background: var(--accent); animation: pulse 1s infinite; }
.status-badge.ok   .dot { background: #4f9d52; }
.status-badge.err  .dot { background: var(--accent); }
.status-badge.idle .dot { background: var(--line-strong); }
@keyframes pulse { 50% { opacity: .35; } }

/* ── body: sidebar | main-area(editor / console) ─────────────────────── */
.studio {
  display: grid;
  grid-template-columns: var(--sidebar-w, 220px) 1fr;
  min-height: 0; overflow: hidden;
}

/* sidebar */
.sidebar { background: var(--paper-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 13px 7px; font-size: 10px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint);
}
.icon-btn { width: 22px; height: 22px; display: grid; place-items: center; border: none; background: transparent; color: var(--ink-faint); border-radius: 5px; }
.icon-btn:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; }

.file-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.file-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; border-radius: 6px; color: var(--ink-soft);
  font-family: var(--mono); font-size: 12px; letter-spacing: -.01em;
  cursor: pointer; user-select: none;
}
.file-row:hover { background: rgba(0,0,0,.045); color: var(--ink); }
.file-row.active {
  background: #fff; color: var(--ink); font-weight: 500;
  box-shadow: inset 2px 0 0 var(--accent), 0 1px 2px rgba(40,28,12,.05);
}
.file-row .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .ki { width: 14px; height: 15px; color: var(--ink-faint); opacity: .5; flex-shrink: 0; }
.file-row:hover .ki { opacity: .8; }
.file-row.active .ki { color: var(--accent); opacity: 1; }
.file-row .entry-badge {
  font-family: var(--ui); font-size: 8.5px; font-weight: 700; letter-spacing: .07em;
  padding: 2px 5px; border-radius: 4px; background: rgba(187,74,24,.1);
  color: var(--accent); text-transform: uppercase;
}
.file-row .row-act { opacity: 0; width: 18px; height: 18px; display: grid; place-items: center; border: none; background: transparent; color: var(--ink-faint); border-radius: 4px; }
.file-row:hover .row-act { opacity: 1; }
.file-row .row-act:hover { background: rgba(187,74,24,.13); color: var(--accent); }
.file-row .row-act svg { width: 12px; height: 12px; }

.sidebar-foot { padding: 10px 13px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--ink-faint); line-height: 1.55; }
.sidebar-foot code { font-family: var(--mono); color: var(--ink-soft); }

/* main area: editor on top, console docked at the bottom */
.main-area { display: grid; grid-template-rows: 1fr 5px var(--console-h, 220px); min-width: 0; min-height: 0; background: var(--panel); }

.editor-wrap { display: flex; flex-direction: column; min-height: 0; }
.editor-head {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px; border-bottom: 1px solid var(--line);
  background: var(--paper-2); color: var(--ink-faint); font-size: 12px;
}
.editor-head .ki { width: 13px; height: 13px; color: var(--accent); }
.editor-head .crumb { color: var(--ink); font-family: var(--mono); font-size: 12px; }
.editor-head .meta { color: var(--ink-faint); font-size: 11px; margin-left: auto; font-family: var(--mono); }
.monaco-host { flex: 1; min-height: 0; }

/* horizontal divider between editor and console */
.divider { background: var(--line); cursor: row-resize; }
.divider:hover { background: var(--accent); }

/* console — dark, docked */
.console-panel { display: flex; flex-direction: column; min-height: 0; background: var(--term-bg); }
.console-head {
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 14px; flex: none;
  color: var(--term-faint); font-family: var(--mono); font-size: 11.5px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.console-head .title { color: var(--term-fg); letter-spacing: .03em; }
.console-head .build { color: var(--term-faint); }
.console-head .build .arrow { color: var(--term-prompt); }
.console-head .build .ok { color: var(--term-ok); }
.console-head .build .err { color: var(--term-err); }
.console-head .clear { margin-left: auto; border: none; background: transparent; color: var(--term-faint); cursor: pointer; font-size: 11px; padding: 2px 7px; border-radius: 4px; font-family: var(--mono); }
.console-head .clear:hover { background: rgba(255,255,255,.07); color: var(--term-fg); }
.console-out { flex: 1; overflow: auto; padding: 10px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--term-fg); }
.console-out .placeholder { color: var(--term-faint); }
.console-out kbd { font-family: var(--mono); font-size: 11px; background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 4px; }
.console-out pre { margin: 0; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--term-fg); white-space: pre-wrap; word-break: break-word; }
.console-out pre.dim { color: var(--term-faint); }
.console-out pre.err { color: var(--term-err); }
.console-out .caret { display: inline-block; width: 7px; height: 14px; background: var(--accent); vertical-align: -2px; margin-left: 1px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* compile-error block inside the console */
.err-list { margin: 0; }
.err-list .label { color: var(--term-err); font-weight: 600; display: block; margin-bottom: 4px; }
.err-list .efile { color: var(--term-ok); cursor: pointer; }
.err-list .efile:hover { text-decoration: underline; }

/* ── status bar ──────────────────────────────────────────────────────── */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 24px; padding: 0 14px; background: var(--paper);
  border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-faint);
  font-family: var(--mono);
}
.statusbar .right { display: flex; align-items: center; gap: 14px; }
.statusbar a { color: var(--ink-soft); text-decoration: none; }
.statusbar a:hover { color: var(--accent); }

/* ── modal ───────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(27,25,22,.4); display: none; place-items: center; z-index: 100; }
.modal-back.show { display: grid; }
.modal { width: 340px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px; padding: 18px; box-shadow: 0 18px 50px -20px rgba(40,28,12,.5); }
.modal h3 { margin: 0 0 4px; font-size: 14px; }
.modal p { margin: 0 0 12px; font-size: 12px; color: var(--ink-soft); }
.modal p code { font-family: var(--mono); color: var(--accent); }
.modal input { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font-family: var(--mono); font-size: 13px; }
.modal input:focus { outline: none; border-color: var(--accent); }
.modal .err-msg { color: var(--accent); font-size: 11px; min-height: 14px; margin-top: 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
