:root {
  --bg: #0f1419;
  --bg-elevated: #171d25;
  --bg-card: #1c2430;
  --border: #2a3544;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3d8bfd;
  --accent-2: #20c997;
  --accent-soft: rgba(61, 139, 253, 0.12);
  --danger: #ff6b6b;
  --warning: #ffd43b;
  --success: #51cf66;
  --gold: #d4a017;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --sidebar: 280px;
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 139, 253, 0.18), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(32, 201, 151, 0.1), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(12px);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand { display: flex; gap: 0.75rem; align-items: center; padding: 0.25rem 0.5rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #1a4d8c, #3d8bfd);
  font-family: var(--serif);
  font-size: 1.4rem;
  color: white;
  box-shadow: 0 6px 18px rgba(61, 139, 253, 0.35);
}
.brand-title { font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.75rem; color: var(--muted); }

.nav {
  display: flex; flex-direction: column; gap: 0.2rem; flex: 1;
  overflow-y: auto; padding-right: 0.15rem;
}
.nav-group {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5f738c;
  font-weight: 700;
  margin: 0.75rem 0.5rem 0.3rem;
}
.nav-group:first-child { margin-top: 0.15rem; }
.state-card {
  cursor: pointer;
  transition: 0.15s ease;
  border: 1px solid var(--border);
}
.state-card:hover {
  border-color: rgba(61, 139, 253, 0.45);
  transform: translateY(-2px);
}
.state-card .flag {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}
.state-card-dual { cursor: default; }
.state-card-dual:hover { transform: none; }
.dual-track-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.track-btn {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start !important;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem !important;
  text-align: left;
  width: 100%;
}
.track-btn strong { font-size: 0.9rem; }
.track-btn span {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
}
@media (max-width: 520px) {
  .dual-track-row { grid-template-columns: 1fr; }
}
.pyq-year {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 700;
  color: #9ec1ff;
  transition: 0.12s ease;
}
.pyq-year:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tab-bar {
  display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.tab-bar button {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.tab-bar button.active {
  background: var(--accent-soft);
  color: #9ec1ff;
  border-color: rgba(61, 139, 253, 0.4);
}

.nav-item {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  transition: 0.15s ease;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: #9ec1ff;
  box-shadow: inset 0 0 0 1px rgba(61, 139, 253, 0.25);
}

.sidebar-foot { margin-top: auto; display: grid; gap: 0.75rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.7rem; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 0.78rem; color: var(--muted); width: fit-content;
}
.pill.ok { color: var(--success); border-color: rgba(81, 207, 102, 0.3); }
.pill.warn { color: var(--warning); border-color: rgba(255, 212, 59, 0.3); }
.disclaimer { font-size: 0.7rem; color: var(--muted); line-height: 1.4; margin: 0; }
.ai-disclaimer-banner {
  margin: 0 0 1.1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 212, 59, 0.35);
  background: rgba(255, 212, 59, 0.08);
  color: #ffe8a3;
  font-size: 0.88rem;
  line-height: 1.45;
}
.ai-disclaimer-banner strong { color: var(--warning); }

.main { padding: 1.5rem 2rem 3rem; max-width: 1100px; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: 1.5rem;
}
.topbar h1 {
  margin: 0; font-size: 1.85rem; letter-spacing: -0.03em;
  font-weight: 700;
}
.muted { color: var(--muted); margin: 0.25rem 0 0; }

.timer-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  text-align: right;
  min-width: 110px;
}
.timer-label { display: block; font-size: 0.7rem; color: var(--muted); }
.timer-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; color: var(--warning); }
.timer-box.urgent .timer-value { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.65; } }

