/* ─────────────────────────────────────────────
   Coding Platform · Dark IDE redesign
   ───────────────────────────────────────────── */

:root {
  --bg: #0b1018;
  --bg-rail: #0f1524;
  --panel: #121a2a;
  --panel-2: #161f31;
  --panel-3: #1a2336;
  --line: #24314a;
  --line-2: #2e3c58;
  --text: #e6ebf5;
  --text-2: #b7c0d3;
  --muted: #7a8499;
  --muted-2: #5a667e;

  --accent: oklch(0.78 0.12 215);
  --accent-ink: #061018;
  --amber: oklch(0.82 0.14 75);
  --green: oklch(0.78 0.15 150);
  --red: oklch(0.7 0.18 25);
  --violet: oklch(0.74 0.15 285);

  --s-bg: #0c1220;
  --s-kw: oklch(0.78 0.14 285);
  --s-fn: oklch(0.82 0.13 80);
  --s-str: oklch(0.78 0.13 145);
  --s-num: oklch(0.78 0.14 30);
  --s-com: #5a667e;
  --s-var: #cfd6e4;
  --s-op: #9ca6bd;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: 44px 1fr;
  grid-template-columns: 56px 1fr;
  height: 100vh;
}
.app.fs-medium {
  font-size: 15.5px;
}
.app.fs-large {
  font-size: 17px;
}

/* ─────────── Topbar ─────────── */
.topbar {
  grid-column: 1 / span 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d1321 0%, #0b1018 100%);
  user-select: none;
}
.top-left {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-2);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.top-center {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 500;
}
.top-center .dropdown {
  width: 8px;
  height: 8px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  margin-left: 4px;
  margin-top: -2px;
  color: var(--muted);
}
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  color: var(--text-2);
}
.timer {
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
}
.user-chip .avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    #fff,
    var(--accent) 45%,
    var(--violet)
  );
}
.export-btn {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
}
.export-btn:hover {
  color: var(--text);
  border-color: var(--text-2);
}

/* ─────────── Rail ─────────── */
.rail {
  grid-row: 2;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  gap: 2px;
  position: relative;
}
.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 9px;
  cursor: pointer;
  color: var(--muted);
  border-left: 2px solid transparent;
  transition: color 0.12s;
}
.rail-btn:hover {
  color: var(--text-2);
}
.rail-btn.rail-static {
  cursor: default;
  color: var(--text-2);
}
.rail-btn.rail-static:hover {
  color: var(--text-2);
}
.rail-btn.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: linear-gradient(
    90deg,
    color-mix(in oklch, var(--accent) 10%, transparent),
    transparent
  );
}
.rail-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rail-btn .lbl {
  font-size: 9px;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.rail-ai {
  color: var(--text);
}
.rail-ai .rail-orb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    #fff 0%,
    color-mix(in oklch, var(--accent) 70%, #fff) 30%,
    color-mix(in oklch, var(--violet) 90%, #000) 100%
  );
  box-shadow:
    inset 0 0 6px color-mix(in oklch, var(--violet) 60%, transparent),
    0 0 10px color-mix(in oklch, var(--accent) 50%, transparent);
  transition: transform 0.15s;
}
.rail-ai:hover .rail-orb {
  transform: scale(1.08);
}

/* Problem progress list in rail */
.rail-probs-label {
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  text-align: center;
  font-weight: 700;
  padding: 10px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.rail-probs {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scrollbar-width: thin;
}
.rail-probs::-webkit-scrollbar {
  width: 3px;
}
.rail-probs::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 2px;
}

.p-node {
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  position: relative;
}
.p-node .num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 8px;
  color: var(--muted-2);
}
.p-node svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.p-node.solved {
  background: color-mix(in oklch, var(--green) 16%, var(--panel));
  border-color: color-mix(in oklch, var(--green) 45%, var(--line));
  color: var(--green);
}
.p-node.current {
  background: color-mix(in oklch, var(--accent) 16%, var(--panel));
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--accent) 55%, transparent);
}
.p-node.locked {
  opacity: 0.55;
}
.p-node .num-big {
  font-size: 11px;
  color: var(--text-2);
}
.p-node.current .num-big {
  color: var(--accent);
}
.p-node.solved .num-big {
  display: none;
}

/* ─────────── Workspace ─────────── */
.workspace {
  grid-row: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  position: relative;
}

/* ── Left panel: problem ── */
.panel-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.panel-header {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  flex-shrink: 0;
}
.problem-scroll {
  overflow-y: auto;
  padding: 22px 28px 60px 28px;
  flex: 1;
}
.problem-scroll::-webkit-scrollbar {
  width: 10px;
}
.problem-scroll::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 6px;
}

