:root {
  --ink: #282047;
  --muted: #6f6890;
  --line: #ded9ef;
  --bg: #f5f1ff;
  --panel: #ffffff;
  --primary: #6753c8;
  --good: #258a55;
  --bad: #c73f4a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--primary); }
button, .button-link {
  border: 1px solid #bdb7d2;
  background: #eeeaf7;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .button-link:hover { border-color: var(--primary); }
button:disabled {
  cursor: not-allowed;
  opacity: .62;
}
input, select, textarea {
  min-height: 40px;
  border: 1px solid #bdb7d2;
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font: inherit;
}
textarea {
  resize: vertical;
  line-height: 1.6;
}

.page { max-width: 1180px; margin: 0 auto; padding: 24px; }
.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;
}
.auth-panel {
  max-width: 430px;
  margin: 64px auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.auth-panel h1 { margin-top: 0; }
.login-announcements {
  display: grid;
  gap: 8px;
  margin: 16px 0 20px;
  padding: 14px;
  border: 1px solid #e8d998;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8d8, #edf7ff);
}
.login-announcement-item {
  display: grid;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px solid rgba(138, 106, 18, .16);
}
.login-announcement-item:first-of-type { border-top: 0; padding-top: 0; }
.login-announcement-item strong { color: var(--ink); }
.login-announcement-item span { color: var(--muted); line-height: 1.45; }
.more-link { font-weight: 800; text-decoration: none; }
.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 8px; font-weight: 700; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-weight: 700; }
.ok { color: var(--good); font-weight: 700; }
.ghost { background: white; }
.danger, .bad { color: var(--bad); border-color: #e4b5bc; background: #fff3f5; }
.good { color: var(--good); border-color: #add7bf; background: #effaf4; }
.secondary { background: white; margin-top: 12px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; }
.topbar p { margin: 6px 0 0; color: var(--muted); }

.mobile-app-shell {
  max-width: 520px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  padding-bottom: 84px;
}
.mobile-panel {
  display: none;
}
.mobile-panel.active {
  display: block;
}
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.learn-header {
  justify-content: flex-end;
  min-height: 42px;
  margin-bottom: 10px;
}
.mobile-header.plain {
  display: block;
}
.mobile-header h1 {
  margin: 0;
  font-size: 26px;
}
.mobile-header p {
  margin: 4px 0 0;
  color: var(--muted);
}
.header-actions {
  display: flex;
  gap: 8px;
}
.learn-header .header-actions {
  margin-left: auto;
}
.icon-button {
  min-width: auto;
  padding: 9px 11px;
  border-radius: 999px;
  background: white;
}
.today-grid,
.record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.record-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.mini-stat,
.summary-card,
.range-card,
.profile-card,
.menu-card,
.trend-card,
.list-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.mini-stat {
  display: grid;
  gap: 4px;
  min-height: 72px;
}
.mini-stat span,
.summary-card span,
.range-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.mini-stat strong,
.summary-card strong,
.range-card strong {
  color: var(--primary);
  font-size: 24px;
  line-height: 1.1;
}
.range-card {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #fbf8ff 100%);
}
.range-card strong {
  font-size: 17px;
  color: var(--ink);
}
.compact-study {
  align-content: start;
  gap: 9px;
  margin-bottom: 0;
  padding: 16px;
}
.compact-study h2 {
  font-size: 34px;
  line-height: 1.12;
}
.compact-study .tag {
  display: none;
}
.compact-study .answer-row {
  margin-top: 2px;
}
.compact-study .guide:empty,
.compact-study .result:empty {
  display: none;
}
.compact-study .result {
  min-height: 0;
  margin: 0;
}
.explain-button {
  width: 100%;
  margin-top: 2px;
  background: #fff8d8;
  border-color: #e8d998;
  color: #6d4c00;
}
.mobile-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.mobile-actions button {
  min-width: 0;
  min-height: 48px;
}
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(520px, 100%);
  transform: translateX(-50%);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(44, 36, 76, .08);
}
.bottom-nav button {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 4px;
  border-radius: 8px;
}
.bottom-nav button.active {
  color: white;
  background: var(--primary);
}
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(22, 18, 40, .38);
}
.sheet-mask[hidden] {
  display: none;
}
.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 31;
  width: min(520px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
  transform: translateX(-50%);
  padding: 16px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  background: white;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -18px 40px rgba(22, 18, 40, .18);
}
.bottom-sheet[hidden] {
  display: none;
}
.sheet-head,
.sheet-actions,
.list-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sheet-head strong {
  font-size: 20px;
}
.sheet-close {
  min-width: auto;
  padding: 8px 10px;
  background: #f8f6ff;
}
.sheet-toolbar {
  border: 0;
  margin: 0;
  padding: 0;
  grid-template-columns: 1fr;
}
.announcement-list {
  display: grid;
  gap: 10px;
}
.announcement-item.full {
  padding: 12px;
  border: 1px solid #efe6bd;
  border-radius: 8px;
  background: #fffdf4;
}
.profile-card,
.menu-card {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.profile-card strong {
  font-size: 22px;
}
.profile-card span {
  color: var(--muted);
}
.menu-card button {
  justify-content: space-between;
  width: 100%;
  background: white;
}
.menu-card span {
  color: var(--muted);
  font-size: 13px;
}
.logout-button {
  width: 100%;
  color: var(--bad);
  border-color: #e4b5bc;
  background: #fff3f5;
}
.trend-card,
.list-card {
  margin-bottom: 12px;
}
.trend-card h2,
.list-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}
.trend-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 112px;
}
.trend-bar {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.trend-bar span {
  display: block;
  width: 100%;
  max-width: 28px;
  border-radius: 999px 999px 4px 4px;
  background: var(--primary);
}
.wrong-list {
  display: grid;
  gap: 10px;
}
.photo-ai-card,
.photo-explain-card,
.photo-history-item {
  display: grid;
  gap: 12px;
}
.photo-ai-card {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.photo-picker {
  display: grid;
  gap: 8px;
  padding: 14px;
  color: var(--primary);
  font-weight: 900;
  text-align: center;
  background: #f4f1ff;
  border: 1px dashed #b7aaf0;
  border-radius: 8px;
}
.photo-picker input {
  width: 100%;
}
.photo-tip {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.photo-preview {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  background: #f9fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.photo-preview img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}
.ocr-result-list,
.photo-history-list,
.history-line-list {
  display: grid;
  gap: 10px;
}
.ocr-line-card,
.history-line-list button {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
  line-height: 1.5;
  background: #fbfdff;
}
.photo-explain-card {
  line-height: 1.7;
}
.photo-explain-card p {
  margin: 0;
}
.photo-explain-card ul {
  margin: 6px 0 0;
  padding-left: 20px;
}
.photo-explain-card span {
  color: var(--muted);
}
.photo-history-item {
  padding: 12px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.article-search-card {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.article-date-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.list-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.list-card-head h2 {
  margin: 0;
}
.article-list {
  display: grid;
  gap: 10px;
}
.article-card {
  display: grid;
  justify-items: start;
  width: 100%;
  min-height: 86px;
  gap: 6px;
  text-align: left;
  background: #fbfdff;
  border-color: #d8e1f2;
}
.article-card strong {
  font-size: 18px;
  color: var(--ink);
}
.article-card em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.5;
}
.article-card-meta {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}
.article-detail-card {
  margin-top: 12px;
}
.article-detail-content {
  display: grid;
  gap: 10px;
  color: #332b52;
  line-height: 1.8;
}
.article-detail-content h2,
.article-detail-content h3,
.article-detail-content h4,
.article-detail-content p,
.article-detail-content ul,
.article-detail-content ol,
.article-detail-content blockquote {
  margin: 0;
}
.article-detail-content h2,
.article-detail-content h3,
.article-detail-content h4 {
  color: #1f1a3d;
  line-height: 1.35;
}
.article-detail-content h2 {
  font-size: 22px;
}
.article-detail-content h3 {
  font-size: 18px;
}
.article-detail-content h4 {
  font-size: 16px;
}
.article-detail-content ul,
.article-detail-content ol {
  padding-left: 22px;
}
.article-detail-content li + li {
  margin-top: 4px;
}
.article-detail-content blockquote {
  border-left: 4px solid #8d7cff;
  color: #51476f;
  padding: 4px 0 4px 12px;
}
.article-detail-content code {
  background: #f3f0ff;
  border-radius: 4px;
  color: #493a85;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 2px 5px;
}
.article-detail-content a {
  color: #4f46e5;
  font-weight: 800;
  text-decoration: none;
}
.article-detail-content a:hover {
  text-decoration: underline;
}
.compact-pager {
  margin-top: 12px;
}
.explain-content dl {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  margin: 0;
}
.explain-content dt {
  color: var(--muted);
  font-weight: 900;
}
.explain-content dd {
  margin: 0;
  line-height: 1.6;
}
.explain-content dd span {
  color: var(--muted);
}

.toolbar, .stats, .study-card, .history, .admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}
.toolbar label { display: grid; gap: 6px; font-weight: 700; color: var(--muted); }
.toolbar .check { display: flex; align-items: center; gap: 8px; }
.voice-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.study-card { display: grid; gap: 12px; }
.review-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #b9c7ea;
  border-radius: 8px;
  background: #edf4ff;
  color: #3b4c72;
  font-weight: 800;
}
.review-banner[hidden] { display: none; }
.announcement-board {
  min-height: 118px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8d8 0%, #edf7ff 100%);
  padding: 14px;
  border: 1px solid #e8d998;
}
.announcement-card {
  display: grid;
  gap: 10px;
}
.announcement-card.quiet {
  color: #4c5574;
}
.announcement-kicker {
  margin: 0;
  color: #8a6a12;
  font-size: 13px;
  font-weight: 900;
}
.announcement-item {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid rgba(138, 106, 18, 0.18);
}
.announcement-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.announcement-card strong {
  color: #241d48;
  font-size: 18px;
}
.announcement-card span {
  color: #4f5570;
  line-height: 1.55;
}
.tag { color: var(--muted); margin: 0; }
.study-card h2 { margin: 0; font-size: 36px; }
.answer { margin: 0; color: var(--primary); font-size: 22px; font-weight: 800; }
.guide { margin: 0; line-height: 1.7; color: #3b335a; }
.answer-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.result { min-height: 28px; font-weight: 800; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions button { min-width: 110px; }
.nav-prev {
  color: #3b4c72;
  border-color: #b9c7ea;
  background: #edf4ff;
}
.reveal-answer {
  color: #2f4f7a;
  border-color: #bfd2ef;
  background: #f1f7ff;
}
.speak-main {
  color: white;
  border-color: #5b49bc;
  background: #6753c8;
}
.auto-play,
.pronunciation-practice {
  color: #4d3100;
  border-color: #e5ba55;
  background: #fff0bd;
}
.auto-play.is-running,
.pronunciation-practice.is-running {
  color: white;
  border-color: #bf3543;
  background: #c73f4a;
}
.pronunciation-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.pronunciation-head,
.pronunciation-actions,
.score-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.pronunciation-head {
  justify-content: space-between;
}
.pronunciation-head span {
  color: var(--primary);
  font-weight: 900;
}
.score-card {
  display: grid;
  place-items: center;
  width: 96px;
  min-height: 82px;
  color: white;
  background: #6753c8;
  border-radius: 8px;
}
.score-card strong {
  font-size: 32px;
}
.score-grid span {
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.nav-next {
  color: white;
  border-color: #23754a;
  background: #258a55;
}

.history h2, .admin-section h2 { margin-top: 0; }
.day-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.history-actions button {
  min-width: 86px;
  padding: 8px 10px;
  background: #ffffff;
}
.history-actions button[data-status="correct"] {
  color: var(--good);
  border-color: #add7bf;
}
.history-actions button[data-status="wrong"] {
  color: var(--bad);
  border-color: #e4b5bc;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 14px;
}
.pager span {
  color: var(--muted);
  font-weight: 800;
}
.admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.admin-form .wide {
  grid-column: 1 / -1;
}
.admin-form label { display: grid; gap: 6px; font-weight: 700; color: var(--muted); }
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.filter-bar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}
.course-picker {
  grid-column: 1 / -1;
  padding: 14px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.course-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.course-picker-head strong {
  color: var(--text);
}
.course-picker-head span {
  color: var(--muted);
  font-size: 13px;
}
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
}
.course-group {
  display: grid;
  gap: 7px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid #ebe6f6;
  border-radius: 8px;
}
.course-group strong {
  color: var(--primary);
  font-weight: 800;
}
.course-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
}
.course-group input {
  width: auto;
}
.course-picker.compact {
  margin-top: 10px;
}
.course-picker.compact .course-grid {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 840px; table-layout: fixed; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #faf8ff; }
td {
  overflow-wrap: anywhere;
}
.admin-table th,
.admin-table td {
  white-space: normal;
}
.codes-table {
  min-width: 1120px;
}
.codes-table th:nth-child(1) { width: 150px; }
.codes-table th:nth-child(2) { width: 220px; }
.codes-table th:nth-child(3) { width: 100px; }
.codes-table th:nth-child(4) { width: 120px; }
.codes-table th:nth-child(5) { width: 185px; }
.codes-table th:nth-child(6) { width: 95px; }
.codes-table th:nth-child(7) { width: 95px; }
.codes-table th:nth-child(8) { width: 96px; }
.course-cell {
  color: #3d365f;
  line-height: 1.5;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  background: #eef1f7;
  color: #516079;
}
.status-pill.ok {
  background: #e9f8ef;
  color: var(--good);
}
.status-pill.warn {
  background: #fff2d5;
  color: #9a6400;
}
.status-pill.idle {
  background: #eef1f7;
  color: #536071;
}
.row-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 900;
}
.edit-panel {
  display: grid;
  gap: 12px;
  width: min(820px, 78vw);
  margin-top: 10px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(44, 36, 76, .12);
}
.edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.edit-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}
.edit-actions {
  display: flex;
  justify-content: flex-end;
}
.inline-admin-form {
  display: grid;
  gap: 8px;
  min-width: 220px;
  margin: 10px 0;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.announcement-form {
  margin-bottom: 16px;
}
.announcement-row-form {
  grid-template-columns: minmax(140px, 1fr) minmax(260px, 2fr) 90px minmax(170px, 1fr) minmax(170px, 1fr) auto;
}
.announcement-table {
  min-width: 980px;
}
.announcement-table textarea {
  min-height: 58px;
}
.article-create-form {
  margin-bottom: 18px;
}
.articles-table {
  min-width: 980px;
}
.articles-table th:nth-child(1) { width: 42%; }
.articles-table th:nth-child(2) { width: 120px; }
.articles-table th:nth-child(3) { width: 96px; }
.articles-table th:nth-child(4) { width: 110px; }
.articles-table th:nth-child(5) { width: 120px; }
.articles-table p {
  margin: 6px 0 0;
  line-height: 1.5;
}
.article-edit-panel {
  width: min(920px, 78vw);
}
.article-edit-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}
.article-edit-panel textarea[name="content"] {
  min-height: 220px;
}
.article-row-actions {
  justify-content: flex-start;
  gap: 10px;
}
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
}
.admin-menu {
  position: sticky;
  top: 16px;
  align-self: start;
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.admin-menu a {
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 800;
}
.admin-menu a:hover {
  background: #eeeaf7;
}
.admin-menu a.active {
  color: white;
  background: var(--primary);
}
.admin-main {
  min-width: 0;
}
.list-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.list-toolbar h2,
.list-toolbar h3 {
  margin: 0;
}
.page-size-form {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.page-size-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}
.section-title-row,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-title-row h2,
.detail-header h3 {
  margin: 0;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.compact-metrics {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.metric-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  color: var(--text);
  text-decoration: none;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric-card:hover,
.metric-card.is-active {
  border-color: var(--primary);
  background: #f2efff;
}
.metric-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}
.metric-label {
  font-weight: 900;
}
.metric-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.row-form.wide {
  grid-template-columns: repeat(10, minmax(95px, 1fr));
}
.row-form.word-form {
  grid-template-columns: minmax(130px, 1.3fr) minmax(150px, 1.4fr) minmax(90px, .8fr) minmax(90px, .8fr) minmax(90px, .9fr) minmax(70px, .6fr) auto;
}

@media (max-width: 680px) {
  .page { padding: 14px 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .answer-row { grid-template-columns: 1fr; }
  .study-card h2 { font-size: 30px; }
  .compact-study {
    gap: 11px;
    padding: 16px;
  }
  .compact-study h2 {
    font-size: 34px;
  }
  .compact-study .answer {
    line-height: 1.25;
  }
  .compact-study input,
  .compact-study button {
    min-height: 48px;
  }
  .compact-study .explain-button {
    margin-top: 4px;
  }
  .compact-study .mobile-actions {
    margin-top: 2px;
  }
  .auth-panel {
    margin: 16px auto;
    padding: 20px;
  }
  .toolbar, .stats, .study-card, .history, .admin-section {
    padding: 14px;
  }
  .today-grid {
    gap: 8px;
  }
  .mini-stat {
    padding: 11px;
  }
  .mini-stat strong {
    font-size: 21px;
  }
  .answer {
    font-size: 20px;
  }
  .review-banner,
  .day-row {
    align-items: stretch;
    flex-direction: column;
  }
  .history-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .history-actions button {
    min-width: 0;
    padding: 9px 6px;
  }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-menu { position: static; }
  .section-title-row,
  .detail-header,
  .list-toolbar {
    flex-direction: column;
  }
  .page-size-form,
  .page-size-form label {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }
  .row-form { grid-template-columns: 1fr; }
  .row-form.wide,
  .row-form.announcement-row-form,
  .row-form.word-form { grid-template-columns: 1fr; }
}
