/* ═══════════════════════════════════════════════════════════════════
   DDA Contest — Practice Arena  |  start.css
   Theme: Dark / Deep-navy — consistent with DDA platform palette
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────── */
:root {
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Mono', monospace;
  --font-size:  16px;

  /* Surfaces */
  --bg:         hsl(240 10% 3.9%);
  --bg-surface: hsl(240 6% 8%);
  --bg-raised:  hsl(240 5% 12%);
  --bg-hover:   hsl(240 5% 16%);

  /* Borders */
  --border:     hsl(240 5% 18%);
  --border-hi:  hsl(240 5% 28%);

  /* Text */
  --text-hi:    hsl(0 0% 98%);
  --text-md:    hsl(215 14% 65%);   /* slate-400 */
  --text-lo:    hsl(217 19% 38%);   /* slate-600 */

  /* Accent — DDA purple */
  --accent:          hsl(258 90% 66%);   /* #8b5cf6 */
  --accent-dim:      hsla(258 90% 66% / 0.15);
  --accent-border:   hsla(258 90% 66% / 0.35);
  --accent-hover:    hsl(258 85% 58%);   /* #7c3aed */

  /* Difficulty */
  --diff-easy:   hsl(142 70% 45%);
  --diff-medium: hsl(38 95% 55%);
  --diff-hard:   hsl(0 72% 60%);

  /* Spacing */
  --header-h:   60px;
  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg:  12px;

  /* Shadows */
  --shadow-header: 0 1px 0 var(--border), 0 2px 16px hsla(240 10% 3% / 0.6);
  --shadow-drawer: 20px 0 60px hsla(240 10% 2% / 0.7);
}

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

html {
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--text-hi);
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-hi);
  height: 100vh;
  overflow: hidden;
  /* Firefox scrollbar support */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

body.workspace-fullscreen-active {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* ─── Custom Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--accent); /* Solid purple state */
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover); /* Brighter purple on interaction */
}

/* ─── Icon helpers ───────────────────────────────────────────────── */
.icon-sm { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; }
.icon-xs { width: 13px; height: 13px; stroke-width: 2; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   ARENA HEADER
   Layout:  [LEFT: catalog | back | home] [CENTER: breadcrumb] [RIGHT: limits | prev/skip/next]
   ══════════════════════════════════════════════════════════════════ */

.arena-header {
  position: sticky;
  top: 0;
  z-index: 600;
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 0 16px;
  background:
    radial-gradient(120% 180% at 50% -60%, hsla(258 90% 66% / 0.12), transparent 48%),
    linear-gradient(180deg, hsl(240 7% 11%), hsl(240 7% 8.5%));
  box-shadow: var(--shadow-header);
  user-select: none;
  gap: 12px;
  border-bottom: 1px solid hsla(240 5% 24% / 0.5);
  backdrop-filter: blur(6px);
}

/* ── LEFT group ─────────────────────────────────────────────────── */
.arena-header__left {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  min-width: 0;
}

/* Shared left-header action style */
.catalog-btn,
.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid hsla(240 5% 26% / 0.88);
  background: linear-gradient(180deg, hsla(240 8% 12% / 0.92), hsla(240 8% 9% / 0.92));
  box-shadow: inset 0 1px 0 hsla(0 0% 100% / 0.05);
  color: var(--text-md);
  font-size: 13px;
  font-weight: 550;
  min-height: 36px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
  touch-action: manipulation;
}

.catalog-btn:hover,
.nav-icon-btn:hover {
  color: var(--text-hi);
  border-color: hsla(240 5% 36% / 0.95);
  background: linear-gradient(180deg, hsla(240 8% 16% / 0.94), hsla(240 8% 11% / 0.94));
  transform: translateY(-1px);
  box-shadow: 0 6px 14px hsla(240 20% 3% / 0.3), inset 0 1px 0 hsla(0 0% 100% / 0.07);
}