.p-title {
  font-size: 1.43em;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.p-setup {
  font-size: 0.93em;
  color: var(--text-2);
  margin-bottom: 20px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent);
}
.p-setup strong {
  color: var(--text);
  font-weight: 600;
}
.p-desc {
  font-size: 1em;
  color: var(--text-2);
  line-height: 1.7;
}
.p-desc p {
  margin: 0 0 14px;
}
.p-desc code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--amber);
}
/* ── Markdown 확장 스타일 ── */
.p-desc pre {
  background: var(--s-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
  line-height: 1.6;
}
.p-desc pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
}
.p-desc h1,
.p-desc h2,
.p-desc h3,
.p-desc h4 {
  color: var(--text);
  font-weight: 600;
  margin: 16px 0 8px;
  line-height: 1.3;
}
.p-desc h1 {
  font-size: 17px;
}
.p-desc h2 {
  font-size: 15px;
}
.p-desc h3 {
  font-size: 14px;
}
.p-desc h4 {
  font-size: 13px;
  color: var(--text-2);
}
.p-desc ul,
.p-desc ol {
  padding-left: 20px;
  margin: 0 0 14px;
}
.p-desc li {
  margin: 3px 0;
}
.p-desc blockquote {
  border-left: 3px solid var(--accent);
  background: var(--panel);
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text-2);
}
.p-desc blockquote p {
  margin: 0;
}
.p-desc strong {
  color: var(--text);
  font-weight: 600;
}
.p-desc em {
  color: var(--text-2);
}
.p-desc hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}
.p-desc table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.p-desc th,
.p-desc td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.p-desc th {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
}

.p-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px 0;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.p-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin: 22px 0 10px;
}
.ex-tabbed {
  margin-bottom: 10px;
}
.ex-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}
.ex-tab {
  padding: 4px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: "Inter", sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}
.ex-tab:hover {
  background: var(--panel-2);
  color: var(--text-2);
}
.ex-tab.active {
  background: var(--panel-2);
  border-color: var(--accent);
  color: var(--text);
}
.ex-panel {
  display: none;
}
.ex-panel.active {
  display: block;
}
.example {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.89em;
  color: var(--text-2);
}
.example .ex-label {
  font-family: "Inter", sans-serif;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 6px;
}
.example .ex-row {
  display: flex;
  gap: 10px;
  padding: 2px 0;
}
.example .ex-k {
  color: var(--muted);
  min-width: 64px;
}
.example .ex-v {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.example .ex-explanation {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.example .ex-explanation-body {
  margin-top: 4px;
  font-family: "Inter", sans-serif;
  font-size: 0.93em;
  color: var(--text-2);
  line-height: 1.6;
}
.example .ex-explanation-body p {
  margin: 0 0 6px;
}
.example .ex-explanation-body p:last-child {
  margin-bottom: 0;
}
.example .ex-explanation-body code {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}
.example .ex-explanation-body pre {
  background: var(--panel-2);
  border-left: 2px solid var(--accent);
  padding: 8px 12px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
}
.example .ex-explanation-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
.example .ex-explanation-body strong {
  color: var(--text);
  font-weight: 600;
}
.example .ex-explanation-body em {
  font-style: italic;
}
.example .ex-explanation-body ul,
.example .ex-explanation-body ol {
  padding-left: 18px;
  margin: 4px 0;
}
.example .ex-explanation-body li {
  margin: 2px 0;
}
.example .ex-explanation .p-image {
  margin: 8px 0;
}

/* ── Right panel: editor + terminal ── */
.panel-right {
  display: grid;
  grid-template-rows: 1fr 6px 260px 44px;
  overflow: hidden;
  background: var(--bg);
  min-height: 0;
  border-left: 1px solid var(--line);
  position: relative;
}

.editor-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.editor-tabs {
  height: 34px;
  display: flex;
  align-items: flex-end;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.editor-tab {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--s-bg);
  border-right: 1px solid var(--line);
  font-size: 12.5px;
  font-family: "JetBrains Mono", monospace;
  color: var(--text);
  position: relative;
}
.editor-tab::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}
.editor-tab .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px color-mix(in oklch, var(--amber) 60%, transparent);
}
.editor-tabs-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12px;
}
.lang-chip {
  font-family: "JetBrains Mono", monospace;
  color: var(--text-2);
}
.icon-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}
.icon-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.editor {
  flex: 1;
  overflow: hidden;
  display: flex;
  background: var(--s-bg);
  position: relative;
  min-height: 0;
}
.gutter {
  width: 48px;
  padding: 10px 10px 10px 0;
  text-align: right;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--muted-2);
  user-select: none;
  line-height: 1.55;
  flex-shrink: 0;
  overflow: hidden;
}

