/* TraceGrade Design System - Clean Slate Theme */
:root {
  /* Slate neutral palette */
  --bg-base: #0b0b0f;        /* Slate 900 */
  --bg-surface: #131318;     /* Slate 800 */
  --bg-card: #131318;        /* Slate 800 */
  --bg-card-hover: #1a1a21;  /* Slate 700 */
  --bg-subtle: #0b0b0f;      /* Slate 950 */
  --border-color: #26262e;   /* Slate 700 */
  --border-subtle: #1a1a21;
  --border-focus: #6366f1;   /* Indigo 500 */

  /* Text hierarchy */
  --text-main: #f4f4f5;      /* Slate 50 */
  --text-muted: #a1a1aa;     /* Slate 400 */
  --text-dim: #71717a;       /* Slate 500 */

  /* Primary Accent: Sophisticated Indigo */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-primary-subtle: rgba(99, 102, 241, 0.12);

  /* Secondary Accent: Cyan / Blue */
  --accent-cyan: #a5b4fc;    /* Sky 500 */
  --accent-cyan-subtle: rgba(99, 102, 241, 0.12);

  /* Semantic status colors */
  --color-success: #22c55e;  /* Emerald 500 */
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #eab308;  /* Amber 500 */
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-error: #ef4444;    /* Red 500 */
  --color-error-bg: rgba(239, 68, 68, 0.12);

  /* Typography */
  --font-sans: Inter, "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Shadows & Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: #a5b4fc;
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: #c7d2fe;
  text-decoration: underline;
}

/* Navbar */
.navbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
  text-decoration: none !important;
}
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
  color: #fff;
}
.brand-badge {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}
.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: #fff;
  text-decoration: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Mobile Nav Toggle */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.mobile-menu {
  display: none;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}
.mobile-menu.active {
  display: block;
}
.mobile-menu ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mobile-menu a {
  color: var(--text-muted);
  font-size: 0.95rem;
  display: block;
  padding: 0.4rem 0;
}

