:root {
  --bg: #fff8ec;
  --surface: #ffffff;
  --surface-2: #fff3d7;
  --ink: #1f2430;
  --muted: #5d6472;
  --line: #dac8a8;
  --blue: #2563eb;
  --green: #10a86b;
  --red: #ef4444;
  --amber: #f59e0b;
  --violet: #7c3aed;
  --mint: #14b8a6;
  --shadow: 0 18px 0 rgba(120, 86, 42, 0.12), 0 24px 52px rgba(40, 36, 28, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.96), rgba(247, 253, 255, 0.98)),
    radial-gradient(circle at 12% 0%, rgba(20, 184, 166, 0.18), transparent 30%),
    radial-gradient(circle at 90% 8%, rgba(245, 158, 11, 0.16), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(124, 58, 237, 0.12), transparent 34%);
  color: var(--ink);
  font-size: 17px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  -webkit-tap-highlight-color: rgba(36, 87, 166, 0.16);
}

body.welcome-open {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

.wechat-share-thumb {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid rgba(179, 58, 49, 0.35);
  border-radius: 50%;
  background: #fff8f4;
  color: var(--red);
  font-size: 28px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 2.15rem;
  letter-spacing: 0;
  line-height: 1.18;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.7rem;
  letter-spacing: 0;
  line-height: 1.24;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.18rem;
}

.brand-block p,
.eyebrow,
.stat-tile span,
.pdf-card p,
.method-panel p,
.recall-box p {
  color: var(--muted);
}

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

.top-actions {
  gap: 6px;
}

.icon-btn,
.soft-btn,
.primary-btn,
.wide-btn,
.rate,
.tab {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  min-height: 50px;
  padding: 11px 15px;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.sound-select {
  display: grid;
  gap: 2px;
  min-width: 96px;
  color: var(--muted);
  font-size: 0.74rem;
}

.sound-select select {
  min-height: 32px;
  padding: 4px 7px;
  font-size: 0.84rem;
  font-weight: 800;
}

.icon-btn[aria-pressed="true"],
.tab.active {
  border-color: rgba(36, 87, 166, 0.45);
  background: #e8f0ff;
  color: var(--blue);
}

.primary-btn {
  border-color: #1d4ed8;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  color: white;
  font-weight: 700;
  box-shadow: 0 5px 0 #173b95, 0 12px 24px rgba(37, 99, 235, 0.24);
}

.soft-btn:hover,
.wide-btn:hover,
.tab:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(36, 87, 166, 0.55);
}

.control-band,
.study-panel,
.side-panel,
.quiz-panel,
.method-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
}

.study-panel,
.side-panel,
.quiz-panel,
.method-panel,
.control-band,
.wrong-card,
.pdf-card {
  border-width: 2px;
  box-shadow: var(--shadow);
}

.control-band {
  padding: 14px;
}

.filter-row {
  margin-bottom: 10px;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 10px;
  padding: 6px 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  background: #fff4cf;
  color: #8a3b00;
  font-size: 0.92rem;
  font-weight: 900;
}

label {
  display: grid;
  gap: 6px;
  min-width: 176px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.search-field {
  flex: 1 1 280px;
}

.group-field {
  flex: 0 0 168px;
  min-width: 148px;
}

select,
input,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 1rem;
}

select:disabled {
  opacity: 1;
  background: #fff8e7;
  color: #7c3d00;
  -webkit-text-fill-color: #7c3d00;
}

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