.code-area {
  flex: 1;
  overflow: auto;
  position: relative;
  min-height: 0;
}
.code-area::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.code-area::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 6px;
}

.code-highlight,
.code-input {
  margin: 0;
  padding: 10px 12px 20px 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  border: none;
  width: 100%;
  min-width: 100%;
  tab-size: 4;
}
.code-highlight {
  position: absolute;
  inset: 0;
  color: var(--s-var);
  pointer-events: none;
  overflow: hidden;
}
.code-input {
  position: relative;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  resize: none;
  outline: none;
  z-index: 2;
  overflow: auto;
  height: 100%;
}
.code-input::selection {
  background: color-mix(in oklch, var(--accent) 30%, transparent);
}

/* minimap (decorative) */
.minimap {
  position: absolute;
  top: 10px;
  right: 0;
  width: 76px;
  bottom: 10px;
  opacity: 0.35;
  pointer-events: none;
  overflow: hidden;
  mask-image: linear-gradient(
    to bottom,
    transparent,
    #000 8%,
    #000 92%,
    transparent
  );
}
.mini-line {
  height: 3px;
  margin: 1px 6px;
  border-radius: 1px;
  background: var(--line-2);
}
.mini-line.kw {
  background: var(--s-kw);
}
.mini-line.fn {
  background: var(--s-fn);
}
.mini-line.str {
  background: var(--s-str);
}
.mini-line.com {
  background: var(--s-com);
}
.minimap .viewport {
  position: absolute;
  left: 0;
  right: 0;
  top: 20%;
  height: 32%;
  background: color-mix(in oklch, var(--text) 8%, transparent);
  border: 1px solid color-mix(in oklch, var(--text) 12%, transparent);
}

.kw {
  color: var(--s-kw);
}
.fn {
  color: var(--s-fn);
}
.str {
  color: var(--s-str);
}
.num-tok {
  color: var(--s-num);
}
.com {
  color: var(--s-com);
  font-style: italic;
}
/* v-divider */
.vdivider {
  background: var(--bg);
  cursor: row-resize;
  position: relative;
  user-select: none;
}
.vdivider:hover::after {
  background: var(--accent);
}
.vdivider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 1px;
  background: var(--line);
}
.vdivider::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-2);
}

/* terminal */
.terminal {
  display: flex;
  flex-direction: column;
  background: var(--s-bg);
  overflow: hidden;
  min-height: 0;
}
.term-tabs {
  height: 34px;
  display: flex;
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding-right: 10px;
  flex-shrink: 0;
}
.term-tab {
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  cursor: pointer;
  position: relative;
}
.term-tab.active {
  color: var(--text);
}
.term-tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}
.term-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.term-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.term-hint svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.btn-run {
  height: 24px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.btn-run svg {
  width: 10px;
  height: 10px;
}
.btn-run:hover {
  filter: brightness(1.08);
}
.btn-run:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.term-body {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.term-body::-webkit-scrollbar {
  width: 8px;
}
.term-body::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 4px;
}
.prompt {
  color: var(--accent);
}
.term-ok {
  color: var(--green);
}
.term-err {
  color: var(--red);
}
.term-muted {
  color: var(--muted);
}
.term-cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--text);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
  margin-left: 2px;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* Actions row */
.actions-row {
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}
.actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  height: 30px;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.btn:hover {
  color: var(--text);
  border-color: var(--text-2);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--green);
  color: #06180d;
  border-color: transparent;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.accent:disabled {
  filter: grayscale(0.4);
}
.btn.ghost {
  color: var(--muted);
  border-color: transparent;
}
.btn.ghost:hover {
  color: var(--text);
  background: var(--panel-2);
}

/* ─────────── Login overlay ─────────── */
#loginOverlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 999;
  background-image:
    radial-gradient(
      600px circle at 20% 30%,
      color-mix(in oklch, var(--accent) 10%, transparent),
      transparent 60%
    ),
    radial-gradient(
      800px circle at 80% 70%,
      color-mix(in oklch, var(--violet) 10%, transparent),
      transparent 60%
    );
}
.login-card {
  width: 380px;
  padding: 28px 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}
.login-card h2 {
  margin: 6px 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.login-card p {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.login-card p.small {
  font-size: 11.5px;
  margin-top: 12px;
  color: var(--muted);
}
.login-card label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  height: 38px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--text);
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-card button {
  width: 100%;
  height: 40px;
  margin-top: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover {
  filter: brightness(1.08);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}
.login-brand .orb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    #fff,
    var(--accent) 40%,
    var(--violet)
  );
  box-shadow: 0 0 10px color-mix(in oklch, var(--accent) 40%, transparent);
}
.login-err {
  color: var(--red);
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}

