:root {
  --bg: #0f1419;
  --bg-elevated: #161d27;
  --surface: #1c2533;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8edf5;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #475569;
  --shadow: 0 10px 35px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(900px 500px at 90% 0%, rgba(167, 139, 250, 0.12), transparent), var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

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

img {
  max-width: 100%;
  height: auto;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.25rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  background: linear-gradient(180deg, var(--bg-elevated), transparent);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem 1rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #0b1220;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.65rem;
  min-height: 44px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

.nav a:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--border);
}

.nav a.active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
}

.main {
  padding: 1.25rem clamp(1rem, 3vw, 2rem) 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
  max-width: 1100px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.motivation {
  font-size: 0.95rem;
  color: var(--muted);
}
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.08s ease, box-shadow 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.35);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(167, 139, 250, 0.22));
  border-color: rgba(56, 189, 248, 0.45);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin-top: 0;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat strong {
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.stat small {
  color: var(--muted);
}
.hero {
  padding: 2rem 0 1rem;
}

.hero h2 {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.03em;
}

.hero p.lead {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 62ch;
  margin: 0 0 1.25rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.85rem;
}
details.note-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

details.note-section > summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 650;
  list-style: none;
}

details.note-section > summary::-webkit-details-marker {
  display: none;
}

details.note-section[open] > summary {
  border-bottom: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.06);
}

.note-body {
  padding: 0.95rem 1rem 1.1rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hl {
  color: var(--text);
  font-weight: 600;
  background: linear-gradient(transparent 60%, rgba(56, 189, 248, 0.22) 0);
  padding: 0 0.1em;
}

ul.clean {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}
.fc-wrap {
  perspective: 1200px;
}

.fc-card {
  width: min(100%, 720px);
  min-height: 220px;
  margin: 0 auto;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
}

.fc-card.is-flipped {
  transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.08), var(--surface));
  padding: 1.25rem;
  display: grid;
  place-items: center;
  text-align: center;
}

.fc-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.1), var(--surface));
}

.fc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}
.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.timer {
  font-family: var(--mono);
  font-size: 1.1rem;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.options {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.option {
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 0.85rem;
  min-height: 44px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
  touch-action: manipulation;
}

.option:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.option.correct {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(52, 211, 153, 0.12);
}

.option.wrong {
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(248, 113, 113, 0.1);
}

.option.selected {
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(56, 189, 248, 0.12);
}

.option:disabled {
  cursor: default;
  opacity: 0.95;
}

.feedback {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.06);
}

.feedback.bad {
  background: rgba(248, 113, 113, 0.08);
}
.checklist label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.checklist input {
  margin-top: 0.2rem;
}
.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 820px) {
  .match-board {
    grid-template-columns: 1fr;
  }
}

.match-col h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tile {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.tile:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.tile.selected {
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(56, 189, 248, 0.1);
}
.match-board .tile.selected:not(.matched) {
  outline: 2px solid rgba(56, 189, 248, 0.45);
}

.tile.matched {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.1);
  cursor: default;
}
.pomo {
  display: grid;
  gap: 0.65rem;
}

.pomo-display {
  font-family: var(--mono);
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: 0.06em;
}

.pomo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}
.site-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.inp-caps::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.enum-found li {
  margin: 0.2rem 0;
}

html.site-locked body {
  overflow: hidden;
}

.site-gate {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  background: rgba(10, 14, 20, 0.94);
  backdrop-filter: blur(10px);
}

html[data-theme='light'] .site-gate {
  background: rgba(244, 246, 251, 0.97);
}

.site-gate-card {
  width: 100%;
  max-width: 400px;
}

.site-gate-label {
  font-size: 0.88rem;
  color: var(--muted);
}

.site-gate-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.nav-toggle {
  display: none;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: max(0.65rem, env(safe-area-inset-top));
    left: max(0.65rem, env(safe-area-inset-left));
    z-index: 10002;
    min-height: 44px;
    min-width: 44px;
    padding: 0 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 650;
    box-shadow: var(--shadow);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.52);
    -webkit-tap-highlight-color: transparent;
  }

  .nav-backdrop.is-open {
    display: block;
  }

  body.nav-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(292px, 88vw);
    z-index: 10001;
    min-height: 100dvh;
    align-self: stretch;
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    border-right: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .main {
    padding-top: max(4.25rem, calc(env(safe-area-inset-top) + 3.25rem));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .btn {
    min-height: 44px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .tile {
    min-height: 44px;
    padding: 0.75rem 0.85rem;
    touch-action: manipulation;
  }

  input:not([type='checkbox']):not([type='radio']),
  textarea,
  select {
    font-size: 16px;
    max-width: 100%;
  }

  .fc-card {
    min-height: 200px;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions .btn {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
  }
}
