:root {
  --bg: #0f1419;
  --panel: #171d25;
  --panel-2: #1d2530;
  --line: #2b3645;
  --text: #e8eef6;
  --muted: #9aa8b8;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --ok: #34d399;
  --bad: #fb7185;
  --warn: #fbbf24;
  --font: "IBM Plex Sans JP", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(45, 212, 191, 0.16), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(56, 189, 248, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
}

#app, .boot { min-height: 100vh; }
.boot {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.login-card .lead {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: #042f2e;
}

.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover { background: rgba(255,255,255,0.04); }

.btn-google {
  width: 100%;
  background: #fff;
  color: #111;
  margin-bottom: 18px;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0 16px;
}

.divider::before, .divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  font: inherit;
}

.tabs button.active {
  color: var(--text);
  border-color: rgba(45, 212, 191, 0.5);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.25);
}

.field { margin-bottom: 12px; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}
.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c1117;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.msg {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.msg.error { background: rgba(251, 113, 133, 0.12); color: #fecdd3; border: 1px solid rgba(251,113,133,0.35); }
.msg.ok { background: rgba(52, 211, 153, 0.12); color: #a7f3d0; border: 1px solid rgba(52,211,153,0.35); }
.msg.info { background: rgba(56, 189, 248, 0.1); color: #bae6fd; border: 1px solid rgba(56,189,248,0.3); }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(23, 29, 37, 0.95);
  overflow: auto;
  padding: 14px;
}

.track-title {
  margin: 8px 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.lesson-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.lesson-list button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
}

.lesson-list button:hover { background: rgba(255,255,255,0.04); }
.lesson-list button.active {
  background: rgba(45, 212, 191, 0.1);
  border-color: rgba(45, 212, 191, 0.35);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: #475569;
}
.status-dot.completed { background: var(--ok); }
.status-dot.started { background: var(--warn); }

.main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.prompt-panel {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(29, 37, 48, 0.55);
}

.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.prompt-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.hint-toggle {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 500;
}

.prompt-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.hint {
  margin-top: 10px;
  color: #cbd5e1;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.hint:not([hidden]) {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.editor-split {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.editor-split--css {
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
}

.editor-stack {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(120px, 1fr) minmax(160px, 1.2fr);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.editor-stack .pane {
  border-right: none;
  min-height: 0;
  overflow: hidden;
}

.editor-stack .pane + .pane {
  border-top: 1px solid var(--line);
}

.pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--line);
}

.pane:last-child { border-right: none; }

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.pane-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pane-reset {
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
}

.pane-readonly .CodeMirror {
  opacity: 0.92;
}

.editor-host {
  min-height: 0;
  overflow: hidden;
  background: #0b0f14;
}

.editor-host .CodeMirror {
  height: 100%;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

.editor-stack .editor-host {
  overflow: auto;
}

.editor-stack .editor-host .CodeMirror {
  height: 100%;
  min-height: 100%;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.pane-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(15,20,25,0.9);
}

.pane-foot .msg {
  flex: 1;
  margin: 0;
}

@media (max-width: 980px) {
  .workspace,
  .editor-split,
  .editor-split--css {
    grid-template-columns: 1fr;
  }
  .sidebar { max-height: 220px; }
}