/* ─────────── AI Drawer ─────────── */
.ai-drawer {
  position: fixed;
  top: 44px;
  left: calc(50% - 8px); /* 패널 경계(50%+28px)에서 handle(36px)만큼 왼쪽 */
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  transform: translateX(calc(100% - 36px));
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 40;
  pointer-events: none; /* 기본 투명 — 실제 UI 요소에서만 개별 활성화 */
}
.ai-drawer.open {
  transform: translateX(0);
}

.ai-handle {
  width: 36px;
  flex-shrink: 0;
  position: relative;
  pointer-events: none; /* 탭 영역 외 클릭 통과 */
}
.ai-handle-tab {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-right: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  transition: background 0.12s;
}
.ai-handle-tab:hover {
  background: var(--panel-3);
}
.ai-handle-orb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    #fff 0%,
    color-mix(in oklch, var(--accent) 70%, #fff) 40%,
    var(--violet) 100%
  );
  box-shadow: 0 0 8px color-mix(in oklch, var(--accent) 45%, transparent);
  flex-shrink: 0;
}
.ai-handle-lbl {
  writing-mode: vertical-rl;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-2);
}
.ai-handle-chev {
  width: 14px;
  height: 14px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-drawer.open .ai-handle-chev {
  transform: rotate(180deg);
}

.ai-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line-2);
  overflow: hidden;
  box-shadow: -6px 0 28px rgba(0, 0, 0, 0.5);
  pointer-events: auto; /* 콘텐츠 영역은 클릭 활성화 */
}

.ai-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  user-select: none;
  flex-shrink: 0;
}
.ai-head .orb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    #fff,
    var(--accent) 40%,
    var(--violet)
  );
}
.ai-head .title {
  font-weight: 700;
  font-size: 13px;
}
.ai-head .subtitle {
  font-size: 11px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
}
.ai-close {
  margin-left: auto;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.ai-close:hover {
  color: var(--text);
}

.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg {
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
  max-width: 90%;
  word-wrap: break-word;
}
.ai-msg.bot {
  background: var(--panel-3);
  border: 1px solid var(--line);
  color: var(--text-2);
}
.ai-msg.user {
  background: color-mix(in oklch, var(--accent) 18%, var(--panel));
  border: 1px solid color-mix(in oklch, var(--accent) 30%, var(--line));
  color: var(--text);
  align-self: flex-end;
}
.ai-msg code {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  background: var(--s-bg);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--amber);
}
.ai-msg .code-wrap {
  position: relative;
  margin: 6px 0;
}
.ai-msg .code-wrap:hover .copy-btn {
  opacity: 1;
}
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.12s,
    color 0.12s;
}
.copy-btn:hover {
  color: var(--text);
}
.ai-msg pre {
  background: var(--s-bg);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  margin: 0;
  overflow-x: auto;
}

.ai-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.ai-input {
  flex: 1;
  min-height: 32px;
  max-height: 160px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
}
.ai-input:focus {
  border-color: var(--accent);
}
.ai-send {
  height: 32px;
  width: 32px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.ai-send svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ─────────── Tweaks panel ─────────── */
.tweaks {
  position: fixed;
  left: 66px;
  top: 120px;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  z-index: 50;
  display: none;
  box-shadow: 0 20px 48px -16px rgba(0, 0, 0, 0.8);
}
.tweaks.open {
  display: block;
}

/* Toast (Ctrl+S 저장 알림 등) */
.app-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--panel);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--r-md);
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.18s ease;
  z-index: 200;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tweaks h4 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}
.tw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}
.tw-seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.tw-seg button {
  padding: 4px 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}
.tw-seg button.active {
  background: var(--panel-3);
  color: var(--text);
}

/* Density */
.app.compact .problem-scroll {
  padding: 14px 22px 50px;
}
.app.compact .p-title {
  font-size: 17px;
}
.app.compact .code-highlight,
.app.compact .code-input {
  font-size: 12px;
}
.app.compact .p-setup {
  font-size: 12.5px;
  padding: 8px 10px;
}

/* ─────────── Font size ─────────── */
/* small = default (no overrides needed) */

.app.fs-medium .code-input,
.app.fs-medium .code-highlight,
.app.fs-medium .gutter {
  font-size: 14px;
}
.app.fs-medium .p-desc,
.app.fs-medium .p-setup,
.app.fs-medium .example {
  font-size: 15.5px;
}
.app.fs-medium .ai-msg,
.app.fs-medium .ai-input {
  font-size: 15px;
}

