:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --paper-strong: #fffdf8;
  --ink: #14201d;
  --muted: #63706b;
  --line: #d9d5ca;
  --green: #123d35;
  --green-2: #1d5b4e;
  --mint: #dceae3;
  --amber: #b86f22;
  --red: #a24035;
  --blue: #37647b;
  --shadow: 0 12px 30px rgba(30, 45, 39, 0.08);
  --radius: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121816;
  --paper-strong: #19211e;
  --ink: #eef3ef;
  --muted: #a9b6b0;
  --line: #33413b;
  --green: #b9dfd1;
  --green-2: #92c7b5;
  --mint: #243b33;
  --amber: #e7a75d;
  --red: #ef8f82;
  --blue: #82b6d0;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button, select { min-height: 44px; }
button { cursor: pointer; }
a { color: var(--green-2); text-underline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero {
  background:
    radial-gradient(circle at 88% 15%, rgba(255, 255, 255, 0.13) 0 2px, transparent 3px),
    linear-gradient(145deg, #0d302a, #195044);
  color: #f7fbf8;
  padding: max(28px, env(safe-area-inset-top)) 20px 30px;
}

.hero__inner, main, .site-footer {
  width: min(100%, 880px);
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 9px;
  color: #b9d9cf;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.hero h1 { margin: 0; font-size: clamp(2rem, 9vw, 3.6rem); line-height: 1.05; letter-spacing: -0.045em; }
.hero__lead { margin: 12px 0 0; color: #d7e8e2; font-weight: 650; }
.hero__stats { margin-top: 23px; color: #cee1da; font-size: 0.82rem; }

.icon-button {
  flex: 0 0 auto;
  width: 46px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: white;
  font-size: 1.2rem;
}

main { padding: 0 16px 52px; }

.control-panel {
  position: sticky;
  z-index: 10;
  top: 8px;
  margin-top: -14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper-strong) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--mint);
}

.mode-tab {
  min-height: 40px;
  padding: 5px 7px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.mode-tab.is-active { background: var(--paper-strong); color: var(--green); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-top: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-strong);
}

.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: var(--muted); }

.filters { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 8px; margin-top: 9px; }
.filters label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 0.65rem; font-weight: 800; }
.filters select { width: 100%; padding: 0 28px 0 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong); color: var(--ink); font-size: 0.78rem; }

.control-panel__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.control-panel__footer p { margin: 0; color: var(--muted); font-size: 0.77rem; }
.text-button { border: 0; background: transparent; color: var(--green-2); font-size: 0.78rem; font-weight: 800; }

.legend { display: flex; justify-content: space-between; gap: 20px; margin: 25px 4px 14px; }
.legend p { margin: 0; max-width: 540px; font-size: 0.83rem; color: var(--muted); }
.legend__badges { display: flex; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; gap: 6px 10px; color: var(--muted); font-size: 0.7rem; white-space: nowrap; }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; }
.dot--s { background: var(--red); }
.dot--a { background: var(--amber); }
.dot--b { background: var(--blue); }

.card-list { display: grid; gap: 12px; }

.study-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 5px solid var(--priority-color, var(--line));
  border-radius: var(--radius);
  background: var(--paper-strong);
  box-shadow: 0 6px 20px rgba(32, 45, 40, 0.045);
}

.study-card[data-priority="S"] { --priority-color: var(--red); }
.study-card[data-priority="A"] { --priority-color: var(--amber); }
.study-card[data-priority="B"] { --priority-color: var(--blue); }
.study-card[data-priority="HOLD"] { --priority-color: var(--muted); opacity: .9; }
.study-card[open] { box-shadow: var(--shadow); }
.study-card summary { padding: 17px 17px 12px; list-style: none; cursor: pointer; }
.study-card summary::-webkit-details-marker { display: none; }

.card-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.card-meta span { padding: 2px 7px; border-radius: 999px; font-size: 0.62rem; line-height: 1.5; font-weight: 850; letter-spacing: .02em; }
.subject-chip { background: var(--green); color: var(--paper-strong); }
[data-theme="dark"] .subject-chip { background: #31574c; color: #f5fbf7; }
.priority-chip, .category-chip { border: 1px solid var(--line); color: var(--muted); }
.reviewed-chip { margin-left: auto; background: var(--mint); color: var(--green); }

.card-title { margin: 0; font-size: clamp(1.16rem, 5vw, 1.45rem); line-height: 1.35; letter-spacing: -.02em; }
.card-summary { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.recall-box { margin-top: 13px; padding: 11px 12px; border-radius: 11px; background: var(--mint); }
.recall-box > span, .mnemonic-block > span { display: block; color: var(--green-2); font-size: .64rem; font-weight: 900; letter-spacing: .08em; }
.recall-box p, .mnemonic-block p { margin: 3px 0 0; font-size: .94rem; line-height: 1.55; }

.open-hint { display: flex; align-items: center; justify-content: space-between; margin: 10px 1px 0; color: var(--muted); font-size: .7rem; font-weight: 800; }
.open-hint b { font-size: 1.15rem; transition: transform .18s ease; }
.study-card[open] .open-hint b { transform: rotate(45deg); }

.card-detail { padding: 0 17px 18px; border-top: 1px solid var(--line); }
.mnemonic-block { margin: 15px 0; padding: 12px 13px; border-left: 3px solid var(--green-2); background: color-mix(in srgb, var(--mint) 54%, transparent); }
.card-detail dl { margin: 0; }
.card-detail dl > div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-detail dt { color: var(--muted); font-size: .72rem; font-weight: 850; }
.card-detail dd { margin: 0; font-size: .84rem; overflow-wrap: anywhere; }
.trap-row dd { color: var(--red); font-weight: 650; }

.weak-button { width: 100%; margin-top: 14px; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: var(--ink); font-size: .82rem; font-weight: 800; }
.weak-button[aria-pressed="true"] { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }

.empty-state { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty-state__mark { margin: 0; font-size: 2.6rem; }
.empty-state h2 { margin: 4px 0; color: var(--ink); }
.empty-state p { margin: 4px; }

.site-footer { padding: 0 20px max(30px, env(safe-area-inset-bottom)); color: var(--muted); font-size: .72rem; }
.site-footer p { margin: 3px 0; }

@media (max-width: 620px) {
  .hero { padding-inline: 18px; }
  main { padding-inline: 10px; }
  .control-panel { top: 4px; padding: 9px; border-radius: 15px; }
  .mode-tab { font-size: .66rem; padding-inline: 2px; }
  .filters { grid-template-columns: 1.2fr 1fr 1fr; gap: 5px; }
  .filters label > span { display: none; }
  .filters select { min-height: 40px; font-size: .7rem; padding-left: 7px; }
  .legend { display: block; margin: 20px 4px 11px; }
  .legend__badges { display: none; }
  .card-detail dl > div { display: block; }
  .card-detail dt { margin-bottom: 3px; }
  .english-row:has(dd:empty) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

@media print {
  .hero, .control-panel, .legend, .site-footer, .weak-button { display: none; }
  body { background: white; color: black; }
  main { width: 100%; padding: 0; }
  .study-card { break-inside: avoid; box-shadow: none; }
  .card-detail { display: block; }
}