.stat-tile {
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.stat-tile strong {
  color: var(--blue);
  font-size: 1.48rem;
  line-height: 1;
}

.stat-tile.warn strong {
  color: var(--red);
}

.tabs {
  margin: 18px 0;
}

.tab {
  display: grid;
  min-width: 108px;
  gap: 1px;
  justify-items: center;
  align-content: center;
}

.tab > span {
  font-size: 1.35rem;
  line-height: 1;
}

.tab strong,
.tab small {
  line-height: 1.15;
}

.tab small {
  color: var(--muted);
  font-size: 0.76rem;
}

.tab.tab-hero {
  border-color: #f6b21a;
  background: linear-gradient(180deg, #fff0a6, #ffc83d);
  color: #7c3d00;
  box-shadow: 0 5px 0 #d78a00, 0 12px 24px rgba(245, 158, 11, 0.2);
}

.tab.tab-hero small {
  color: #7c3d00;
}

.tab.active:not(.tab-hero) {
  box-shadow: 0 4px 0 rgba(37, 99, 235, 0.24);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
}

.page-ribbon {
  display: grid;
  gap: 5px;
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 2px solid rgba(37, 99, 235, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(255, 240, 166, 0.9), rgba(226, 255, 246, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.82));
  box-shadow: 0 6px 0 rgba(36, 87, 166, 0.12), 0 14px 32px rgba(30, 41, 59, 0.1);
}

.page-ribbon strong {
  color: var(--blue);
  font-size: 1.08rem;
}

.owner-line {
  color: #8a3b00;
  font-size: 0.92rem;
  font-weight: 900;
}

.quiz-ribbon {
  border-color: rgba(245, 158, 11, 0.48);
  background: linear-gradient(90deg, #fff1a8, #e7f8ff 55%, #ffe1ee);
}

.study-panel,
.side-panel,
.quiz-panel,
.method-panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head.flat {
  margin: 0 0 14px;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 0.86rem;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff4e6;
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.recall-box,
.answer-box,
.feedback {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fbfaf7;
  padding: 16px;
  margin: 14px 0;
}

.recall-box {
  cursor: pointer;
}

.recall-box:active {
  transform: translateY(1px);
}

.answer-box {
  border-color: rgba(31, 122, 77, 0.3);
  background: #f0faf5;
}

.answer-label {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

#cardAnswer {
  color: var(--green);
  font-size: 2rem;
}

#cardKeyword {
  color: var(--blue);
  overflow-wrap: anywhere;
  font-size: 2rem;
  cursor: pointer;
}

#cardStrategy {
  margin-bottom: 10px;
}

details {
  color: var(--muted);
}

summary {
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.rating-row {
  margin-top: 10px;
}

.show-answer-btn {
  margin-top: 12px;
  min-width: 150px;
}

.rate.good {
  border-color: rgba(31, 122, 77, 0.45);
  color: var(--green);
  background: #edfff7;
}

.rate.unsure {
  border-color: rgba(168, 101, 22, 0.45);
  color: var(--amber);
  background: #fff8e4;
}

.rate.bad {
  border-color: rgba(179, 58, 49, 0.45);
  color: var(--red);
  background: #fff0f0;
}

.side-panel h2 {
  font-size: 20px;
}

.method-list {
  padding-left: 22px;
}

.method-list li + li {
  margin-top: 8px;
}

.wide-btn {
  width: 100%;
  margin-top: 10px;
  text-align: center;
}

.share-btn {
  border-color: #991b1b;
  background: linear-gradient(180deg, #ef4444, #c91f2f);
  color: #fff;
  box-shadow: 0 5px 0 #8f1b20, 0 12px 24px rgba(201, 31, 47, 0.22);
}

#cardCanvas {
  width: 100%;
  height: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.mode-visual,
.archive-visual,
.welcome-hero {
  display: block;
  overflow: hidden;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.74);
  background: #fff7e8;
  box-shadow: 0 8px 0 rgba(120, 86, 42, 0.12), 0 18px 34px rgba(30, 41, 59, 0.13);
}

.mode-visual {
  margin: -4px 0 16px;
  max-height: 260px;
}

.archive-visual {
  margin: 0 0 14px;
  max-height: 230px;
}

.welcome-hero {
  margin-bottom: 14px;
  max-height: 230px;
}

.mode-visual img,
.archive-visual img,
.welcome-hero img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 170px;
  object-fit: cover;
}

.download-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-weight: 700;
}

.mode-grid,
.option-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

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

.option-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
}

.option-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
}

.option-row.correct {
  border-color: rgba(16, 168, 107, 0.55);
  background: #ecfff7;
}

.option-row.wrong {
  border-color: rgba(239, 68, 68, 0.58);
  background: #fff1f1;
}

.feedback.good {
  border-color: rgba(31, 122, 77, 0.35);
  background: #effaf4;
}

.feedback.bad {
  border-color: rgba(179, 58, 49, 0.35);
  background: #fff4f2;
}

.quiz-summary strong {
  display: block;
  margin-bottom: 6px;
}

.quiz-summary ol {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 22px;
}

.quiz-summary li span {
  display: block;
  color: var(--muted);
  font-size: 0.94rem;
}

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