.catalog-btn[aria-expanded="true"] {
  color: hsl(258 95% 80%);
  border-color: hsla(258 90% 66% / 0.7);
  background: linear-gradient(180deg, hsla(258 90% 66% / 0.2), hsla(258 90% 66% / 0.12));
  box-shadow: 0 0 0 2px hsla(258 90% 66% / 0.14), inset 0 1px 0 hsla(0 0% 100% / 0.08);
}

.catalog-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.catalog-btn__label {
  font-size: 13px;
}

/* Vertical divider */
.nav-divider {
  width: 1px;
  height: 26px;
  background: linear-gradient(180deg, transparent, var(--border-hi), transparent);
  margin: 0 6px;
  flex-shrink: 0;
}

/* ── CENTER — Breadcrumb ─────────────────────────────────────────── */
.arena-header__center {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  overflow: hidden;
  padding: 0 12px;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumb__sep {
  color: var(--text-lo);
  flex-shrink: 0;
}

.breadcrumb__item { overflow: hidden; text-overflow: ellipsis; }
.breadcrumb__item--muted { color: var(--text-lo); }
.breadcrumb__item--active {
  color: var(--accent);
  font-weight: 600;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Difficulty pill */
.diff-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.diff-pill--easy   { background: hsla(142 70% 45% / 0.18); color: var(--diff-easy);   }
.diff-pill--medium { background: hsla(38 95% 55%  / 0.18); color: var(--diff-medium); }
.diff-pill--hard   { background: hsla(0 72% 60%   / 0.18); color: var(--diff-hard);   }

/* ── RIGHT — Perf stats + Problem nav ───────────────────────────── */

.arena-header__right {
  display: flex;
  align-items: center;
  justify-self: end;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.perf-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-lo);
}
.perf-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}
.perf-sep { color: var(--border-hi); }

/* Problem navigation (Prev · Skip · Next) */
.prob-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid hsla(240 5% 24% / 0.7);
  background: linear-gradient(180deg, hsla(240 6% 14% / 0.9), hsla(240 6% 10% / 0.9));
  box-shadow: inset 0 1px 0 hsla(0 0% 100% / 0.05);
  min-width: 360px;
}

.prob-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid hsla(240 5% 26% / 0.9);
  border-radius: 10px;
  background: linear-gradient(180deg, hsla(240 8% 11% / 0.88), hsla(240 8% 8% / 0.88));
  color: var(--text-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s ease, box-shadow 0.12s ease;
  min-height: 38px;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 hsla(0 0% 100% / 0.05);
}
.prob-nav__btn:hover:not(:disabled) {
  background: linear-gradient(180deg, hsla(240 8% 16% / 0.96), hsla(240 8% 11% / 0.96));
  border-color: hsla(240 5% 35% / 0.95);
  color: var(--text-hi);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px hsla(240 20% 3% / 0.35), inset 0 1px 0 hsla(0 0% 100% / 0.06);
}
.prob-nav__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.prob-nav__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Skip — slightly accented so it stands out */
.prob-nav__btn--skip {
  border-color: var(--accent-border);
  color: hsl(258 95% 72%);
}
.prob-nav__btn--skip:hover:not(:disabled) {
  background: linear-gradient(180deg, hsla(258 90% 66% / 0.28), hsla(258 90% 66% / 0.18));
  border-color: var(--accent);
  color: #fff;
}

/* ══════════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════════════ */
.main-container {
  display: flex;
  flex-direction: row;
  height: calc(100vh - var(--header-h));
  overflow: hidden; /* Prevent body scroll during resize */
}

/* ── Resizer Gutters ─────────────────────────────────────────────── */
.gutter {
  background: linear-gradient(180deg, hsla(240 6% 24% / 0.45), hsla(240 6% 16% / 0.45));
  background-repeat: no-repeat;
  background-position: 50%;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.16s ease;
  z-index: 10;
  position: relative;
  user-select: none;
  touch-action: none;
}