.hidden { display: none !important; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

.card {
  background: linear-gradient(180deg, rgba(28, 36, 48, 0.95), rgba(23, 29, 37, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 0.6rem; letter-spacing: -0.02em; }
.card p { margin: 0.35rem 0; color: var(--muted); font-size: 0.92rem; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 1.6rem 1.5rem;
  background:
    linear-gradient(135deg, rgba(26, 77, 140, 0.45), rgba(15, 20, 25, 0.2)),
    var(--bg-card);
  border: 1px solid rgba(61, 139, 253, 0.3);
  border-radius: calc(var(--radius) + 4px);
  margin-bottom: 1rem;
}
.hero h2 {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.hero p { max-width: 58ch; }

.stat {
  display: flex; flex-direction: column; gap: 0.15rem;
}
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat .label { font-size: 0.8rem; color: var(--muted); }

/* ---- Judicial exam pattern (human UI, no raw JSON) ---- */
.jud-state-banner {
  background:
    linear-gradient(120deg, rgba(61, 139, 253, 0.12), transparent 55%),
    var(--bg-card);
}
.jud-banner-flag {
  font-size: 1.75rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(61, 139, 253, 0.25);
}
.jud-banner-title {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.jud-banner-stages {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: #9ec1ff;
  font-weight: 600;
}

.exam-overview-hero {
  margin-bottom: 1rem;
  background:
    linear-gradient(135deg, rgba(26, 77, 140, 0.35), rgba(15, 20, 25, 0.15)),
    var(--bg-card);
  border-color: rgba(61, 139, 253, 0.28);
}
.eoh-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.eoh-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #9ec1ff;
}
.eoh-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.eoh-short {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 52ch;
}
.eoh-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}
.accent-chip {
  background: var(--accent-soft);
  color: #9ec1ff;
  border: 1px solid rgba(61, 139, 253, 0.35);
}

.stage-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(42, 53, 68, 0.9);
}
.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.55);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}
.stage-idx {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: linear-gradient(135deg, #2f78e8, #3d8bfd);
  color: white;
}
.stage-arrow {
  color: var(--muted);
  font-weight: 700;
  opacity: 0.7;
}

.pattern-grid { align-items: stretch; }
.pattern-card-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}
.pattern-card-head h3 { margin: 0 0 0.15rem; }
.pattern-icon {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--accent-soft);
  color: #9ec1ff;
  border: 1px solid rgba(61, 139, 253, 0.3);
  flex-shrink: 0;
}
.pattern-tagline {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.pattern-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.55rem;
}
.pattern-stat {
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  background: rgba(15, 20, 25, 0.45);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 4.2rem;
}
.ps-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6f8299;
  font-weight: 700;
}
.ps-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.pattern-subhead {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  color: #9ec1ff;
  letter-spacing: -0.01em;
}
.paper-list { display: grid; gap: 0.55rem; }
.paper-row {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid var(--border);
}
.paper-num {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(61, 139, 253, 0.15);
  color: #9ec1ff;
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.paper-body { flex: 1; min-width: 0; }
.paper-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  justify-content: space-between;
}
.paper-body strong { color: var(--text); font-size: 0.95rem; }
.paper-marks, .paper-marks-chip {
  font-size: 0.78rem;
  color: #a8e6cf;
}
.paper-marks-chip {
  background: rgba(32, 201, 151, 0.1);
  border: 1px solid rgba(32, 201, 151, 0.28);
  color: #8fe3c4;
}
.paper-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.pattern-note {
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: rgba(255, 212, 59, 0.06);
  border: 1px solid rgba(255, 212, 59, 0.18);
  color: #e6d9a0;
  font-size: 0.84rem;
}
.pattern-footnote {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: #6f8299;
}
.official-hint-card {
  margin-top: 1rem;
  border-color: rgba(32, 201, 151, 0.25);
}
.prelims-card .pattern-icon { background: rgba(61, 139, 253, 0.18); }
.mains-card .pattern-icon {
  background: rgba(32, 201, 151, 0.15);
  color: #8fe3c4;
  border-color: rgba(32, 201, 151, 0.3);
}
.interview-card .pattern-icon {
  background: rgba(212, 160, 23, 0.15);
  color: #f0c96a;
  border-color: rgba(212, 160, 23, 0.3);
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .pattern-stats { grid-template-columns: repeat(2, 1fr); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  transition: 0.15s ease;
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(135deg, #2f78e8, #3d8bfd);
  color: white;
  box-shadow: 0 6px 16px rgba(61, 139, 253, 0.3);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: #3d4f66; }
.btn-success { background: rgba(32, 201, 151, 0.15); color: var(--accent-2); border: 1px solid rgba(32, 201, 151, 0.35); }
.btn-danger { background: rgba(255, 107, 107, 0.12); color: var(--danger); border: 1px solid rgba(255, 107, 107, 0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

.chip {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--muted);
}
.chip.high { color: #ffc078; border-color: rgba(255, 192, 120, 0.35); }
.chip.vhigh { color: #ff8787; border-color: rgba(255, 135, 135, 0.35); }
.chip.med { color: #91a7ff; border-color: rgba(145, 167, 255, 0.35); }

.form-row {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 140px; }
.field label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.field select, .field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
.field select:focus, .field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.2);
}

.q-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  margin-bottom: 0.85rem;
}
.q-meta {
  display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.q-num { font-weight: 700; color: #9ec1ff; margin-right: 0.35rem; }
.q-text { font-size: 1rem; margin-bottom: 0.75rem; }
.options { display: grid; gap: 0.45rem; }
.option {
  display: flex; gap: 0.65rem; align-items: flex-start;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: left;
  transition: 0.12s ease;
}
.option:hover { border-color: #3d4f66; }
.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option.correct {
  border-color: var(--success);
  background: rgba(81, 207, 102, 0.1);
}
.option.wrong {
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.1);
}
.opt-key {
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700;
  background: var(--bg-elevated); color: var(--muted); flex-shrink: 0;
}
.option.selected .opt-key { background: var(--accent); color: white; }
.explanation {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(32, 201, 151, 0.08);
  border: 1px solid rgba(32, 201, 151, 0.2);
  font-size: 0.9rem;
  color: #c3e6cb;
}

.progress-bar {
  height: 8px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--border); overflow: hidden; margin: 0.75rem 0;
}
.progress-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #2f78e8, #20c997);
  width: 0%; transition: width 0.25s ease;
}

.topic-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.topic-list li {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.topic-list strong { display: block; margin-bottom: 0.25rem; }
.subtopics { font-size: 0.82rem; color: var(--muted); }

.table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.table th, .table td {
  text-align: left; padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }

.research-item {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 0.6rem;
}
.research-item a { font-weight: 600; text-decoration: none; }
.research-item a:hover { text-decoration: underline; }
.snippet { font-size: 0.88rem; color: var(--muted); margin-top: 0.35rem; }

.loading {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--muted); padding: 1rem 0;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.score-ring {
  width: 120px; height: 120px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent-2) var(--p, 0%), var(--border) 0);
  margin: 0 auto 1rem;
}
.score-ring-inner {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--bg-card);
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.4rem;
}

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: grid; place-items: center;
  padding: 1rem;
}
.modal-card {
  width: min(560px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 0.6rem; right: 0.8rem;
  font-size: 1.4rem; color: var(--muted);
}

.desc-card textarea {
  width: 100%;
  min-height: 120px;
  margin-top: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  resize: vertical;
}
.model-points {
  margin-top: 0.6rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-tabs {
  display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.section-tabs button {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg);
  font-size: 0.85rem; font-weight: 600;
}
.section-tabs button.active {
  background: var(--accent-soft);
  color: #9ec1ff;
  border-color: rgba(61, 139, 253, 0.4);
}

.sticky-actions {
  position: sticky; bottom: 0.75rem;
  display: flex; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.75rem;
  background: rgba(15, 20, 25, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}
