:root {
  color-scheme: light;
  --bg: #F8FAFC;
  --surface: #ffffff;
  --line: #dbeafe;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --accent: #F59E0B;
  --good: #22C55E;
  --bad: #bd3d3d;
  --warn: #F59E0B;
  --shadow: 0 14px 26px rgba(37, 99, 235, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.24), transparent 28rem),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.18), transparent 32rem),
    linear-gradient(180deg, #eff6ff 0%, var(--bg) 42%);
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Sans", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 32px) 36px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 78px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.45rem;
}

.hidden {
  display: none !important;
}

.icon-button {
  width: 50px;
  height: 50px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.screen {
  display: grid;
  gap: 18px;
}

.hero-panel,
.panel {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 28px);
}

.large-copy {
  margin: 0 0 10px;
  font-size: clamp(1.25rem, 3.4vw, 2rem);
  color: var(--primary-dark);
  font-weight: 900;
  line-height: 1.45;
}

.small-copy,
.muted {
  color: var(--muted);
  line-height: 1.7;
}

.small-copy {
  margin: 0;
}

.storage-status {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: fit-content;
  margin-top: 14px;
  padding: 9px 12px;
  border: 2px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary-dark);
  font-weight: 850;
}

.storage-status span {
  color: var(--muted);
  font-size: 0.92rem;
}

.storage-status.temporary,
.warning-panel {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.home-menu-section {
  display: grid;
  gap: 14px;
  padding: clamp(18px, 4vw, 26px);
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-menu-section h2 {
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}

.admin-menu {
  background: #eef6ff;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.menu-card {
  display: grid;
  gap: 8px;
  min-height: 72px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.menu-card:hover {
  border-color: var(--primary);
  box-shadow: 0 18px 32px rgba(37, 99, 235, 0.18);
  transform: translateY(-2px);
}

.study-card {
  min-height: 148px;
  padding: 20px;
  font-size: 1.2rem;
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

.admin-card {
  background: #fbfdff;
}

.menu-card strong {
  font-size: 1.28rem;
}

.study-card strong {
  font-size: 1.38rem;
}

.menu-card span:last-child {
  color: var(--muted);
  line-height: 1.5;
}

.menu-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #dbeafe;
  color: var(--primary-dark);
  font-size: 1.35rem;
  font-weight: 900;
}

.kanji-icon {
  font-family: "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-weight: 400;
}

.quest-status-panel {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 4vw, 26px);
  border: 2px solid #bfdbfe;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 58%, #fef3c7 100%);
  box-shadow: var(--shadow);
}

.quest-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 850;
}

.danger-badge {
  background: #fee2e2;
  color: #991b1b;
}

.quest-progress-section {
  display: grid;
  gap: 12px;
}

.quest-progress-section h3 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.25rem;
}

.compact-section-header {
  margin-bottom: 0;
}

.quest-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.quest-status-card {
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 2px solid currentColor;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
}

.quest-status-card strong {
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.25;
}

.quest-status-card b,
.quest-status-card em,
.quest-term {
  font-weight: 850;
}

.quest-status-card em {
  color: var(--muted);
  font-style: normal;
}

.question-quest-card {
  color: var(--primary);
}

.quest-mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 750;
}

.quest-mini-stats span {
  padding: 6px 8px;
  border-radius: 10px;
  background: #f8fafc;
}

.quest-progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.quest-progress-track div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--good));
}

.toolbar,
.button-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button-row {
  margin-top: 16px;
}

.export-actions button {
  flex: 1 1 240px;
}

.primary-button,
.secondary-button,
.result-button,
.danger-button {
  min-height: 52px;
  border-radius: 8px;
  border: 2px solid transparent;
  padding: 0 18px;
  font-size: 1.08rem;
  font-weight: 850;
}

.primary-button {
  background: var(--primary);
  color: white;
}

.secondary-button {
  background: var(--surface);
  color: var(--primary-dark);
  border-color: var(--primary);
}

.danger-button {
  background: #fff1f1;
  color: var(--bad);
  border-color: #f1bbbb;
}

.compact-button {
  min-height: 42px;
  padding: 0 14px;
  font-size: 0.98rem;
}

.count-badge {
  min-width: 76px;
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
  font-size: 1.1rem;
}

.result-button.correct {
  background: #dcfce7;
  color: var(--good);
  border-color: #86efac;
}

.result-button.wrong {
  background: #fff0f0;
  color: var(--bad);
  border-color: #f0a8a8;
}

