/* TOI-Zero Solutions — friendlier palette + richer landing UI
   Warm indigo/violet dark base, pastel accents, softer shadows. */
:root {
  /* Surfaces — warm indigo, not icy slate */
  --bg:        #14102a;
  --bg-elev:   #1d1740;
  --bg-card:   #221c48;
  --bg-hover:  #2a2358;
  --border:    rgba(167, 139, 250, .18);
  --border-strong: rgba(167, 139, 250, .32);

  /* Text */
  --text:       #eceaf5;
  --text-muted: #aea7cc;
  --text-dim:   #8a82ab;

  /* Primary — pastel indigo (soft, inviting) */
  --primary:      #a5b4fc;
  --primary-bold: #818cf8;
  --primary-soft: rgba(165, 180, 252, .12);

  /* Semantic — pastel, not alarm-red/alarm-green */
  --success:      #86efac;
  --success-soft: rgba(134, 239, 172, .14);
  --warn:         #fcd34d;
  --warn-soft:    rgba(252, 211, 77, .14);
  --danger:       #fca5a5;
  --danger-soft:  rgba(252, 165, 165, .14);

  /* Code */
  --code-bg: #0e0a22;

  /* Problem-set accents (distinct pastels) */
  --accent-a1:      #93c5fd;  /* blue-300 */
  --accent-a1-soft: rgba(147, 197, 253, .14);
  --accent-a2:      #c4b5fd;  /* violet-300 */
  --accent-a2-soft: rgba(196, 181, 253, .14);
  --accent-a3:      #f9a8d4;  /* pink-300 */
  --accent-a3-soft: rgba(249, 168, 212, .14);

  --radius:   12px;
  --radius-sm: 8px;
  --shadow:   0 10px 30px rgba(40, 20, 90, .35);
  --shadow-glow: 0 12px 32px rgba(165, 180, 252, .22);

  font-family: 'Inter', 'Sarabun', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(ellipse 900px 500px at 10% -10%, rgba(165, 180, 252, .12), transparent 60%),
    radial-gradient(ellipse 800px 500px at 110% 8%, rgba(249, 168, 212, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
body { font-family: inherit; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================ Header */
.site-header {
  background:
    radial-gradient(ellipse at 18% 0%, rgba(165, 180, 252, .35), transparent 55%),
    radial-gradient(ellipse at 82% 0%, rgba(249, 168, 212, .22), transparent 55%),
    linear-gradient(135deg, #1e1a4a 0%, #16122f 55%, #2a1a45 100%);
  padding: 2.8rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.site-header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(165, 180, 252, .5), transparent);
}
.site-header .wrap {
  max-width: 1100px;
  margin: 0 auto;
}
.site-header h1 {
  margin: 0 0 .45rem;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  letter-spacing: -0.02em;
  font-weight: 700;
  background: linear-gradient(120deg, #ffffff 0%, #dcd4ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-header p {
  margin: 0;
  color: var(--text-muted);
  max-width: 70ch;
}
.site-header .badge {
  display: inline-block;
  background: rgba(255, 255, 255, .08);
  color: #f4f2ff;
  border: 1px solid rgba(255, 255, 255, .14);
  padding: .18rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  margin-right: .4rem;
  margin-bottom: .7rem;
  backdrop-filter: blur(6px);
}

/* ============================================================ PDF CTA card */
.pdf-card {
  display: flex;
  align-items: center;
  gap: .95rem;
  margin: 1.15rem 0 0;
  padding: .75rem 1rem;
  max-width: 420px;
  color: var(--text) !important;
  text-decoration: none !important;
  background:
    linear-gradient(135deg, rgba(165, 180, 252, .14) 0%, rgba(249, 168, 212, .12) 100%),
    rgba(29, 23, 64, .55);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(25, 15, 60, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform .2s ease, border-color .2s ease, box-shadow .25s ease, background .25s ease;
}
.pdf-card:hover {
  transform: translateY(-2px);
  border-color: rgba(165, 180, 252, .55);
  box-shadow: 0 12px 32px rgba(165, 180, 252, .22), inset 0 1px 0 rgba(255, 255, 255, .1);
}
.pdf-card:active { transform: translateY(-1px); }
.pdf-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(225, 29, 72, .35), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.pdf-card-text {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  flex: 1;
  min-width: 0;
}
.pdf-card-text strong {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.005em;
  line-height: 1.25;
}
.pdf-card-text small {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .02em;
}
.pdf-card-arrow {
  color: var(--primary);
  opacity: .65;
  flex-shrink: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.pdf-card:hover .pdf-card-arrow { transform: translateX(4px); opacity: 1; }
@media (max-width: 520px) {
  .pdf-card { max-width: none; padding: .7rem .85rem; }
  .pdf-card-icon { width: 38px; height: 38px; }
  .pdf-card-text strong { font-size: .9rem; }
}

/* ============================================================ Container */
main.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ============================================================ Stats + Progress (landing) */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin: 1rem 0 1.5rem;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  position: relative;
  overflow: hidden;
}
.stat .num {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--text);
}
.stat .lbl {
  color: var(--text-muted);
  font-size: .78rem;
  margin-top: .35rem;
}
.stat.a1 { border-left: 3px solid var(--accent-a1); }
.stat.a2 { border-left: 3px solid var(--accent-a2); }
.stat.a3 { border-left: 3px solid var(--accent-a3); }

/* Progress card (the big one showing overall / per-set) */
.progress-card {
  background: linear-gradient(135deg, rgba(165, 180, 252, .09), rgba(249, 168, 212, .06)), var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.8rem;
}
.progress-card h3 {
  margin: 0 0 .85rem;
  font-size: .95rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.progress-row {
  display: grid;
  grid-template-columns: 55px 1fr auto;
  align-items: center;
  gap: .75rem;
  margin: .5rem 0;
  font-size: .88rem;
}
.progress-row .label {
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text);
}
.progress-row .value {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, .06);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 999px;
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}
.progress-bar .fill.total { background: linear-gradient(90deg, var(--primary), var(--accent-a3)); }
.progress-bar .fill.a1    { background: linear-gradient(90deg, var(--accent-a1), #60a5fa); }
.progress-bar .fill.a2    { background: linear-gradient(90deg, var(--accent-a2), #a78bfa); }
.progress-bar .fill.a3    { background: linear-gradient(90deg, var(--accent-a3), #ec4899); }

/* ============================================================ Controls (search + filter) */
.controls {
  display: flex;
  gap: .65rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.search {
  flex: 1 1 260px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: .7rem 1rem;
  color: var(--text);
  border-radius: var(--radius);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.search::placeholder { color: var(--text-dim); }
.search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.filter-group {
  display: flex;
  gap: .35rem;
  padding: .2rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: .45rem .95rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
  font-size: .88rem;
  font-family: inherit;
}
.filter-btn:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.filter-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

/* ============================================================ Problem grid (landing) */
.section-title {
  margin: 2rem 0 .9rem;
  padding: .4rem 0 .45rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.15rem;
  letter-spacing: .01em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.section-title .chip {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 999px;
}
.section-title.a1 .chip { background: var(--accent-a1); box-shadow: 0 0 12px var(--accent-a1); }
.section-title.a2 .chip { background: var(--accent-a2); box-shadow: 0 0 12px var(--accent-a2); }
.section-title.a3 .chip { background: var(--accent-a3); box-shadow: 0 0 12px var(--accent-a3); }
.section-title .count {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .7rem;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: block;
  color: var(--text);
  text-decoration: none;
  transition: transform .12s, border-color .15s, box-shadow .15s, background .15s;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--border);
  transition: width .15s, background .15s;
}
.card:hover {
  transform: translateY(-2px);
  background: var(--bg-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.card:hover::before { width: 4px; }
.card .id {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card .title {
  font-weight: 600;
  margin-top: .2rem;
  font-size: .96rem;
  line-height: 1.35;
}
.card.a1::before { background: var(--accent-a1); }
.card.a2::before { background: var(--accent-a2); }
.card.a3::before { background: var(--accent-a3); }
.card.a1:hover { box-shadow: 0 10px 30px rgba(147, 197, 253, .18); }
.card.a2:hover { box-shadow: 0 10px 30px rgba(196, 181, 253, .18); }
.card.a3:hover { box-shadow: 0 10px 30px rgba(249, 168, 212, .18); }

/* Score chip on card */
.card .score {
  margin-left: auto;
  font-size: .68rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .03em;
  border: 1px solid transparent;
}
.card .score.full    { color: var(--success); background: var(--success-soft); border-color: rgba(134, 239, 172, .3); }
.card .score.partial { color: var(--warn);    background: var(--warn-soft);    border-color: rgba(252, 211, 77, .3); }
.card .score.low     { color: var(--danger);  background: var(--danger-soft);  border-color: rgba(252, 165, 165, .3); }

/* Solved checkbox (bottom-right) */
.card .solved-dot {
  position: absolute;
  bottom: .6rem;
  right: .75rem;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card .solved-dot:hover { border-color: var(--success); background: var(--success-soft); }
.card .solved-dot.on {
  background: var(--success);
  border-color: var(--success);
  color: #052e0f;
}
.card .solved-dot.on::after {
  content: '';
  width: 4px; height: 8px;
  border: solid #052e0f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  display: block;
}
.card.is-solved {
  opacity: .75;
}
.card.is-solved .title { text-decoration: line-through; text-decoration-color: var(--text-dim); }

/* ============================================================ Problem page */
.problem-page .crumbs {
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: .85rem;
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.problem-page .crumbs a { color: var(--text-muted); }
.problem-page .crumbs a:hover { color: var(--primary); text-decoration: none; }
.problem-page .crumbs .sep { color: var(--text-dim); }
.problem-page .crumbs .current { color: var(--text); font-weight: 500; }

.problem-page h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
}
.problem-page h2 {
  margin: 2.2rem 0 .8rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.25rem;
  letter-spacing: .01em;
}
.problem-page .tag {
  display: inline-block;
  background: var(--primary-soft);
  border: 1px solid rgba(165, 180, 252, .32);
  color: var(--primary);
  font-size: .72rem;
  padding: .12rem .6rem;
  border-radius: 999px;
  margin-right: .35rem;
}

/* Panels */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.panel.hint { border-left: 4px solid var(--warn); }
.panel.idea { border-left: 4px solid var(--primary); }

/* IO table */
.iotable {
  width: 100%;
  border-collapse: collapse;
  margin: .4rem 0 1rem;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: .88rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.iotable th {
  text-align: left;
  background: var(--bg-elev);
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}
.iotable td {
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  vertical-align: top;
}

/* Solution toggle */
details.solution {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: border-color .15s;
}
details.solution:hover { border-color: var(--border-strong); }
details.solution > summary {
  padding: .9rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  transition: background .12s;
}
details.solution > summary::-webkit-details-marker { display: none; }
details.solution > summary:hover { background: var(--primary-soft); }
details.solution > summary::before {
  content: "▶";
  display: inline-block;
  transition: transform .2s;
  color: var(--primary);
  font-size: .75rem;
}
details.solution[open] > summary::before { transform: rotate(90deg); }
details.solution .body {
  padding: 0 1.1rem 1rem;
  border-top: 1px solid var(--border);
}
.lang-py { border-left: 4px solid #fde047; }
.lang-cpp { border-left: 4px solid #60a5fa; }

/* Code block */
pre.code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: .88rem;
  line-height: 1.6;
  margin: .8rem 0 1rem;
  position: relative;
}
pre.code code { color: #f1f5f9; }

code.inline {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0 .4rem;
  border-radius: 5px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: .88em;
}

.explain ol, .explain ul { padding-left: 1.3rem; }
.explain li { margin-bottom: .5rem; }

/* Nav bottom (prev / home / next) */
.nav-bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: .75rem;
  margin-top: 2.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
  align-items: stretch;
}
.nav-bottom a {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: all .15s;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 54px;
}
.nav-bottom a:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
  text-decoration: none;
  transform: translateY(-1px);
}
.nav-bottom .nav-prev { justify-content: flex-start; }
.nav-bottom .nav-home { justify-content: center; }
.nav-bottom .nav-next { justify-content: flex-end; text-align: right; }
.nav-bottom .nav-label {
  display: block;
  font-size: .7rem;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.1;
}
.nav-bottom .nav-title {
  display: block;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.25;
  margin-top: .12rem;
}
.nav-bottom a.disabled {
  opacity: .35;
  pointer-events: none;
}
@media (max-width: 640px) {
  .nav-bottom { grid-template-columns: 1fr 1fr; }
  .nav-bottom .nav-home { grid-column: 1 / -1; order: -1; }
}

/* Code keyword syntax (very light) */
.k { color: #c084fc; }
.s { color: #86efac; }
.n { color: #93c5fd; }
.c { color: #64748b; font-style: italic; }

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: .85rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* small screens */
@media (max-width: 600px) {
  .site-header { padding: 1.8rem 1rem 1.4rem; }
  main.container { padding: 1rem 1rem 3rem; }
  .grid { grid-template-columns: 1fr; }
  .progress-row { grid-template-columns: 45px 1fr auto; font-size: .82rem; }
}
