/* ═══════════════════════════════════════════════════════
   MATHVERSE CODE ARENA — style.css
   Breakpoints:
     Mobile  : < 640px
     Tablet  : 640px – 1023px
     Desktop : ≥ 1024px
════════════════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --bg:        #07070f;
  --s1:        #0d0d1a;
  --s2:        #121220;
  --s3:        #1a1a2e;
  --s4:        #22223a;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.13);
  --accent:    #6c63ff;
  --accent2:   #a78bfa;
  --accent-g:  linear-gradient(135deg, #6c63ff 0%, #a78bfa 100%);
  --gold:      #f0b429;
  --green:     #22d3a0;
  --red:       #f25c7a;
  --text:      #e2e2f0;
  --sub:       #9090b0;
  --dim:       #484868;
  --mono:      'JetBrains Mono', monospace;
  --ui:        'Outfit', sans-serif;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 14px;
  --sp-lg: 20px;
  --sp-xl: 28px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── SCROLLBARS ──────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--s4); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ═══════════════════════════════════════════════════════
   HEADER
════════════════════════════════════════════════════════ */
.header {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--sp-lg);
  gap: var(--sp-md);
  background: var(--s1);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(108,99,255,.12);
  position: relative;
  z-index: 20;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-shrink: 0;
  text-decoration: none;
  transition: opacity .2s;
}
.logo:hover { opacity: .8; }

.logo-icon {
  width: 30px; height: 30px;
  background: var(--accent-g);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(108,99,255,.4);
}
.logo-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}
.logo-text span { color: var(--accent2); }

/* Center chip */
.header-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.problem-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  background: var(--s3);
  border: 1px solid var(--border2);
  padding: 5px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  transition: border-color .2s;
}
.problem-chip:hover { border-color: rgba(108,99,255,.3); }
.problem-chip #hdr-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.chip-easy   { background: rgba(34,211,160,.18);  color: var(--green); }
.chip-medium { background: rgba(240,180,41,.18);  color: var(--gold); }
.chip-hard   { background: rgba(242,92,122,.18);  color: var(--red); }

/* Right controls */
.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-shrink: 0;
}
.lang-pill {
  background: var(--s3);
  border: 1px solid var(--border2);
  color: var(--sub);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
  outline: none;
  transition: border-color .2s, color .2s;
  appearance: none;
  -webkit-appearance: none;
}
.lang-pill:focus,
.lang-pill:hover { border-color: var(--accent); color: var(--text); }
.lang-pill option { background: var(--s2); }

.run-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-g);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 8px 17px;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.2px;
  white-space: nowrap;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 2px 12px rgba(108,99,255,.35);
  animation: runPulse 3s ease-in-out infinite;
}
@keyframes runPulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(108,99,255,.3); }
  50%       { box-shadow: 0 2px 22px rgba(108,99,255,.6); }
}
.run-btn:hover  { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 22px rgba(108,99,255,.5); animation: none; }
.run-btn:active { transform: translateY(0); }
.run-btn .play-icon { width: 13px; height: 13px; fill: #fff; flex-shrink: 0; }
.running { animation: none; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
  flex-shrink: 0;
}
.running .spinner    { display: block; }
.running .play-icon  { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════
   MOBILE NAV TABS
════════════════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  height: 50px;
  flex-shrink: 0;
  background: rgba(13,13,26,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  align-items: stretch;
}
.mnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.mnav-btn:active { background: rgba(108,99,255,.06); }
.mnav-btn svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s;
}
.mnav-btn.active {
  color: var(--accent2);
  border-bottom-color: var(--accent2);
}
.mnav-btn.active svg { transform: scale(1.1); }

/* ═══════════════════════════════════════════════════════
   WORKSPACE
════════════════════════════════════════════════════════ */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr 310px;
  grid-template-rows: 1fr;
  overflow: hidden;
  min-height: 0;
}

/* ── SHARED PANEL BASE ───────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── PANEL TOP BAR ───────────────────────────────────── */
.panel-top,
.right-header {
  padding: 11px 16px 9px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--s2) 0%, var(--s1) 100%);
}
.panel-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--dim);
}
.problem-count {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
}
.results-meta {
  font-size: 11px;
  color: var(--accent2);
  font-family: var(--mono);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════
   LEFT PANEL — PROBLEMS
════════════════════════════════════════════════════════ */
.left-panel {
  background: var(--s1);
  border-right: 1px solid var(--border);
  position: relative;
}

.problem-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.p-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .16s, border-color .16s, transform .1s;
  position: relative;
  overflow: hidden;
}
/* Left accent bar */
.p-item::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-g);
  opacity: 0;
  transition: opacity .2s, top .2s, bottom .2s;
}
.p-item:hover  { background: var(--s3); border-color: var(--border2); }
.p-item:hover::before { opacity: .4; top: 20%; bottom: 20%; }
.p-item:active { transform: scale(.99); }
.p-item.active {
  background: rgba(108,99,255,.1);
  border-color: rgba(108,99,255,.3);
}
.p-item.active::before { opacity: 1; top: 0; bottom: 0; }