.wrong-card,
.pdf-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.wrong-card h3,
.pdf-card h2 {
  color: var(--blue);
  font-size: 18px;
}

.wrong-card strong {
  color: var(--green);
}

.pdf-card a {
  color: var(--blue);
  font-weight: 800;
}

.pdf-frame {
  width: 100%;
  min-height: 620px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

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

.method-columns section,
.reference-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
  padding: 14px;
}

.reference-list {
  padding-left: 32px;
}

.keyword-highlight {
  color: var(--blue);
  font-weight: 800;
}

.answer-highlight {
  color: var(--green);
  font-weight: 800;
}

.trap-highlight {
  color: var(--red);
  font-weight: 800;
}

.pulse-once {
  animation: pulseOnce 360ms ease;
}

@keyframes pulseOnce {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.012);
  }
  100% {
    transform: scale(1);
  }
}

body.reduce-motion * {
  animation: none !important;
  transition: none !important;
}

.welcome-overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(32, 34, 38, 0.52), rgba(36, 87, 166, 0.42)),
    linear-gradient(180deg, rgba(255, 250, 244, 0.7), rgba(240, 250, 245, 0.72));
  backdrop-filter: blur(10px);
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
}

.welcome-card {
  width: min(860px, 100%);
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 26px 70px rgba(20, 22, 26, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cardRise 460ms ease both;
  touch-action: auto;
}

.welcome-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px 8px;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid rgba(179, 58, 49, 0.28);
  border-radius: 999px;
  background: #fff4e6;
  color: var(--red);
  font-weight: 800;
}

.welcome-card h2 {
  margin: 16px 0 8px;
  color: var(--blue);
  font-size: 2.15rem;
  line-height: 1.18;
}

.welcome-scroll > p {
  color: var(--muted);
  font-size: 1.05rem;
}

.plan-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.plan-steps article {
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
  padding: 14px;
  box-shadow: 0 5px 0 rgba(120, 86, 42, 0.1);
}

.plan-steps span {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

.plan-steps strong {
  display: block;
  margin: 10px 0 6px;
  color: var(--ink);
}

.plan-steps p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.welcome-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  padding: 12px 20px 18px;
  border-top: 1px solid rgba(218, 200, 168, 0.72);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), #ffffff);
  box-shadow: 0 -12px 24px rgba(30, 41, 59, 0.08);
}

.welcome-actions button {
  flex: 1 1 180px;
  min-height: 56px;
}

.mode-card {
  display: grid;
  gap: 6px;
  min-height: 108px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 6px 0 rgba(120, 86, 42, 0.12);
}

.mode-card strong {
  color: var(--blue);
  font-size: 1.22rem;
}

.mode-card span {
  color: var(--muted);
  font-size: 1rem;
}

.mode-card.accent {
  border-color: rgba(179, 58, 49, 0.35);
  background: #fff7f2;
}

.mode-card.accent strong {
  color: var(--red);
}

.quiz-idle .timer-board,
.quiz-idle #quizOptions,
.quiz-idle .quiz-actions {
  display: none;
}

.quiz-active .mode-visual,
.quiz-active .mode-grid {
  display: none;
}

.quiz-finished .mode-visual,
.quiz-finished .mode-grid,
.quiz-finished .timer-board,
.quiz-finished #quizOptions,
.quiz-finished .quiz-actions {
  display: none;
}

.timer-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.timer-board > div {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
}

.timer-board span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.timer-board strong {
  display: block;
  margin-top: 5px;
  color: var(--blue);
  font-size: 2rem;
  line-height: 1;
}

#quizTimer.urgent {
  color: var(--red);
  animation: pulseOnce 620ms ease infinite;
}

.leaderboard {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
  padding: 14px;
  box-shadow: 0 6px 0 rgba(120, 86, 42, 0.1);
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mini-head h3 {
  margin: 0;
  font-size: 18px;
}

.mini-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.leaderboard ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: white;
}

.leaderboard li.self {
  border: 1px solid rgba(36, 87, 166, 0.35);
  background: #e8f0ff;
}

.leaderboard li span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--blue);
  font-weight: 800;
}

.leaderboard li em {
  color: var(--green);
  font-style: normal;
  font-weight: 800;
}

.dashboard-panel textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  font: inherit;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1.2fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.dashboard-grid label {
  align-content: start;
  min-width: 0;
}