.gutter::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid hsla(0 0% 100% / 0.08);
  background: linear-gradient(160deg, hsla(240 8% 24% / 0.9), hsla(240 8% 16% / 0.9));
  box-shadow: 0 2px 8px hsla(240 20% 3% / 0.4);
  pointer-events: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.gutter::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.95;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.gutter:hover {
  background-color: var(--accent-border);
  box-shadow: 0 0 0 1px hsla(258 90% 66% / 0.14), 0 0 14px var(--accent-dim);
}

.gutter:hover::before {
  border-color: hsla(258 90% 66% / 0.42);
  box-shadow: 0 0 0 2px hsla(258 90% 66% / 0.12), 0 8px 18px hsla(240 20% 3% / 0.45);
}

.gutter:hover::after {
  opacity: 1;
}

.gutter:active::before,
.gutter.dragging::before {
  border-color: hsla(258 90% 66% / 0.6);
  box-shadow: 0 0 0 2px hsla(258 90% 66% / 0.2), 0 10px 20px hsla(240 20% 3% / 0.5);
  transform: translate(-50%, -50%) scale(0.97);
}

.gutter.gutter-horizontal {
  cursor: col-resize;
  width: 10px;
}

.gutter.gutter-horizontal::before {
  width: 18px;
  height: 46px;
  border-radius: 999px;
}

.gutter.gutter-horizontal::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: hsla(0 0% 96% / 0.78);
  box-shadow: 0 -7px 0 hsla(0 0% 96% / 0.78), 0 7px 0 hsla(0 0% 96% / 0.78);
}

.gutter.gutter-vertical {
  cursor: row-resize;
  height: 10px;
}

.gutter.gutter-vertical::before {
  width: 46px;
  height: 18px;
  border-radius: 999px;
}

.gutter.gutter-vertical::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: hsla(0 0% 96% / 0.78);
  box-shadow: -7px 0 0 hsla(0 0% 96% / 0.78), 7px 0 0 hsla(0 0% 96% / 0.78);
}

/* ══════════════════════════════════════════════════════════════════
   PROBLEMS SIDEBAR — LeetCode-style flat list
   ══════════════════════════════════════════════════════════════════ */
.problems-sidebar {
  position: fixed;
  top: 0;
  left: calc(-1 * 380px);
  width: 380px;
  height: 100vh;
  background: hsl(220 13% 10%);
  border-right: 1px solid var(--border);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-drawer);
}
.problems-sidebar.active {
  transform: translateX(380px);
}

/* Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: hsla(240 10% 2% / 0.65);
  backdrop-filter: blur(2px);
  z-index: 499;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ── Sidebar Header ─────────────────────────────────────────────── */
.sl-header {
  padding: calc(var(--header-h) + 16px) 16px 0;
  background: hsl(220 13% 10%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sl-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sl-title {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-hi);
}
.sl-title__chevron { color: var(--text-lo); }

.sl-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sl-solved-count {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-lo);
}
.sl-solved-count .icon-xs { color: hsl(142 60% 45%); }

.sl-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-lo);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.sl-close:hover { color: var(--text-hi); background: var(--bg-hover); }

/* Search bar */
.sl-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.sl-search__icon {
  position: absolute;
  left: 10px;
  color: var(--text-lo);
  pointer-events: none;
  flex-shrink: 0;
}
.sl-search__input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 12px 7px 30px;
  font-size: 13px;
  color: var(--text-hi);
  outline: none;
  transition: border-color 0.15s;
}
.sl-search__input::placeholder { color: var(--text-lo); }
.sl-search__input:focus { border-color: var(--accent); }

/* ── Problem rows ───────────────────────────────────────────────── */
.sl-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.sl-list::-webkit-scrollbar { width: 5px; }
.sl-list::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

.sl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  text-decoration: none;
  color: var(--text-hi);
  font-size: 13.5px;
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
  min-height: 40px;
}
.sl-row:hover {
  background: hsl(220 13% 14%);
}
.sl-row--active {
  background: hsl(220 13% 14%);
  border-left-color: #fff;
  font-weight: 600;
}
.sl-row--solved .sl-row__title {
  color: var(--text-lo);
}