/* Layout Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  width: 100%;
}

/* Buttons Hierarchy */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.15s ease;
  line-height: 1.4;
}
.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  color: #ffffff;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: #475569;
  color: #ffffff;
}
.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}
.btn-danger {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: var(--color-error);
  color: #fff;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
}
.badge-easy { background: var(--color-success-bg); color: var(--color-success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-medium { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-hard { background: var(--color-error-bg); color: var(--color-error); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-indigo { background: var(--accent-primary-subtle); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.15s ease;
}
.card:hover {
  border-color: #34343d;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.form-control {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus {
  border-color: var(--border-focus);
}

/* Code blocks & monospace */
pre, code, .mono {
  font-family: var(--font-mono);
}
pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  color: #e2e8f0;
  line-height: 1.45;
}

/* SVG Inline icons helper */
.icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  vertical-align: -0.15em;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 0.875rem; height: 0.875rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }

/* Responsive grid system */
.grid {
  display: grid;
  gap: 1.5rem;
}
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 768px) {
  .nav-links { display: none; }
  .mobile-nav-toggle { display: block; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
  .container { padding: 1.5rem 1rem; }
}

/* Footer */
footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
footer a {
  color: var(--text-muted);
}
footer a:hover {
  color: var(--text-main);
}


/* ===== Design system v2 (consistent type, tables, rooms) ===== */
body { font-size: 14px; line-height: 1.6; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; color: var(--text-main); }
.btn { font-weight: 500; font-size: 14px; }
.btn-sm { font-size: 13px; }
.badge { font-weight: 500; border: 0 !important; background: var(--bg-card-hover) !important; color: var(--text-muted) !important; }
.badge-easy, .badge-medium, .badge-hard { background: transparent !important; padding-left: 0; }
.badge-easy { color: var(--color-success) !important; }
.badge-medium { color: var(--color-warning) !important; }
.badge-hard { color: var(--color-error) !important; }
.badge-easy::before, .badge-medium::before, .badge-hard::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-title { font-size: 28px; font-weight: 600; line-height: 1.2; margin-bottom: 0.25rem; }
.page-sub { color: var(--text-muted); font-size: 14px; }
.section-title { font-size: 20px; font-weight: 600; margin-bottom: 0.75rem; }
.label { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

/* Nav */
.nav-links a.active { color: var(--text-main); box-shadow: inset 0 -2px 0 var(--accent-primary); padding-bottom: 0.35rem; }
.nav-brand { font-weight: 600; }

/* Toolbar + table (LeetCode-style lists) */
.toolbar { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .form-control { max-width: 280px; height: 36px; padding: 0 0.75rem; font-size: 14px; }
.toolbar select.form-control { max-width: 160px; }
.table-wrap { border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-surface); }
.table-scroll { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-card-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a.row-title { color: var(--text-main); font-weight: 500; }
.table a.row-title:hover { color: #c7d2fe; text-decoration: none; }
.diff { font-weight: 500; }
.diff-easy { color: var(--color-success); } .diff-medium { color: var(--color-warning); } .diff-hard { color: var(--color-error); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--bg-card-hover); color: var(--text-muted); font-size: 12px; font-weight: 500; }
.tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.status-dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-color); display: inline-block; }
.status-dot.done { border-color: var(--color-success); background: var(--color-success); }
.progress { height: 6px; border-radius: 999px; background: var(--bg-card-hover); overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--accent-primary); }
.row-soon td { color: var(--text-dim); }

/* Split layout (collapses on mobile) */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.split > .side { position: sticky; top: 76px; }
.task-list { list-style: none; display: flex; flex-direction: column; }
.task-list li { display: flex; gap: 0.9rem; align-items: center; padding: 0.8rem 0; border-bottom: 1px solid var(--border-color); }
.task-list li:last-child { border-bottom: 0; }
.task-num { width: 26px; height: 26px; border-radius: 6px; background: var(--bg-card-hover); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.facts .v { font-size: 15px; font-weight: 600; color: var(--text-main); }
.axis { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 0.75rem; align-items: center; font-size: 13px; margin-bottom: 0.6rem; }
.axis .bar { grid-column: 1 / -1; height: 4px; background: var(--bg-card-hover); border-radius: 999px; overflow: hidden; }
.axis .bar span { display: block; height: 100%; background: var(--accent-primary); }

.empty { text-align: center; padding: 3rem 1rem; }
.empty .empty-icon { width: 40px; height: 40px; margin: 0 auto 0.75rem; color: var(--text-dim); }
.empty h3 { font-size: 16px; margin-bottom: 0.35rem; }
.empty p { color: var(--text-muted); margin-bottom: 1rem; }

/* Home */
.hero { padding: 3.5rem 0 3rem; max-width: 720px; }
.hero h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; font-weight: 600; margin-bottom: 1rem; }
.hero p { font-size: 16px; color: var(--text-muted); margin-bottom: 1.75rem; max-width: 600px; }
.hero .actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; padding: 2rem 0 3rem; border-top: 1px solid var(--border-color); }
.steps .n { font-size: 12px; font-weight: 600; color: var(--accent-primary); margin-bottom: 0.4rem; }
.steps h3 { font-size: 16px; margin-bottom: 0.35rem; }
.steps p { color: var(--text-muted); }
.home-section { padding: 2.5rem 0; border-top: 1px solid var(--border-color); }
.faq details { border-bottom: 1px solid var(--border-color); padding: 0.9rem 0; }
.faq summary { cursor: pointer; font-weight: 500; color: var(--text-main); list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq details p { color: var(--text-muted); margin-top: 0.5rem; max-width: 720px; }

/* Dark scrollbars */
pre::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { height: 8px; }
pre::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { background: #34343d; border-radius: 999px; }
pre::-webkit-scrollbar-track, .table-scroll::-webkit-scrollbar-track { background: transparent; }
pre { white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .split > .side { position: static; }
  .steps { grid-template-columns: 1fr; gap: 1.25rem; }
}
@media (max-width: 768px) {
  .brand-badge, .nav-user .btn-outline { display: none; }
  .navbar { padding: 0.65rem 1rem; }
  .hide-sm { display: none; }
  .page-title { font-size: 24px; }
}

/* ===== MCP setup page ===== */
.setup { display: flex; flex-direction: column; }
.setup-step { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 1rem; padding: 1.5rem 0; border-top: 1px solid var(--border-color); }
.setup-step:first-child { border-top: 0; padding-top: 0.5rem; }
.setup-num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-primary-subtle); color: #c7d2fe; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.setup-body { max-width: 760px; }
.copy-row { display: flex; gap: 0.5rem; }
.copy-row .form-control { flex: 1; height: 38px; }
.notice { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; font-size: 14px; border: 1px solid; }
.notice-success { background: var(--color-success-bg); border-color: rgba(34, 197, 94, 0.3); color: var(--text-main); }
.notice-error { background: var(--color-error-bg); border-color: rgba(239, 68, 68, 0.3); color: var(--text-main); }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem; overflow-x: auto; }
.tab { background: none; border: 0; color: var(--text-muted); font: inherit; font-weight: 500; padding: 0.55rem 0.85rem; cursor: pointer; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.tab:hover { color: var(--text-main); }
.tab.active { color: var(--text-main); box-shadow: inset 0 -2px 0 var(--accent-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.steps-list { padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.steps-list li { padding-left: 0.25rem; }
.code-block { position: relative; margin-top: 0.5rem; }
.code-block pre { padding-right: 4.5rem; margin: 0; }
.code-block .copy-btn { position: absolute; top: 6px; right: 6px; }
.alt { margin-top: 1rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.65rem 0.9rem; }
.alt summary { cursor: pointer; color: var(--text-muted); font-weight: 500; }
.alt[open] summary { margin-bottom: 0.6rem; }
.trouble { padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.4rem; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 0.6rem 1rem; align-items: center; }
@media (max-width: 768px) {
  .kv { grid-template-columns: 1fr; }
  .copy-row { flex-direction: column; }
  .setup-step { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
  .setup-body, .tab-panel, .code-block { min-width: 0; max-width: 100%; }
}

/* Exam state on room page */
.exam-live { display: flex; gap: 0.75rem; align-items: center; padding: 0.75rem; border: 1px solid rgba(34, 197, 94, 0.3); background: var(--color-success-bg); border-radius: var(--radius-md); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-success); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2); flex: none; }
