/* TeachKit — shared stylesheet. Pure CSS, no dependencies. */
:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #1a2333;
  --muted: #5b6b84;
  --line: #dfe7f0;
  --primary: #1f6feb;
  --primary-dark: #1859c4;
  --primary-soft: #e3edfd;
  --accent: #0e9f6e;
  --warn: #c2410c;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 40, 80, 0.08);
  --shadow-lg: 0 10px 30px rgba(20, 40, 80, 0.14);
  --header-h: 64px;
}
[data-theme="dark"] {
  --bg: #0f1522;
  --surface: #182033;
  --surface-2: #111a2c;
  --text: #e8eef7;
  --muted: #9fb0c9;
  --line: #2a3852;
  --primary: #5b9dff;
  --primary-dark: #7db3ff;
  --primary-soft: #1c2c4d;
  --accent: #34d399;
  --warn: #fb923c;
  --danger: #f87171;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
main { min-height: calc(100vh - var(--header-h) - 180px); }

/* Accessibility */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--primary); color: #fff; padding: 10px 16px; z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface); border-bottom: 1px solid var(--line);
  height: var(--header-h);
}
.header-inner {
  display: flex; align-items: center; gap: 20px; height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.25rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 32px; height: 32px; }
.main-nav { display: flex; gap: 4px; margin-left: 8px; }
.main-nav a {
  color: var(--muted); font-weight: 600; padding: 8px 12px; border-radius: 8px;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.main-nav a.active { color: var(--primary); background: var(--primary-soft); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 13px; font-size: 0.85rem; font-weight: 700; cursor: pointer;
}
.lang-switch button.active { background: var(--primary); color: #fff; }

.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 20px; height: 20px; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun, :root:not([data-theme]) .icon-sun { display: none; }

/* Hero */
.hero { text-align: center; padding: 72px 20px 48px; }
.hero-badge {
  display: inline-block; background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: 0.85rem; padding: 6px 14px; border-radius: 999px; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin: 0 0 12px; letter-spacing: -0.02em; }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }

.search-box { max-width: 480px; margin: 0 auto; position: relative; }
.search-box input {
  width: 100%; padding: 14px 18px 14px 46px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
}
.search-box input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }

/* Cards */
.section-title { font-size: 1.6rem; margin: 8px 0 20px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; padding-bottom: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-icon {
  width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
}
.card-icon svg { width: 28px; height: 28px; color: var(--primary); }
.card h3 { margin: 0; font-size: 1.25rem; }
.card p { margin: 0; color: var(--muted); flex: 1; }
.card .card-link { font-weight: 700; margin-top: 6px; }
.no-results { color: var(--muted); padding: 24px; text-align: center; }

/* Why section */
.why { padding: 48px 0 64px; }
.why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.why-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.why-item h3 { margin: 0 0 8px; font-size: 1.1rem; }
.why-item p { margin: 0; color: var(--muted); }

/* Tool pages */
.tool-hero { padding: 44px 0 8px; }
.tool-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 8px; }
.tool-hero .lead { color: var(--muted); font-size: 1.1rem; margin: 0 0 8px; }

.tool-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; margin: 20px 0;
}
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; }
.field .hint { font-size: 0.9rem; color: var(--muted); margin-top: 6px; }
textarea, input[type="text"], input[type="number"] {
  width: 100%; padding: 12px 14px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
textarea:focus, input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea { min-height: 140px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font-size: 1rem; font-weight: 700; padding: 12px 22px; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.btn-large { font-size: 1.15rem; padding: 16px 34px; }

.checkline { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; cursor: pointer; font-weight: 600; }
.checkline input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }

.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.radio-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.result-display {
  margin-top: 20px; padding: 30px 20px; border-radius: var(--radius);
  background: var(--surface-2); border: 2px dashed var(--line);
  text-align: center; min-height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.result-label { font-size: 0.9rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.result-value { font-size: clamp(2.4rem, 7vw, 4rem); font-weight: 800; line-height: 1.2; word-break: break-word; }
.result-meta { color: var(--muted); font-size: 0.95rem; }
.notice { margin-top: 12px; padding: 12px 16px; border-radius: 10px; font-weight: 600; }
.notice-error { background: rgba(220, 38, 38, 0.1); color: var(--danger); border: 1px solid var(--danger); }
.notice-info { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary); }
[data-theme="dark"] .notice-info { color: var(--primary-dark); }

/* Groups output */
.groups-output { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.group-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.group-card h3 { margin: 0 0 10px; font-size: 1.05rem; color: var(--primary); }
.group-card ul { margin: 0; padding-left: 20px; }
.group-card li { margin: 4px 0; }

/* Timer */
.timer-display {
  font-size: clamp(4rem, 16vw, 8rem); font-weight: 800; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em; line-height: 1.1;
  padding: 20px 0;
}
.timer-display.finished { color: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.preset-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.preset-row .btn { padding: 10px 18px; }
.custom-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.custom-row .field { margin-bottom: 0; flex: 1; min-width: 120px; }

/* Dice & coin */
.chance-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 8px; }
.chance-box { text-align: center; padding: 26px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.chance-box h3 { margin: 0 0 14px; font-size: 1.05rem; color: var(--muted); }
.die {
  width: 120px; height: 120px; margin: 0 auto 16px; background: var(--surface);
  border: 2px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 18px;
}
.pip { width: 70%; aspect-ratio: 1; border-radius: 50%; background: var(--text); place-self: center; opacity: 0; }
.pip.on { opacity: 1; }
.coin {
  width: 120px; height: 120px; margin: 0 auto 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--primary-soft), var(--surface));
  border: 3px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: var(--primary);
}
.coin.flipping { animation: flip 0.6s ease; }
@keyframes flip { 50% { transform: rotateY(90deg) scale(0.9); } }
.die.rolling { animation: shake 0.4s ease; }
@keyframes shake {
  25% { transform: rotate(-8deg) translateY(-4px); }
  75% { transform: rotate(8deg) translateY(2px); }
}

/* Guidance */
.guide {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; margin: 8px 0 56px;
}
.guide h2 { margin-top: 0; }
.guide h3 { margin: 22px 0 8px; }
.guide ol, .guide ul { margin: 8px 0; padding-left: 22px; }
.guide li { margin: 6px 0; }

/* Content pages */
.content { max-width: 760px; padding: 44px 20px 64px; }
.content h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0 0 10px; }
.content .updated { color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; }
.content h2 { margin: 32px 0 10px; font-size: 1.3rem; }
.contact-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; margin-top: 24px; text-align: center;
}
.contact-card .email-link { font-size: 1.25rem; font-weight: 800; word-break: break-all; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 36px 0 28px; margin-top: 24px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; justify-content: space-between; }
.footer-brand { font-weight: 800; font-size: 1.1rem; margin-bottom: 6px; }
.footer-tag { color: var(--muted); font-size: 0.95rem; margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.footer-links a:hover { color: var(--text); }
.footer-bottom { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

/* Breadcrumb-ish back link */
.back-link { display: inline-block; margin-top: 20px; font-weight: 600; }

/* Responsive */
@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .why-grid { grid-template-columns: 1fr; }
  .chance-row { grid-template-columns: 1fr; }
  .main-nav { display: none; }
  .hero { padding: 48px 20px 36px; }
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