.app.fs-large .code-input,
.app.fs-large .code-highlight,
.app.fs-large .gutter {
  font-size: 16px;
}
.app.fs-large .p-desc,
.app.fs-large .p-setup,
.app.fs-large .example {
  font-size: 17px;
}
.app.fs-large .ai-msg,
.app.fs-large .ai-input {
  font-size: 16px;
}

/* ── Explain mode overlay ── */
.explain-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(11, 16, 24, 0.93);
  backdrop-filter: blur(8px);
  flex-direction: column;
  padding: 24px 28px;
  gap: 16px;
}
.explain-overlay.active {
  display: flex;
}
.explain-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.explain-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}
.explain-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}
.explain-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.explain-bubble.user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.explain-bubble.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text-2);
}
.explain-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  position: relative;
}
.explain-resize {
  position: absolute;
  top: -10px;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: ns-resize;
  z-index: 5;
  opacity: 0.5;
  background-image: linear-gradient(
    -45deg,
    transparent 0 3px,
    var(--muted) 3px 4px,
    transparent 4px 7px,
    var(--muted) 7px 8px,
    transparent 8px 11px,
    var(--muted) 11px 12px,
    transparent 12px
  );
  touch-action: none;
}
.explain-resize:hover {
  opacity: 1;
}
.explain-input {
  flex: 1;
  min-height: 160px;
  max-height: 500px;
  resize: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}
.explain-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Explain attempt counter ── */
.explain-attempt {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* ── Rubric feedback block ── */
.rubric-feedback {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  width: 100%;
}

.rubric-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.rubric-item.correct {
  border-color: oklch(0.65 0.15 150 / 0.5);
  background: oklch(0.65 0.15 150 / 0.08);
}

.rubric-item.warning {
  border-color: oklch(0.82 0.14 75 / 0.5);
  background: oklch(0.82 0.14 75 / 0.08);
}

.rubric-item.missing {
  border-color: oklch(0.65 0.2 25 / 0.4);
  background: oklch(0.65 0.2 25 / 0.06);
}

.rubric-item-icon {
  flex-shrink: 0;
  font-size: 14px;
  margin-top: 1px;
}

.rubric-item-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rubric-item-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

.rubric-item-feedback {
  color: var(--text);
  font-size: 13px;
}

/* ── Shallow detection warning ── */
.shallow-warning {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid oklch(0.82 0.14 75 / 0.4);
  background: oklch(0.82 0.14 75 / 0.07);
  color: var(--text);
}

/* ── Unlock success message ── */
.explain-unlock-msg {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: oklch(0.65 0.15 150 / 0.12);
  border: 1px solid oklch(0.65 0.15 150 / 0.5);
  text-align: center;
  margin-top: 4px;
}

.explain-unlock-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
}

/* ─────────────────────────────────────────────
   Creative problem types — write card
   ───────────────────────────────────────────── */

/* 가이드 섹션: 문제 지문 위에 compact하게 */
.creative-guide {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.creative-guide p {
  margin: 0 0 8px;
}

/* 작성 카드 컨테이너 */
.write-card {
  margin-top: 16px;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
}
.write-card--saved {
  border-color: oklch(0.45 0.14 150 / 0.7);
  background: oklch(0.13 0.03 150 / 0.25);
}

/* 카드 헤더 */
.write-card__header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.write-card--saved .write-card__header {
  background: oklch(0.15 0.05 150 / 0.2);
  border-bottom-color: oklch(0.35 0.1 150 / 0.4);
}
.write-card__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.write-card__icon--ok {
  stroke: oklch(0.72 0.18 150);
}
.write-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
}
.write-card--saved .write-card__title {
  color: oklch(0.72 0.18 150);
}
.write-card__hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* 텍스트 작성 영역 */
.write-card__textarea {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.75;
  resize: vertical;
  box-sizing: border-box;
  display: block;
  tab-size: 2;
}
.write-card__textarea::placeholder {
  color: var(--muted-2);
  line-height: 1.75;
}
.write-card__textarea:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.015);
}
.write-card__textarea[readonly] {
  color: var(--text-2);
  cursor: default;
  border-bottom: none;
  min-height: 200px;
}

/* 카드 푸터 */
.write-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.15);
  gap: 12px;
}
.write-card__charcount {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.write-card__save-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.write-card__save-btn svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* 에디터 잠금 상태 */
.editor-locked {
  opacity: 0.38;
  pointer-events: none;
  user-select: none;
}