.sl-row__num {
  font-size: 13px;
  color: var(--text-lo);
  min-width: 28px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.sl-row__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sl-row__diff {
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Difficulty colours (inline, no badge) */
.sl-diff--easy   { color: var(--diff-easy); }
.sl-diff--medium { color: var(--diff-medium); }
.sl-diff--hard   { color: var(--diff-hard); }

/* ══════════════════════════════════════════════════════════════════
   PROBLEM DETAIL PANEL
   ══════════════════════════════════════════════════════════════════ */
.problem-detail {
  background: var(--bg);
  padding: 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.problem-detail h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-hi);
  margin: 24px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.problem-detail h3:first-child { margin-top: 0; }

.problem-detail p {
  line-height: 1.7;
  color: var(--text-md);
  margin-bottom: 14px;
  font-size: 14px;
}

/* Markdown document styling (PDF-like reading experience) */
.md-doc {
  background:
    linear-gradient(180deg, hsl(230 12% 13%), hsl(230 12% 10%));
  border: 1px solid hsla(230 9% 33% / 0.72);
  border-radius: 14px;
  color: hsl(220 20% 88%);
  padding: 18px 20px;
  margin: 0 0 18px;
  box-shadow: 0 8px 22px hsla(230 35% 3% / 0.48), inset 0 1px 0 hsla(0 0% 100% / 0.05);
  font-family: 'Inter', var(--font-sans);
  font-size: 14px;
  line-height: 1.75;
  max-width: 840px;
  overflow-wrap: anywhere;
}

.md-doc__empty {
  color: hsl(220 14% 62%);
  font-style: italic;
}

.md-doc > *:first-child {
  margin-top: 0;
}

.md-doc > *:last-child {
  margin-bottom: 0;
}

.md-doc h1,
.md-doc h2,
.md-doc h3,
.md-doc h4 {
  color: hsl(0 0% 98%);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.15em;
  margin-bottom: 0.5em;
}

.md-doc h1 { font-size: 1.55rem; }
.md-doc h2 { font-size: 1.3rem; border-bottom: 1px solid hsla(230 10% 36% / 0.62); padding-bottom: 0.32em; }
.md-doc h3 { font-size: 1.12rem; }
.md-doc h4 { font-size: 1rem; }

.md-doc p,
.md-doc ul,
.md-doc ol,
.md-doc pre,
.md-doc table,
.md-doc blockquote {
  margin: 0.75em 0;
}

.md-doc ul,
.md-doc ol {
  padding-left: 1.35em;
}

.md-doc li + li {
  margin-top: 0.28em;
}

.md-doc hr {
  border: 0;
  border-top: 1px solid hsla(230 10% 34% / 0.65);
  margin: 1em 0;
}

.md-doc a {
  color: hsl(205 90% 70%);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md-doc code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: hsl(220 28% 90%);
  background: hsl(230 10% 20%);
  border: 1px solid hsla(230 8% 42% / 0.72);
  border-radius: 6px;
  padding: 0.1em 0.35em;
}

.md-doc pre {
  background: hsl(230 20% 9%);
  color: hsl(213 30% 90%);
  border: 1px solid hsla(230 8% 36% / 0.82);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
}

.md-doc pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
  font-size: 0.92em;
}

.md-doc blockquote {
  border-left: 4px solid hsl(218 72% 62%);
  background: hsla(220 22% 20% / 0.78);
  color: hsl(220 20% 86%);
  border-radius: 8px;
  padding: 10px 12px;
}

.md-doc table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.md-doc th,
.md-doc td {
  border: 1px solid hsla(230 9% 38% / 0.74);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.md-doc th {
  background: hsl(230 10% 20%);
  color: hsl(0 0% 97%);
  font-weight: 700;
}

.md-doc img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid hsla(230 8% 40% / 0.8);
}

/* Test cases */
.test-cases {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 20px;
}
.test-case {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  font-family: var(--font-mono);
}
.test-case-title {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 13px;
}
.test-case-section { margin-bottom: 10px; }
.test-case-label {
  color: var(--text-lo);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.test-case-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-hi);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ══════════════════════════════════════════════════════════════════
   EDITOR SECTION
   ══════════════════════════════════════════════════════════════════ */
.editor-section {
  background: var(--bg-raised);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-width: 0; /* Fix for flex children exceeding parent width */
}

.editor-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-raised);
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.editor-header {
  background: var(--bg-raised);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.editor-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}