.p-num {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--s4);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  color: var(--dim);
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.p-item.active .p-num { background: rgba(108,99,255,.35); color: var(--accent2); }

.p-name {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  line-height: 1.3;
  transition: color .2s;
}
.p-item.active .p-name { color: var(--accent2); }

.p-diff {
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.diff-easy   { background: rgba(34,211,160,.15);  color: var(--green); }
.diff-medium { background: rgba(240,180,41,.15);  color: var(--gold); }
.diff-hard   { background: rgba(242,92,122,.15);  color: var(--red); }

/* Problem detail — animates in */
.problem-detail {
  position: absolute;
  inset: 0;
  background: var(--s1);
  display: none;
  flex-direction: column;
  padding: var(--sp-lg);
  overflow-y: auto;
  z-index: 5;
}
.problem-detail.show {
  display: flex;
  animation: slideInDetail .2s ease both;
}
@keyframes slideInDetail {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--s3);
  border: 1px solid var(--border2);
  color: var(--sub);
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: var(--sp-md);
  padding: 6px 12px 6px 8px;
  border-radius: var(--r-pill);
  transition: color .2s, border-color .2s, background .2s;
  align-self: flex-start;
}
.back-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(108,99,255,.1); }
.back-btn svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}

.pd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}
.pd-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}
.pd-badge {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  margin-top: 3px;
}

.pd-desc {
  font-size: 13.5px;
  line-height: 1.75;
  color: #ababcc;
  margin-bottom: var(--sp-lg);
}

.pd-section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--dim);
  margin-bottom: var(--sp-sm);
}

.example {
  background: var(--s3);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  margin-bottom: 7px;
  transition: border-color .2s;
}
.example:hover { border-color: rgba(108,99,255,.25); }
.example code {
  font-family: var(--mono);
  font-size: 12px;
  color: #c8d3f5;
  display: block;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Go to editor button — mobile only */
.go-editor-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: var(--sp-lg);
  padding: 13px;
  background: var(--accent-g);
  border: none;
  border-radius: var(--r-md);
  color: #fff;
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
  box-shadow: 0 4px 16px rgba(108,99,255,.35);
}
.go-editor-btn:hover  { opacity: .88; }
.go-editor-btn:active { transform: scale(.98); }
.go-editor-btn svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════
   CENTER PANEL — EDITOR
════════════════════════════════════════════════════════ */
.editor-panel {
  background: #06060e;
}

.editor-bar {
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--s2);
  border-bottom: 1px solid var(--border);
}

.editor-dots { display: flex; gap: 7px; align-items: center; }
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  transition: filter .2s;
}
.editor-bar:hover .dot { filter: brightness(1.25); }
.dot-r { background: #ff5f57; box-shadow: 0 0 5px rgba(255,95,87,.4); }
.dot-y { background: #febc2e; box-shadow: 0 0 5px rgba(254,188,46,.4); }
.dot-g { background: #28c840; box-shadow: 0 0 5px rgba(40,200,64,.4); }

.editor-filename {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--sub);
  font-weight: 500;
}

.editor-shortcut {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--dim);
  background: var(--s3);
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.editor-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.line-nums {
  width: 46px;
  flex-shrink: 0;
  padding: 18px 0;
  background: #06060e;
  border-right: 1px solid var(--border);
  overflow: hidden;
  text-align: right;
  user-select: none;
}
.line-num {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--dim);
  padding-right: 10px;
  height: 22.1px;
}

#code-editor {
  flex: 1;
  background: #06060e;
  color: #cdd6f4;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  border: none;
  outline: none;
  resize: none;
  padding: 18px 20px 18px 12px;
  tab-size: 4;
  caret-color: var(--accent2);
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre;
}
#code-editor::selection { background: rgba(108,99,255,.28); }

/* ═══════════════════════════════════════════════════════
   RIGHT PANEL — RESULTS
════════════════════════════════════════════════════════ */
.right-panel {
  background: var(--s1);
  border-left: 1px solid var(--border);
}

