:root {
  --bg: #10151c; --panel: #1a222c; --line: #2c3846; --ink: #e7eef7;
  --muted: #8ea0b5; --accent: #3d9cf0; --ok: #3ecf8e; --danger: #f07178;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans); color: var(--ink);
  background: radial-gradient(900px 420px at 8% -10%, rgba(61,156,240,.2), transparent 55%), var(--bg);
}
.hidden { display: none !important; }
.auth-gate { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 1.5rem; display: flex; flex-direction: column; gap: .7rem;
}
.auth-card h1 { margin: 0; font-size: 1.5rem; }
.sub { margin: 0; color: var(--muted); font-size: .9rem; }
.tabs { display: flex; gap: .4rem; }
.tab {
  flex: 1; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: .45rem; font: inherit; cursor: pointer;
}
.tab.on { color: var(--ink); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--muted); }
input, textarea, select {
  font: inherit; color: var(--ink); background: #0b1016; border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .65rem;
}
.primary, .ghost {
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; padding: .5rem .85rem;
}
.primary { background: var(--accent); border: 0; color: #061018; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.err { color: var(--danger); margin: 0; font-size: .85rem; }
.top {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: rgba(16,21,28,.9);
}
.brand strong { display: block; }
.brand small { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.layout {
  display: grid; grid-template-columns: 200px 1.3fr 1fr; height: calc(100vh - 58px); min-height: 0;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 45vh 1fr; height: auto; }
}
.side {
  border-right: 1px solid var(--line); padding: .75rem; overflow: auto;
  background: rgba(26,34,44,.55);
}
.side.locked { opacity: .55; }
.side h2 {
  margin: .6rem 0 .35rem; font-size: .72rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between;
}
.tiny { border: 0; background: var(--line); color: var(--ink); border-radius: 4px; cursor: pointer; }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.files li {
  padding: .35rem .45rem; border-radius: 6px; cursor: pointer; font-family: var(--mono);
  font-size: .8rem; display: flex; justify-content: space-between; gap: .3rem;
}
.files li.on, .files li:hover { background: rgba(61,156,240,.15); }
.files .x { color: var(--muted); border: 0; background: 0; cursor: pointer; }
.editor-pane {
  min-height: 0; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
#editor { flex: 1; height: auto; width: 100%; min-height: 0; }
.ai-bar {
  position: absolute; z-index: 8; display: flex; gap: 4px;
  background: #1a222c; border: 1px solid #3d9cf0; border-radius: 8px; padding: 4px;
}
.ai-bar-fixed {
  position: relative; top: auto; left: auto; margin: 8px 8px 0;
  flex: 0 0 auto; width: max-content; max-width: calc(100% - 16px); flex-wrap: wrap;
}
.ai-bar button {
  border: 0; background: #2c3846; color: #e7eef7; border-radius: 6px;
  padding: 4px 8px; font: inherit; font-size: .78rem; cursor: pointer;
}
.ai-dock { display: flex; flex-direction: column; gap: .35rem; min-height: 0; flex: 0 0 auto; }
.ai-dock-h { font-size: .75rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.ai-dock #aiOut { max-height: 140px; min-height: 64px; flex: 0 0 auto; }
.io {
  display: flex; flex-direction: column; gap: .55rem; padding: .75rem; min-height: 0;
  border-left: 1px solid var(--line);
  padding-bottom: calc(4.2rem + env(safe-area-inset-bottom, 0px));
}
.term {
  flex: 1; min-height: 160px; display: flex; flex-direction: column;
  background: #0b1016; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.term-out { flex: 1; min-height: 80px; margin: 0; border: 0; border-radius: 0; background: transparent; }
.term-in {
  border: 0; border-top: 1px solid var(--line); background: #101820; color: var(--ink);
  font-family: var(--mono); font-size: .85rem; padding: .55rem .7rem; outline: none;
}
.term-in:disabled { opacity: .45; }
.cpp-foot {
  position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 80; display: flex; gap: 8px; align-items: center;
}
.cpp-foot .ghost {
  border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: .82rem;
  background: rgba(26,34,44,.92);
}
.field { font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: .3rem; }
.out-head { display: flex; justify-content: space-between; align-items: baseline; }
.out-head h2 { margin: 0; font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.meta { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.out, .err {
  margin: 0; flex: 1; overflow: auto; font-family: var(--mono); font-size: .85rem;
  background: #0b1016; border: 1px solid var(--line); border-radius: 8px; padding: .65rem; white-space: pre-wrap;
}
.err { color: var(--danger); flex: 0 0 auto; max-height: 160px; }
dialog {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink);
  padding: 0; max-width: 420px; width: calc(100% - 2rem);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.pay-box { padding: 1.1rem; display: flex; flex-direction: column; gap: .65rem; }
.pay-qr { width: 100%; max-width: 280px; margin: 0 auto; border-radius: 8px; }
.hint { color: var(--muted); font-size: .82rem; margin: 0; }
.row { display: flex; gap: .5rem; justify-content: flex-end; }