.lang-dropdown {
  position: relative;
  min-width: 136px;
}

.language-select-native {
  display: none;
}

.language-select-btn {
  width: 100%;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid hsla(240 6% 34% / 0.95);
  background: linear-gradient(180deg, hsl(240 8% 12%), hsl(240 8% 9%));
  color: var(--text-hi);
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 hsla(0 0% 100% / 0.06);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.language-select-btn:hover {
  border-color: hsla(240 8% 48% / 0.95);
}

.language-select-btn:focus-visible {
  outline: none;
  border-color: hsla(258 90% 70% / 0.78);
  box-shadow: 0 0 0 2px hsla(258 90% 66% / 0.2), inset 0 1px 0 hsla(0 0% 100% / 0.08);
}

.language-dropdown-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 12px;
  border: 1px solid hsla(240 7% 34% / 0.95);
  background: hsl(240 10% 10%);
  box-shadow: 0 14px 36px hsla(240 35% 4% / 0.72);
  max-height: 220px;
  overflow-y: auto;
  z-index: 45;
  opacity: 0;
  transform: translateY(-4px) scale(0.985);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.lang-dropdown.is-open .language-dropdown-list {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.language-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-hi);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.14s ease, color 0.14s ease;
}

.language-dropdown-option:hover {
  background: hsla(240 10% 24% / 0.85);
}

.language-dropdown-option.is-selected {
  background: hsla(258 70% 58% / 0.2);
  color: hsl(258 95% 84%);
}

.language-dropdown-check {
  width: 14px;
  height: 14px;
  line-height: 14px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: hsl(258 95% 80%);
}

.language-dropdown-label {
  flex: 1;
}

.language-select-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--text-md);
  width: 16px;
  height: 16px;
  transition: color 0.15s ease, transform 0.15s ease;
}

.lang-dropdown.is-open .language-select-icon {
  transform: rotate(180deg);
}

.lang-dropdown:focus-within .language-select-icon {
  color: hsl(258 90% 72%);
}

.language-select-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Action buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 36px;
}

.run-btn { background: linear-gradient(135deg, hsl(158 70% 36%), hsl(158 64% 46%)); color: #fff; }
.run-btn:hover {
  background: linear-gradient(135deg, hsl(158 72% 30%), hsl(158 68% 40%));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsla(158 70% 40% / 0.4);
}

.submit-btn { background: linear-gradient(135deg, hsl(0 70% 45%), hsl(0 72% 58%)); color: #fff; }
.submit-btn:hover {
  background: linear-gradient(135deg, hsl(0 70% 38%), hsl(0 72% 50%));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsla(0 72% 55% / 0.4);
}

.reset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-md);
}
.reset-btn:hover {
  border-color: var(--border-hi);
  color: var(--text-hi);
  background: var(--bg-hover);
}

.fullscreen-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-md);
}
.fullscreen-btn:hover { border-color: var(--accent-border); color: var(--accent); }

.action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Code editor */
.code-editor {
  flex: 1;
  background: var(--bg);
  color: var(--text-hi);
  border: none;
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  resize: none;
  outline: none;
  tab-size: 2;
  height: 100%; /* Ensure it fills parent */
}
.code-editor::placeholder { color: var(--text-lo); font-style: italic; }