.dashboard-status {
  color: var(--muted);
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.dashboard-summary article {
  min-height: 112px;
  padding: 12px;
  border: 1px solid rgba(36, 87, 166, 0.15);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
  box-shadow: 0 6px 0 rgba(36, 87, 166, 0.08);
}

.dashboard-summary span,
.dashboard-summary small,
.student-cell small,
.dashboard-table td small,
.focus-item small {
  display: block;
  color: var(--muted);
}

.dashboard-summary strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--blue);
  font-size: 1.45rem;
}

.dashboard-focus {
  display: grid;
  grid-template-columns: minmax(160px, 0.28fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(237, 171, 66, 0.35);
  border-radius: var(--radius);
  background: #fff9e9;
}

.dashboard-focus h3 {
  margin: 2px 0 0;
}

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

.focus-item {
  display: grid;
  gap: 8px;
  min-height: 116px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.focus-item p,
.dashboard-table td p {
  margin: 6px 0 0;
  color: var(--ink);
  white-space: normal;
}

.focus-item.warning {
  border-color: rgba(237, 171, 66, 0.55);
  background: #fff7df;
}

.focus-item.danger {
  border-color: rgba(220, 82, 70, 0.45);
  background: #fff0ee;
}

.focus-empty {
  margin: 0;
  color: var(--muted);
}

.dashboard-toolbar {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(140px, 0.7fr) minmax(220px, 1.2fr);
  gap: 12px;
  align-items: end;
  margin: 14px 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.dashboard-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  font-size: 15px;
}

.dashboard-table th,
.dashboard-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.dashboard-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
}

.dashboard-table tr:last-child td {
  border-bottom: 0;
}

.student-cell strong,
.dashboard-table td > strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.82rem;
}

.status-badge.good {
  background: #dbf7d7;
  color: #1f7b3b;
}

.status-badge.info {
  background: #e8f0ff;
  color: var(--blue);
}

.status-badge.warning {
  background: #fff0bd;
  color: #8a5a00;
}

.status-badge.danger {
  background: #ffe0dc;
  color: #a7352a;
}

.dashboard-row.row-warning td:first-child,
.dashboard-row.row-danger td:first-child {
  box-shadow: inset 5px 0 0 var(--orange);
}

.dashboard-row.row-danger td:first-child {
  box-shadow: inset 5px 0 0 #dc5246;
}

