:root {
  --paper: #f4efe4;
  --ink: #2c2a26;
  --muted: #6d675c;
  --teal: #2a6f6f;
  --teal-dark: #1e4f4f;
  --coral: #e07a3d;
  --green: #3d8b5c;
  --red: #c44536;
  --card: #fffdf8;
  --line: #e4dccb;
  --shadow: 0 10px 30px rgba(44, 42, 38, .08);
  --radius: 22px;
  --font: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(42, 111, 111, .08), transparent 28%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--teal-dark); }
.app-shell {
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}
.theme-parent .app-shell,
.page-wide .app-shell {
  width: min(520px, calc(100% - 32px));
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 253, 248, .9);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
  gap: 8px;
}
.brand { font-weight: 800; text-decoration: none; color: var(--teal-dark); }
.who { color: var(--muted); margin-right: 10px; }
.who em { font-style: normal; font-size: .75rem; margin-right: 8px; padding: 2px 8px; border-radius: 999px; background: #efe8d8; color: var(--teal-dark); font-weight: 700; }
.text-link { color: var(--muted); }
.btn-logout { min-height: 36px; padding: 0 14px; background: #efe8d8; color: var(--ink); font-size: .9rem; }

.auth-card, .hero-card, .panel, .study-card, .result-card, .kid-card, .feedback {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}
.eyebrow { color: var(--teal); font-weight: 700; letter-spacing: .08em; margin: 0 0 8px; }
h1 { margin: 0 0 12px; font-size: 1.7rem; }
.lead, .hint, .center-note, .empty, .done-note { color: var(--muted); }
.center-note { text-align: center; }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--coral); color: #fff; }
.btn-secondary { background: #efe8d8; color: var(--ink); }
.btn-xl { width: 100%; min-height: 56px; font-size: 1.05rem; margin-top: 12px; }

.hello { font-size: 1.4rem; font-weight: 800; margin-top: 0; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-row article, .dash-grid article, .result-grid article {
  background: #f7f3ea;
  border-radius: 16px;
  padding: 12px;
}
.stat-row p, .dash-grid p, .result-grid p { margin: 0; color: var(--muted); font-size: .85rem; }
.stat-row strong, .dash-grid strong, .result-grid strong { font-size: 1.4rem; }
.stat-row em { display: block; font-style: normal; font-weight: 800; color: var(--teal-dark); }
.set-charts { display: grid; gap: 12px; margin: 16px 0; }
.set-chart {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f7f3ea;
  border-radius: 16px;
  padding: 12px;
  width: 100%;
  border: 2px solid transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}
.set-chart-form { margin: 0; }
button.set-chart { cursor: pointer; background: #f7f3ea; }
button.set-chart:hover { border-color: var(--teal); }
.set-chart.is-current { border-color: var(--teal); background: #eef6f3; }
.set-chart .set-name,
.set-chart .set-count { display: block; }
.set-chart .set-name { margin: 0; font-weight: 800; }
.set-chart .set-name em {
  font-style: normal;
  font-size: .75rem;
  color: var(--teal-dark);
  margin-left: 6px;
}
.set-now, .set-reset { margin: 0 0 8px; }
.study-link { margin: 10px 0; }
.study-link-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.study-link-row input {
  flex: 1 1 220px;
  min-width: 0;
  font-size: .85rem;
}
.study-link-reset { margin-top: 10px; }
.set-default-form .check { margin: 10px 0; }
.set-chart .set-count { margin: 2px 0; }
.donut {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 86px;
}
.donut span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--card);
  display: grid;
  place-items: center;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}
.donut small { display: block; font-size: .7rem; color: var(--muted); font-weight: 700; }
.level-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  font-size: .8rem;
}
.level-legend i {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #efe8d8, #d8efe6, #8ecdb8, #3d9a82, #1f5f4a, #16452c);
}
.set-charts.compact .donut { width: 68px; height: 68px; flex-basis: 68px; }
.set-charts.compact .donut span { width: 42px; height: 42px; font-size: .85rem; }
.stat-row span { font-size: .8rem; margin-left: 2px; }
.today-progress { margin: 18px 0; }
.bar { height: 10px; background: #efe8d8; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--teal); }
.count { margin: 8px 0 0; font-weight: 700; }

.term { font-size: 2.4rem; text-align: center; margin: 10px 0 8px; }
.prompt { text-align: center; color: var(--muted); }
.choices { display: grid; gap: 10px; }
.choice {
  font: inherit;
  font-size: 1.1rem;
  padding: 16px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.choice:active { transform: scale(.99); }
.progress-label { text-align: center; color: var(--muted); font-weight: 700; }
.feedback { text-align: center; }
.feedback .mark { font-size: 2rem; font-weight: 800; margin: 0; }
.ok { color: var(--green); }
.ng { color: var(--red); }
.hidden { display: none; }
.fb-term { font-size: 1.5rem; font-weight: 800; margin: 8px 0 0; }
.fb-meaning { font-size: 1.2rem; margin: 4px 0 12px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.result-list { padding: 0; list-style: none; }
.result-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }

.kid-card h2 { margin-top: 0; }
.week-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.week-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.weak-list { list-style: none; padding: 0; }
.weak-list li { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; display: grid; }
.weak-list span, .weak-list em { color: var(--muted); }
.weak-meta { margin: 6px 0 0; color: var(--ink); font-weight: 700; }
.weak-meta em { font-style: normal; font-weight: 700; margin-left: 10px; }

.flash { border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.flash-success { background: #e7f5ec; color: #215c38; }
.flash-error { background: #fdecea; color: #8a2a22; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filter { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.table-wrap { overflow: auto; background: var(--card); border-radius: 16px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { display: inline; }
.row-actions button { background: none; border: 0; color: var(--teal-dark); cursor: pointer; font: inherit; }
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.dash-grid.compact { margin-bottom: 16px; }
.admin-frame { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; width: 100%; }
.admin-nav { background: #1e3a3a; color: #f4efe4; padding: 22px 18px; }
.admin-nav a { color: #f4efe4; text-decoration: none; display: block; padding: 8px 0; }
.admin-nav .brand { color: #fff; display: block; margin-bottom: 18px; }
.admin-main { padding: 24px; min-width: 0; width: 100%; }
.code { background: #1e3a3a; color: #f4efe4; padding: 12px; border-radius: 12px; overflow: auto; }
.card-list { display: grid; gap: 12px; }
.top-nav { display: flex; gap: 14px; flex: 1; margin: 0 16px; }
.top-nav a { color: var(--teal-dark); font-weight: 700; text-decoration: none; }
.set-bar { display: grid; gap: 14px; }
.set-switch, .set-new, .set-activate { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.set-switch label, .set-new label { margin: 0; }
.sheet-tools { display: grid; gap: 16px; }
.sheet-import { display: grid; gap: 12px; }
.sheet-wrap { max-height: 70vh; }
table.sheet th, table.sheet td { padding: 6px; }
table.sheet input, table.sheet select {
  width: 100%;
  min-width: 88px;
  padding: 8px;
  border-radius: 8px;
}
table.sheet input[type="number"] { min-width: 64px; }
.row-clear {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.sheet-actions { margin-top: 16px; }
.result-table td, .result-table th { font-size: .95rem; }

@media (min-width: 900px) {
  .theme-parent .app-shell,
  .page-wide .app-shell {
    width: min(1280px, calc(100% - 48px));
    padding: 24px 0 56px;
  }
  .theme-parent .card-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .theme-parent .home-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
  }
  .theme-parent .stat-row {
    grid-template-columns: repeat(4, 1fr);
  }
  .theme-parent .set-bar {
    grid-template-columns: auto 1fr auto;
    align-items: end;
  }
  .theme-parent .set-charts {
    grid-template-columns: repeat(2, 1fr);
  }
  .theme-admin .admin-frame {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .theme-admin .admin-main {
    padding: 28px 40px 56px;
  }
  .theme-admin .dash-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
  .theme-admin .form.panel,
  .theme-admin .panel .form {
    max-width: 720px;
  }
}
@media (min-width: 1400px) {
  .theme-parent .app-shell,
  .page-wide .app-shell {
    width: min(1440px, calc(100% - 64px));
  }
  .theme-admin .dash-grid {
    grid-template-columns: repeat(6, minmax(140px, 1fr));
  }
}
@media (max-width: 800px) {
  .admin-frame { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .term { font-size: 2rem; }
}