.result-button.unsure {
  background: #fffbeb;
  color: var(--warn);
  border-color: #fcd34d;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.top-actions {
  margin: 0 0 18px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.full {
  grid-column: 1 / -1;
}

label {
  color: var(--primary-dark);
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1.05rem;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.bulk-textarea {
  min-height: 180px;
}

.bulk-result {
  margin-top: 14px;
  font-weight: 850;
}

.preview-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.preview-table {
  display: grid;
  min-width: 860px;
  gap: 6px;
}

.preview-row {
  display: grid;
  grid-template-columns: 64px minmax(240px, 1fr) 120px 100px 120px minmax(150px, 0.8fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
}

.preview-head {
  background: #eef8f9;
  color: var(--primary-dark);
  font-weight: 900;
}

.preview-row.has-error {
  border-color: #f0a8a8;
  background: #fff7f7;
}

.reading-csv-panel {
  margin: 16px 0;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.reading-preview-table {
  display: grid;
  min-width: 780px;
  gap: 6px;
}

.reading-preview-row {
  display: grid;
  grid-template-columns: 80px 150px 180px 90px 100px minmax(160px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
}

.reading-preview-row.has-error {
  border-color: #f0a8a8;
  background: #fff7f7;
}

.license-note {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
}

.list-item strong {
  font-size: 1.12rem;
}

.kanji-bulk-toolbar {
  margin: 16px 0;
}

.inline-label {
  min-width: fit-content;
}

.kanji-table-wrap {
  overflow-x: auto;
}

.kanji-table {
  display: grid;
  min-width: 1040px;
  gap: 6px;
}

.kanji-table-row {
  display: grid;
  grid-template-columns: 66px 72px 70px 72px 100px 130px 150px minmax(180px, 1fr) 92px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: white;
}

.kanji-table-head {
  background: #eef8f9;
  color: var(--primary-dark);
  font-weight: 900;
}

.kanji-table-char,
.readonly-kanji {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid currentColor;
  border-radius: 12px;
  background: white;
  font-size: 1.45rem;
  font-family: "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-weight: 400;
}

.readonly-kanji {
  width: 70px;
  height: 70px;
  font-size: 2.3rem;
}

.kanji-select {
  width: 24px;
  min-height: 24px;
}

.term-choice-grid,
.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

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

.term-choice,
.progress-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

.term-choice {
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 14px;
  text-align: left;
}

.term-choice strong {
  font-size: 1.24rem;
}

.term-choice span {
  color: var(--muted);
  line-height: 1.4;
}

.progress-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.progress-card span,
.progress-card b {
  font-weight: 850;
}

.progress-card strong {
  font-size: 1.7rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(37, 49, 59, 0.12);
}

.progress-track div {
  height: 100%;
  border-radius: inherit;
  background: currentColor;
}

.kanji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kanji-study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
}

.kanji-study-card {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 86px;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: white;
}

.kanji-study-card strong {
  font-size: 2rem;
  line-height: 1;
  font-family: "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-weight: 400;
}

.kanji-study-card span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.kanji-chip {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid currentColor;
  border-radius: 12px;
  background: white;
  font-size: 1.35rem;
  font-family: "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-weight: 400;
}

.term-list {
  display: grid;
  gap: 18px;
}

.term-heading {
  margin: 0 0 9px;
  font-size: 1.1rem;
}

.term-1 {
  color: #176bba;
}

.term-2 {
  color: #c46615;
}

.term-3 {
  color: #20845a;
}

.term-none {
  color: var(--muted);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-button {
  min-height: 70px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  text-align: left;
  font-weight: 850;
}

.question-card {
  display: grid;
  gap: 18px;
  min-height: 300px;
  place-items: center;
  text-align: center;
}

.combo-banner {
  justify-self: center;
  padding: 10px 18px;
  border: 2px solid #fcd34d;
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 950;
}

.progress {
  justify-self: stretch;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.question-text {
  font-size: clamp(2rem, 8vw, 4.3rem);
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.prompt-block {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: min(560px, 100%);
  line-height: 1.5;
}

.prompt-block p,
.prompt-block span {
  margin: 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 800;
}

.prompt-block .prompt-title {
  color: var(--text);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 950;
}

.prompt-block strong {
  color: var(--primary-dark);
  font-size: clamp(2.4rem, 9vw, 4.8rem);
  line-height: 1.1;
}

.answer-box {
  min-height: 76px;
  padding: 12px 20px;
  border-radius: 8px;
  background: #eef8f9;
  color: var(--primary-dark);
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  font-weight: 950;
}

.answer-box small {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

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

.kanji-result-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  padding: 14px;
  border-radius: 8px;
  background: white;
  border: 2px solid var(--line);
}

.stat strong {
  display: block;
  font-size: 1.6rem;
}

.error {
  color: var(--bad);
  font-weight: 850;
}

@media (max-width: 760px) {
  .home-grid,
  .quest-status-grid,
  .question-quest-grid,
  .term-choice-grid,
  .progress-grid,
  .choice-grid,
  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .menu-card {
    min-height: 96px;
  }

  .primary-button,
  .secondary-button,
  .result-button,
  .danger-button {
    width: 100%;
  }
}