/* Console */
.console-section {
  flex: 1;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 40px;
}
.console-header {
  background: var(--bg-raised);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.console-header__left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.console-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-hi);
}
.console-perf-stats {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.console-perf-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, hsl(240 8% 9%), hsl(240 8% 7%));
  color: var(--text-hi);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  min-height: 32px;
  box-shadow: inset 0 1px 0 hsla(0 0% 100% / 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.console-perf-pill:hover {
  border-color: var(--border-hi);
  box-shadow: inset 0 1px 0 hsla(0 0% 100% / 0.05), 0 0 0 1px hsla(258 90% 66% / 0.14);
}

.console-perf-pill .icon-xs {
  width: 12px;
  height: 12px;
  color: var(--text-md);
}
.console-perf-label {
  color: var(--text-md);
  font-weight: 600;
}
.console-perf-sep {
  color: var(--text-lo);
  font-size: 11px;
}
.console-perf-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-hi);
}
.console-output {
  flex: 1;
  padding: 14px 18px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-hi);
  white-space: pre-wrap;
  background: var(--bg);
}

/* ── Fullscreen Workspace (editor + output) ─────────────────────── */
.main-container.workspace-fullscreen-right {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: auto;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  z-index: 800;
}

.main-container.workspace-fullscreen-right .gutter.gutter-horizontal,
.main-container.workspace-fullscreen-right #problem-side {
  display: none !important;
}

.main-container.workspace-fullscreen-right #editor-side {
  width: 100% !important;
  max-width: 100% !important;
  flex: 1 1 100% !important;
  height: 100% !important;
}

.main-container.workspace-fullscreen-right #editor-top,
.main-container.workspace-fullscreen-right #console-side {
  width: 100% !important;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-lo); }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-lo);
  text-align: center;
  gap: 12px;
  font-size: 14px;
}
.empty-state-icon { width: 52px; height: 52px; opacity: 0.4; }

/* ── Timer ───────────────────────────────────────────────────────── */
.timer {
  background: hsla(0 72% 60% / 0.12);
  border: 1px solid hsla(0 72% 60% / 0.3);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: hsl(0 72% 70%);
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .catalog-btn__label { display: none; }
  .nav-icon-btn span  { display: none; }
  .breadcrumb__item--active { max-width: 180px; }
}

@media (max-width: 520px) {
  .console-header {
    gap: 8px;
  }

  .console-perf-stats {
    width: 100%;
    justify-content: flex-start;
    gap: 5px;
  }

  .console-perf-pill {
    padding: 6px 9px;
    font-size: 11px;
    border-radius: 8px;
    min-height: 30px;
  }
}