.results-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Idle state */
.idle-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 20px;
  text-align: center;
}
.idle-icon {
  width: 62px; height: 62px;
  border-radius: var(--r-lg);
  background: radial-gradient(circle, rgba(108,99,255,.15) 0%, var(--s3) 100%);
  border: 1px solid rgba(108,99,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  color: var(--accent2);
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 20px rgba(108,99,255,.1); }
  50%       { box-shadow: 0 0 36px rgba(108,99,255,.3); }
}
.idle-text {
  font-size: 13px;
  color: var(--sub);
  line-height: 1.7;
}
.idle-hint {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
  background: var(--s3);
  padding: 5px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

/* Score cards */
.score-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.score-card {
  border-radius: var(--r-md);
  border: 1px solid var(--border2);
  padding: 13px 8px;
  text-align: center;
  background: var(--s2);
  transition: transform .2s;
}
.score-card:hover { transform: translateY(-2px); }
.score-card .num {
  font-size: 26px;
  font-weight: 800;
  display: block;
  line-height: 1;
  margin-bottom: 5px;
}
.score-card .lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
}
.sc-pass { border-color: rgba(34,211,160,.22); box-shadow: inset 0 1px 0 rgba(34,211,160,.08); }
.sc-pass .num { color: var(--green); text-shadow: 0 0 16px rgba(34,211,160,.4); }
.sc-fail { border-color: rgba(242,92,122,.22); box-shadow: inset 0 1px 0 rgba(242,92,122,.08); }
.sc-fail .num { color: var(--red);   text-shadow: 0 0 16px rgba(242,92,122,.4); }
.sc-pct  { border-color: rgba(108,99,255,.22); box-shadow: inset 0 1px 0 rgba(108,99,255,.08); }
.sc-pct  .num { color: var(--accent2); text-shadow: 0 0 16px rgba(108,99,255,.4); }

/* Progress bar */
.progress-wrap {
  background: var(--s3);
  border-radius: var(--r-pill);
  height: 5px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--accent-g);
  transition: width .6s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 8px rgba(108,99,255,.5);
}

/* Result items */
.r-item {
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: slideUp .22s ease both;
  transition: border-color .2s;
}
.r-item.r-pass { border-color: rgba(34,211,160,.2); }
.r-item.r-fail { border-color: rgba(242,92,122,.2); }
.r-item.r-pass:hover { border-color: rgba(34,211,160,.4); }
.r-item.r-fail:hover { border-color: rgba(242,92,122,.4); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.r-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  transition: filter .15s;
  user-select: none;
}
.r-item.r-pass .r-head { background: rgba(34,211,160,.05); }
.r-item.r-fail .r-head { background: rgba(242,92,122,.05); }
.r-head:hover { filter: brightness(1.18); }

.r-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.r-pass .r-dot { background: var(--green); box-shadow: 0 0 6px rgba(34,211,160,.5); }
.r-fail .r-dot { background: var(--red);   box-shadow: 0 0 6px rgba(242,92,122,.5); }

.r-name { font-size: 13px; font-weight: 600; flex: 1; }

.r-tag {
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.r-pass .r-tag { background: rgba(34,211,160,.15); color: var(--green); }
.r-fail .r-tag { background: rgba(242,92,122,.15); color: var(--red); }

.r-chevron {
  font-size: 10px;
  color: var(--dim);
  transition: transform .2s;
  flex-shrink: 0;
}
.r-head.open .r-chevron { transform: rotate(180deg); }

.r-body {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 11px 13px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.25);
}
.r-body.open { display: flex; }

.r-row { display: flex; gap: 10px; align-items: flex-start; }
.r-key {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--dim);
  width: 62px;
  flex-shrink: 0;
  padding-top: 2px;
}
.r-val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #c8d3f5;
  line-height: 1.55;
  word-break: break-all;
}
.r-val.ok  { color: var(--green); }
.r-val.bad { color: var(--red); }

/* ═══════════════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════════════════ */
.footer {
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  padding: 0 var(--sp-lg);
  background: var(--s1);
  border-top: 1px solid var(--border);
}
.foot-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
  white-space: nowrap;
}
.foot-right { margin-left: auto; }
.foot-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(34,211,160,.6);
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ═══════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--s3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════
   ANIMATIONS
════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease both; }


/* ═══════════════════════════════════════════════════════
   TABLET  640px – 1023px
════════════════════════════════════════════════════════ */
@media (min-width: 640px) and (max-width: 1023px) {
  .workspace {
    grid-template-columns: 240px 1fr;
    /* Editor 65%, Results 35% — much better than 50/50 */
    grid-template-rows: 65fr 35fr;
  }
  .left-panel  { grid-row: 1 / 3; border-right: 1px solid var(--border); }
  .editor-panel { grid-column: 2; grid-row: 1; border-bottom: 1px solid var(--border); }
  .right-panel  { grid-column: 2; grid-row: 2; border-left: none; border-top: 1px solid var(--border); }

  #code-editor { font-size: 12.5px; }
  .editor-shortcut { display: none; }
  .footer { gap: 14px; }
  .foot-right { display: none; }
}