@keyframes cardRise {
  0% {
    transform: translateY(18px) scale(0.985);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 860px) {
  body {
    font-size: 18px;
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-band {
    padding: 10px;
    box-shadow: 0 8px 0 rgba(120, 86, 42, 0.08), 0 12px 26px rgba(40, 36, 28, 0.1);
  }

  .group-badge {
    min-height: 30px;
    margin-bottom: 7px;
    padding: 4px 9px;
    font-size: 0.82rem;
  }

  .filter-row {
    display: none;
  }

  .filter-row label,
  .search-field {
    min-width: 0;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .group-field,
  .search-field {
    display: none;
  }

  label {
    gap: 3px;
    font-size: 0.76rem;
  }

  select,
  input,
  textarea {
    min-height: 40px;
    padding: 7px 9px;
    font-size: 0.9rem;
  }

  .workspace-grid,
  .list-grid,
  .pdf-grid,
  .method-columns,
  .plan-steps,
  .dashboard-grid,
  .dashboard-focus,
  .dashboard-toolbar {
    grid-template-columns: 1fr;
  }

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

  .focus-list {
    grid-template-columns: 1fr;
  }

  .dashboard-table {
    min-width: 980px;
    font-size: 14px;
  }

  .dashboard-table th,
  .dashboard-table td {
    padding: 10px;
  }

  .mode-grid,
  .timer-board {
    grid-template-columns: 1fr;
  }

  .quiz-active .timer-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 8px 0;
  }

  .quiz-active .timer-board > div {
    min-height: 70px;
    padding: 10px 8px;
  }

  .quiz-active .timer-board span {
    font-size: 0.76rem;
  }

  .quiz-active .timer-board strong {
    font-size: 1.36rem;
  }

  .quiz-actions {
    position: sticky;
    z-index: 18;
    bottom: calc(82px + env(safe-area-inset-bottom));
    margin-top: 12px;
    padding: 8px 0 2px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.98) 36%, #fff);
  }

  .quiz-actions > button {
    flex: 1 1 0;
    min-width: 0;
  }

  .stats-grid {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 1px 1px 3px;
    scrollbar-width: none;
  }

  .stats-grid::-webkit-scrollbar {
    display: none;
  }

  .stat-tile {
    min-width: 86px;
    min-height: 46px;
    padding: 7px 8px;
    border-width: 1px;
  }

  .stat-tile span {
    font-size: 0.66rem;
    line-height: 1.1;
    white-space: nowrap;
  }

  .stat-tile strong {
    font-size: 1.08rem;
  }

  .stat-tile:nth-child(1),
  .stat-tile:nth-child(2) {
    display: none;
  }

  .welcome-card {
    width: min(100%, 560px);
    max-height: calc(100vh - 18px);
    max-height: calc(100dvh - 18px);
  }

  .welcome-scroll {
    padding: 14px 14px 6px;
  }

  .welcome-card h2 {
    font-size: 1.72rem;
  }

  .welcome-scroll > p {
    font-size: 1rem;
  }

  .welcome-hero {
    max-height: 168px;
  }

  .welcome-hero img {
    min-height: 138px;
  }

  .mode-visual {
    max-height: 150px;
    margin: -2px 0 10px;
  }

  .mode-visual img {
    min-height: 132px;
  }

  .quiz-panel .panel-head {
    margin-bottom: 10px;
  }

  .mode-card {
    min-height: 94px;
    padding: 14px;
  }

  .plan-steps {
    gap: 8px;
    margin: 12px 0;
  }

  .plan-steps article {
    display: grid;
    grid-template-columns: 36px 1fr;
    column-gap: 10px;
    min-height: 0;
    padding: 12px;
  }

  .plan-steps article span {
    grid-row: span 2;
  }

  .plan-steps strong {
    margin: 0 0 3px;
  }

  .welcome-actions {
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .top-actions {
    width: 100%;
    gap: 5px;
    align-items: end;
    flex-wrap: nowrap;
  }

  .top-actions .icon-btn {
    flex: 0 1 66px;
    min-height: 34px;
    padding: 5px 7px;
    font-size: 0.78rem;
    line-height: 1.1;
  }

  .top-actions .sound-select {
    flex: 0 0 90px;
    min-width: 86px;
    font-size: 0.66rem;
  }

  .top-actions .sound-select select {
    min-height: 30px;
    padding: 3px 5px;
    font-size: 0.76rem;
  }

  .pdf-frame {
    min-height: 420px;
  }

  .tabs {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 0;
    margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 28px rgba(34, 34, 34, 0.12);
  }

  .tab {
    min-width: 0;
    min-height: 62px;
    border-radius: 0;
    border-left: 0;
    font-size: 0.82rem;
    padding: 7px 3px;
  }

  .tab > span {
    font-size: 1.25rem;
  }

  .tab small {
    font-size: 0.66rem;
  }

  .tab:first-child {
    border-left: 1px solid var(--line);
    border-radius: var(--radius) 0 0 var(--radius);
  }

  .tab:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  .icon-btn,
  .soft-btn,
  .primary-btn,
  .wide-btn,
  .rate {
    min-height: 54px;
  }

  .option-row {
    min-height: 62px;
    padding: 15px;
    font-size: 1.04rem;
  }

  .option-row input {
    width: 22px;
    min-height: 22px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  h1 {
    font-size: 1.62rem;
  }

  h2 {
    font-size: 1.42rem;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .study-panel,
  .side-panel,
  .quiz-panel,
  .method-panel,
  .control-band {
    padding: 15px;
  }

  .button-row > button {
    flex: 1 1 140px;
  }

  .dashboard-summary {
    grid-template-columns: 1fr;
  }

  .filter-row label,
  .search-field {
    min-width: 0;
  }

  #cardAnswer {
    font-size: 1.55rem;
  }

  #cardKeyword {
    font-size: 1.62rem;
  }

  .pdf-frame {
    min-height: 360px;
  }
}

@media (max-width: 380px) {
  body {
    font-size: 17px;
  }

  .welcome-card h2 {
    font-size: 1.48rem;
  }

  .welcome-hero {
    max-height: 130px;
  }

  .plan-steps article {
    padding: 10px;
  }

  .stat-tile strong,
  .timer-board strong {
    font-size: 1.52rem;
  }

  .tab {
    min-height: 58px;
  }
}
