:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #d9dde7;
  --accent: #3b82f6;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #181b24;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #2a2f3d;
  --accent: #60a5fa;
  --accent-text: #0b1020;
  --danger: #f87171;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { margin: 0; font-size: 1.4rem; }

nav { display: flex; flex-direction: column; gap: 0.25rem; }

.nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--accent); color: var(--accent-text); }

.content {
  padding: 2rem;
  max-width: 820px;
  width: 100%;
}

.tool {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.tool h2 { margin: 0; }
.tool h3 { margin: 0.5rem 0 0; font-size: 1rem; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  width: 100%;
}
input[type="checkbox"], input[type="range"], input[type="color"] { width: auto; }
input[type="color"] { height: 42px; width: 64px; padding: 2px; }
input[type="number"] { width: 110px; }
textarea { resize: vertical; }

input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--text); }
.checks label { flex-direction: row; align-items: center; gap: 0.4rem; }

.row { display: flex; gap: 0.5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row input[type="text"], .row input[type="number"], .row select { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.btn {
  font: inherit;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }
.error { color: var(--danger); margin: 0; min-height: 1.2em; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

.result {
  font-size: 1.6rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  min-height: 2.2rem;
  word-break: break-all;
}

.output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0;
  max-height: 400px;
  overflow: auto;
  white-space: pre-wrap;
}

.stats { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.stats strong { color: var(--text); font-size: 1.1rem; }

.swatch {
  flex: 1;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.display {
  font-size: 2.4rem;
  text-align: center;
  padding: 0.5rem;
}

.laps { margin: 0; padding-left: 1.5rem; max-height: 180px; overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace; }

#pw-output { font-size: 1.1rem; }

/* ---------- Sidebar with 100 tools ---------- */
.sidebar { min-height: 0; }
.sidebar nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  gap: 0.1rem;
}
.sidebar input[type="search"] { width: 100%; }
.brand-link { color: inherit; text-decoration: none; }
.nav-link { font-size: 0.92rem; padding: 0.35rem 0.75rem; }
.nav-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 0.75rem;
  padding: 0 0.75rem;
}

/* ---------- Home grid ---------- */
.cat-title {
  margin: 1.75rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
@media (max-width: 900px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .cards { grid-template-columns: 1fr; } }
.card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card .hint { font-size: 0.85rem; }

/* ---------- Tool forms ---------- */
.tool-body { display: flex; flex-direction: column; gap: 0.9rem; }
.tool-about {
  border-left: 3px solid var(--accent);
  padding: 0.1rem 0 0.1rem 0.9rem;
}
.tool-about h3 { margin: 0 0 0.3rem; }
.tool-about p { margin: 0; line-height: 1.6; }
.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
}
.form label:has(textarea) { grid-column: 1 / -1; }
.form label.check {
  flex-direction: row;
  align-items: center;
  color: var(--text);
}
.form label.check input { width: auto; }
.output-box { min-height: 6rem; white-space: pre-wrap; }

/* ---------- Modern home page ---------- */
.content { max-width: 1080px; }

.home-head { margin-bottom: 1.25rem; }
.home-title {
  font-size: 2rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}
.gradient-text {
  background: linear-gradient(90deg, #6366f1, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Slideshow */
.hero {
  position: relative;
  height: 320px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 18px 40px -18px rgba(79, 70, 229, 0.55);
  color: #fff;
}
.hero:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.slides { position: absolute; inset: 0; }
.slide {
  position: absolute;
  inset: 0;
  background: var(--grad);
  padding: 2.75rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.8rem;
  opacity: 0;
  transform: translateX(32px) scale(0.99);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}
.slide::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  right: -90px;
  top: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 70%);
  pointer-events: none;
}
.slide.is-active { opacity: 1; transform: none; pointer-events: auto; }
.slide-kicker {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}
.slide-title { margin: 0; font-size: 2.2rem; line-height: 1.15; max-width: 26ch; letter-spacing: -0.02em; }
.slide-text { margin: 0; font-size: 1.05rem; opacity: 0.92; max-width: 52ch; }
.slide-cta {
  align-self: flex-start;
  margin-top: 0.4rem;
  background: #fff;
  color: #111827;
  text-decoration: none;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
.slide-cta:hover { transform: translateY(-1px); }

.slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.25);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  z-index: 2;
}
.slide-nav:hover { background: rgba(15, 23, 42, 0.45); }
.slide-nav.prev { left: 1rem; }
.slide-nav.next { right: 1rem; }

.dots {
  position: absolute;
  bottom: 1rem;
  left: 3.5rem;
  display: flex;
  gap: 0.45rem;
  z-index: 2;
}
.dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease;
}
.dot.is-active { width: 26px; background: #fff; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0 1.5rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
}
.stat strong { font-size: 1.7rem; letter-spacing: -0.02em; }