/* ═══════════════════════════════════════════════════════
   MOBILE  < 640px
════════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  .header { height: 48px; padding: 0 14px; gap: 8px; }
  .logo-text { font-size: 15px; }
  .logo-icon { width: 27px; height: 27px; font-size: 13px; }

  .header-mid { display: none; }
  .lang-pill  { display: none; }
  .run-btn    { padding: 7px 14px; font-size: 12px; }
  .run-label  { display: none; }

  .mobile-nav { display: flex; }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
  }
  .panel {
    position: absolute;
    inset: 0;
    display: none;
    border: none !important;
  }
  .panel.mobile-active { display: flex; }

  .p-item       { padding: 14px 12px; }
  .p-name       { font-size: 14px; }
  .go-editor-btn { display: flex; }
  #code-editor  { font-size: 13px; }
  .pd-desc      { font-size: 14px; }
  .pd-title     { font-size: 19px; }

  .score-card .num { font-size: 22px; }
  .score-card      { padding: 10px 6px; }

  .footer        { display: none; }
  .line-nums     { width: 38px; }
  .line-num      { padding-right: 8px; font-size: 12px; }
  .idle-icon     { width: 52px; height: 52px; }
  .problem-detail { padding: 16px; }
}


/* ═══════════════════════════════════════════════════════
   LARGE DESKTOP  ≥ 1280px
════════════════════════════════════════════════════════ */
@media (min-width: 1280px) {
  .workspace   { grid-template-columns: 300px 1fr 320px; }
  .header      { padding: 0 28px; }
  #code-editor { font-size: 13.5px; }
}

/* ═══════════════════════════════════════════════════════
   EXTRA LARGE  ≥ 1600px
════════════════════════════════════════════════════════ */
@media (min-width: 1600px) {
  .workspace   { grid-template-columns: 330px 1fr 350px; }
  #code-editor { font-size: 14px; }
  .pd-title    { font-size: 20px; }
  .r-name      { font-size: 14px; }
}

/* ── Reduce motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .run-btn, .idle-icon, .foot-dot { animation: none; }
  .problem-detail.show            { animation: none; }
}

/* ═══════════════════════════════════════════════════════
   FILTER BAR
════════════════════════════════════════════════════════ */
.filter-bar {
  padding: 8px 10px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--s1);
}

.filter-pill {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--ui);
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--sub);
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.filter-pill:hover {
  color: var(--text);
  border-color: rgba(108,99,255,.35);
  background: rgba(108,99,255,.07);
}
.filter-pill.active {
  color: #fff;
  border-color: transparent;
  background: var(--accent-g);
  box-shadow: 0 2px 10px rgba(108,99,255,.3);
}

/* ═══════════════════════════════════════════════════════
   SOLVED PROGRESS BAR
════════════════════════════════════════════════════════ */
.solved-bar {
  height: 2px;
  flex-shrink: 0;
  background: var(--s4);
  overflow: hidden;
}
.solved-fill {
  height: 100%;
  background: var(--accent-g);
  transition: width .5s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 8px rgba(108,99,255,.5);
}

/* ═══════════════════════════════════════════════════════
   SOLVED STATE ON PROBLEM ITEMS
════════════════════════════════════════════════════════ */
.p-item.solved .p-num {
  background: rgba(34,211,160,.18);
  color: var(--green);
}
.p-item.solved .p-num::after {
  content: '✓';
}
.p-item.solved .p-num span { display: none; }

/* ═══════════════════════════════════════════════════════
   CATEGORY LABEL ON PROBLEM ITEMS
════════════════════════════════════════════════════════ */
.p-topic {
  font-size: 9px;
  font-weight: 600;
  color: var(--dim);
  white-space: nowrap;
  flex-shrink: 0;
  display: none; /* shown only on xl screens */
}
@media (min-width: 1400px) {
  .p-topic { display: block; }
}

/* ═══════════════════════════════════════════════════════
   HINT BUTTON & BODY
════════════════════════════════════════════════════════ */
.hint-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: var(--sp-lg);
  padding: 9px 14px;
  background: rgba(240,180,41,.07);
  border: 1px solid rgba(240,180,41,.2);
  border-radius: var(--r-md);
  color: var(--gold);
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background .18s, border-color .18s;
}
.hint-btn:hover {
  background: rgba(240,180,41,.13);
  border-color: rgba(240,180,41,.35);
}
.hint-btn.open {
  background: rgba(240,180,41,.12);
  border-color: rgba(240,180,41,.4);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.hint-btn svg {
  width: 15px; height: 15px;
  fill: currentColor;
  flex-shrink: 0;
}

.hint-body {
  display: none;
  font-size: 12.5px;
  line-height: 1.75;
  color: #c8c87e;
  background: rgba(240,180,41,.06);
  border: 1px solid rgba(240,180,41,.2);
  border-top: none;
  border-bottom-left-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
  padding: 11px 14px;
  animation: fadeIn .18s ease;
}
.hint-body.open { display: block; }