:root {
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #18233d;
  --surface-3: #0f1628;
  --border: #253356;
  --text: #e6ecf8;
  --text-muted: #93a4c7;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ac: #22c55e;
  --wa: #ef4444;
  --tle: #f59e0b;
  --re: #a855f7;
  --ce: #f97316;
  --mono: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  letter-spacing: 0.4px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.brand-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

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

.sidebar {
  background: var(--surface-3);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.problem-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.problem-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.problem-item:hover {
  border-color: #3b82f6;
  background: var(--surface-2);
}

.problem-item.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.14);
}

.problem-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.problem-item-code {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: #60a5fa;
}

.problem-item-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.problem-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 12px;
  padding: 12px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: #60a5fa;
  border-bottom-color: var(--primary);
}

.panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.hidden {
  display: none !important;
}

.problem-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.problem-code-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.16);
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.problem-header h2 {
  margin: 0;
  font-size: 18px;
}

.limits {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill-neutral {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pill-ac {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.statement-block {
  margin-bottom: 18px;
}

.statement-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #93c5fd;
}

.pre-wrap {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
}

.sample-card {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.sample-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sample-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.sample-pre {
  margin: 0;
  background: #080c17;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sample-explanation {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-tag {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: #93c5fd;
}

.shortcut-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: #60a5fa;
}

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

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: #60a5fa;
}

.code-editor-wrap {
  display: flex;
  flex: 1.2;
  min-height: 220px;
  background: #080c17;
  overflow: hidden;
}

.line-numbers {
  margin: 0;
  padding: 12px 10px;
  min-width: 44px;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: #4f628e;
  background: #0b1020;
  border-right: 1px solid var(--border);
  user-select: none;
  overflow: hidden;
}

.code-editor {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  background: #080c17;
  color: #e6ecf8;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 4;
  overflow: auto;
}

.console-panel {
  display: flex;
  flex-direction: column;
  flex: 0.95;
  min-height: 210px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.console-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.empty-state {
  color: var(--text-muted);
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.verdict-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.verdict-badge {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 14px;
  padding: 3px 10px;
  border-radius: 7px;
}

.v-AC { background: rgba(34, 197, 94, 0.16); color: #4ade80; border-color: rgba(34, 197, 94, 0.45); }
.v-WA { background: rgba(239, 68, 68, 0.16); color: #f87171; border-color: rgba(239, 68, 68, 0.45); }
.v-TLE { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border-color: rgba(245, 158, 11, 0.45); }
.v-RE { background: rgba(168, 85, 247, 0.16); color: #c084fc; border-color: rgba(168, 85, 247, 0.45); }
.v-CE { background: rgba(249, 115, 22, 0.16); color: #fb923c; border-color: rgba(249, 115, 22, 0.45); }

.compile-box {
  background: #080c17;
  border: 1px solid rgba(249, 115, 22, 0.4);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  color: #fdba74;
  margin-bottom: 12px;
}

.tc-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tc-row {
  border: 1px solid var(--border);
  background: var(--surface-3);
  border-radius: 8px;
  padding: 8px 10px;
}

.tc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.tc-diff {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.tc-diff pre {
  margin: 4px 0 0;
  background: #080c17;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tc-diff-label {
  font-size: 11px;
  color: var(--text-muted);
}

.custom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  height: 100%;
}

.custom-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 130px;
}

.custom-col label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.custom-out-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-status {
  font-size: 12px;
  font-family: var(--mono);
  color: #93c5fd;
}

.io-box {
  flex: 1;
  margin: 0;
  background: #080c17;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  resize: none;
  outline: none;
  overflow: auto;
  white-space: pre-wrap;
}

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

.history-header h3 {
  margin: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--border);
  background: var(--surface-3);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item:hover {
  border-color: var(--primary);
}

.history-meta {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .sidebar {
    max-height: 170px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
}