/* Home page: no sidebar, with its own top bar */
.is-home .layout { grid-template-columns: 1fr; }
.is-home .sidebar { display: none; }
.is-home .content { margin: 0 auto; padding-top: 1.25rem; }
.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.home-topbar .brand-link { font-size: 1.3rem; font-weight: 750; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.topbar-actions .btn { padding: 0.4rem 0.9rem; }

/* Disclaimer page */
.legal { max-width: 760px; }
.legal-section { display: flex; flex-direction: column; gap: 0.35rem; }
.legal-section h3 { margin: 0.5rem 0 0; font-size: 1.05rem; }
.legal-section p { margin: 0; line-height: 1.6; }
.legal p { line-height: 1.6; }
.legal a { color: var(--accent); }

/* Featured spotlight cards (home page) */
.spotlight {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.spot {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 190px;
  padding: 1.1rem 1.15rem;
  border-radius: 16px;
  color: var(--text);
  text-decoration: none;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 35%, transparent)) border-box;
  border: 2px solid transparent;
  box-shadow: 0 10px 26px -18px color-mix(in srgb, var(--c) 80%, transparent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.spot:hover { transform: translateY(-3px); box-shadow: 0 16px 32px -16px color-mix(in srgb, var(--c) 85%, transparent); }
.spot-badge {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--c);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  margin-bottom: 0.3rem;
}
.spot-name { font-size: 1.05rem; line-height: 1.25; }
.spot .hint { font-size: 0.85rem; }
.spot .card-arrow { opacity: 1; transform: none; margin-top: auto; }
@media (max-width: 900px) { .spotlight { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .spotlight { grid-template-columns: 1fr; } }

/* Section headers and page links */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 0.7rem;
}
.section-head .cat-title { margin: 0; }
.link-more { color: var(--accent); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.link-more:hover { text-decoration: underline; }
.home-link { font-weight: 600; }

/* Category pills */
.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.pill {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill:hover { border-color: var(--c); }
.pill.is-active { background: var(--c); border-color: var(--c); color: #fff; }

/* Category groups & cards */
.groups { display: flex; flex-direction: column; gap: 0.5rem; }
.group { --c: #6366f1; }
.cat-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.5rem 0 0.7rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
}
.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent);
}
.cat-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
}
.card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem 0.9rem 1.3rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--c);
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--c);
  box-shadow: 0 14px 28px -16px color-mix(in srgb, var(--c) 70%, transparent);
}
.card-cat {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c);
}
.card-name { font-size: 1rem; margin: 0.2rem 0 0.25rem; }
.card .hint { font-size: 0.85rem; }
.card-arrow {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.18s ease;
}
.card:hover .card-arrow { opacity: 1; transform: none; }

/* ---------- Interactive tools (productivity) ---------- */
.todo, .habits { width: 100%; border-collapse: collapse; }
.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.todo li { display: flex; align-items: center; gap: 0.6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.7rem; }
.todo li span { flex: 1; }
.habits th, .habits td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); text-align: center; font-size: 0.9rem; }
.habits th:first-child, .habits td:first-child { text-align: left; }
.habits input[type="checkbox"] { width: 18px; height: 18px; }
.reaction-box {
  height: 180px;
  width: 100%;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}
.reaction-box.red { background: #dc2626; color: #fff; }
.reaction-box.green { background: #16a34a; color: #fff; }
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.team { display: flex; flex-direction: column; gap: 0.5rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; }
.flashcard {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.25rem;
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 1rem;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.preview { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; overflow: auto; min-height: 200px; }
.preview h1, .preview h2, .preview h3 { margin-top: 0.2rem; }
.preview code { background: var(--panel); padding: 0.1rem 0.3rem; border-radius: 4px; }
.typing-target { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; line-height: 1.8; font-size: 1.05rem; }
.typing-target .ok { color: #16a34a; }
.typing-target .bad { color: #dc2626; background: rgba(220, 38, 38, 0.12); }
@media (max-width: 720px) {
  .split, .scoreboard { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .hero { height: 360px; }
  .slide { padding: 2.25rem 1.5rem 3.5rem; }
  .slide-title { font-size: 1.6rem; }
  .dots { left: 1.5rem; }
  .slide-nav { display: none; }
  .stats-row { grid-template-columns: 1fr 1fr 1fr; }
  .stat strong { font-size: 1.2rem; }
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  nav { flex-direction: column; max-height: 45vh; }
  .content { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Modern footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 6%, transparent));
  padding: 2rem 2rem 1.25rem;
}
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}
.footer-brand { display: flex; flex-direction: column; gap: 0.35rem; max-width: 380px; }
.footer-title { font-size: 1.1rem; font-weight: 750; letter-spacing: -0.01em; }
.footer-brand .hint { font-size: 0.88rem; line-height: 1.5; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; }
.footer-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s ease;
}
.footer-links a:hover { color: var(--accent); }
.footer-top {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.footer-top:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.footer-copy {
  max-width: 1080px;
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}
@media (max-width: 720px) {
  .site-footer { padding: 1.5rem 1rem 1rem; }
  .footer-inner { flex-direction: column; }
}

/* ---------- Home top bar: search and icon theme toggle ---------- */
.home-search { flex: 1; max-width: 420px; margin: 0 auto; }
.home-search input { margin: 0; }
.theme-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
}
.theme-icon-btn svg { width: 18px; height: 18px; display: block; }
.theme-icon-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-icon-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-icon-btn .icon-moon { display: none; }
@media (max-width: 720px) {
  .home-topbar { flex-wrap: wrap; }
  .home-search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
}