@media (max-width: 1024px) {
  body {
    overflow-y: auto !important;
    height: auto !important;
  }

  .arena-header {
    height: 56px;
    padding: 0 8px;
  }

  .main-container {
    flex-direction: column !important; 
    height: auto !important; 
    overflow: visible !important;
    display: flex !important;
  }

  .main-container.workspace-fullscreen-right {
    top: var(--header-h) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    height: calc(100vh - var(--header-h)) !important;
    height: calc(100dvh - var(--header-h)) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .main-container.workspace-fullscreen-right #editor-side {
    height: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-rows: minmax(230px, 1fr) minmax(160px, 38dvh) !important;
    overflow: hidden !important;
  }

  .main-container.workspace-fullscreen-right #editor-top {
    min-height: 0 !important;
    flex: none !important;
    height: auto !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .main-container.workspace-fullscreen-right .editor-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    padding-top: calc(10px + env(safe-area-inset-top)) !important;
    background: linear-gradient(180deg, hsla(240 6% 10% / 0.97), hsla(240 6% 10% / 0.92)) !important;
    backdrop-filter: blur(4px);
  }

  .main-container.workspace-fullscreen-right .editor-footer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 25 !important;
    margin-bottom: env(safe-area-inset-bottom) !important;
  }

  .main-container.workspace-fullscreen-right .code-editor {
    height: auto !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
  }

  .main-container.workspace-fullscreen-right #console-side {
    min-height: 150px !important;
    max-height: 42dvh !important;
    margin-bottom: 0 !important;
    flex: none !important;
    overflow: hidden !important;
  }

  .main-container.workspace-fullscreen-right .console-output {
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }
  .prob-nav {
    min-width: 0;
    gap: 6px;
    padding: 4px 6px;
  }

  .prob-nav__btn {
    min-height: 40px;
    padding: 8px 12px;
  }

  .prob-nav__btn span { display: none; }
  .arena-header { padding: 0 10px; }
  
  /* Disable gutters on mobile */
  .gutter { display: none !important; }
  
  /* Reset rigid heights/widths */
  .problem-detail, 
  .editor-section, 
  .console-section,
  #problem-side,
  #editor-side,
  #editor-top,
  #console-side,
  .editor-pane { 
      width: 100% !important; 
      max-width: 100% !important;
      flex: none !important; 
      height: auto !important;
  }

  /* Specific Panel Heights */
    .problem-detail {
      border-right: none !important;
      border-bottom: 2px solid var(--border) !important;
      padding: 18px 18px 16px !important;
      overflow-x: hidden !important;
  }

    .problem-detail h3 {
      font-size: 17px;
      margin: 20px 0 10px;
    }

    .problem-detail p {
      font-size: 15px;
      line-height: 1.75;
    }

    .problem-detail .md-doc,
    .problem-detail .test-cases,
    .problem-detail > div[style*="max-width"] {
      width: 100% !important;
      max-width: none !important;
      margin-left: 0 !important;
      margin-right: 0 !important;
    }

    .md-doc {
      font-size: 15px;
      line-height: 1.8;
      padding: 16px;
      border-radius: 12px;
    }

    .md-doc h1 {
      font-size: 1.32rem;
      line-height: 1.35;
    }

    .md-doc h2 {
      font-size: 1.08rem;
      line-height: 1.4;
    }

    .md-doc h3 {
      font-size: 1rem;
    }

    .md-doc ul,
    .md-doc ol {
      padding-left: 1.2em;
    }

    .test-cases {
      padding: 12px;
      margin-top: 14px;
    }

    .test-case {
      padding: 12px;
      margin-bottom: 12px;
    }

    .test-case-content {
      font-size: 14px;
      line-height: 1.6;
    }

  .editor-section {
      min-height: 50vh !important;
      display: flex !important;
      flex-direction: column !important;
  }

    .editor-header {
      padding: 10px 12px;
    }

    .language-select-btn {
      min-height: 40px;
      font-size: 14px;
    }

    .action-btn {
      min-height: 40px;
      font-size: 13px;
    }

  .editor-pane {
      display: flex !important;
      flex-direction: column !important;
      min-height: 40vh !important;
  }

  .code-editor {
      min-height: 350px !important;
      height: 40vh !important;
      font-size: 15px;
      line-height: 1.7;
      padding: 14px 16px;
  }

  .console-section {
      min-height: 280px !important;
      margin-bottom: 24px !important;
  }

    .console-title {
      font-size: 14px;
    }

    .console-output {
      font-size: 13.5px;
      line-height: 1.65;
      padding: 12px 14px;
    }

  /* Ergonomic Floating Actions */
  .editor-footer {
     position: sticky !important;
     bottom: 0 !important;
     z-index: 10 !important;
     background: var(--bg-surface) !important;
     box-shadow: 0 -4px 12px rgba(0,0,0,0.4) !important;
     justify-content: space-between !important;
     padding: 12px 16px !important;
     border-top: 1px solid var(--border) !important;
  }
  
  .run-btn, .submit-btn {
      flex: 1 !important;
      justify-content: center !important;
      padding: 12px !important;
  }
}

  @media (max-width: 640px) {
    .problem-detail {
      padding: 16px 14px 14px !important;
    }

    .md-doc {
      font-size: 15px;
      line-height: 1.82;
      padding: 14px;
    }

    .problem-detail h3 {
      font-size: 16px;
    }

    .prob-nav {
      gap: 4px;
      padding: 3px 4px;
    }

    .prob-nav__btn {
      min-height: 38px;
      padding: 8px 10px;
    }

    .editor-footer {
      padding: 10px 12px !important;
      gap: 8px;
    }

    .run-btn,
    .submit-btn {
      min-height: 44px;
      font-size: 14px;
    }
  }

/* ── Prefers-reduced-motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
