:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface: #fffefa;
  --surface-strong: #ffffff;
  --surface-muted: #eef3ef;
  --ink: #16332c;
  --muted: #697871;
  --line: #dce3de;
  --line-strong: #c9d5cf;
  --accent: #176f5e;
  --accent-dark: #0d5043;
  --accent-soft: #e1f1eb;
  --warm: #e2a63b;
  --warm-soft: #fff2d5;
  --danger: #b64b3d;
  --danger-soft: #fff0ec;
  --shadow-sm: 0 5px 18px rgba(25, 54, 45, .07);
  --shadow-lg: 0 24px 70px rgba(18, 43, 35, .18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 255, 255, .95), transparent 28rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.panel-open { overflow: hidden; }

button,
input,
select { font: inherit; }

button,
select { cursor: pointer; }

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(226, 166, 59, .75);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent-dark);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: var(--safe-top);
  border-bottom: 1px solid rgba(201, 213, 207, .82);
  background: rgba(244, 242, 236, .93);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.header-inner {
  width: min(100%, 1560px);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 7px 12px 5px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 7px 16px rgba(23, 111, 94, .18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
}

.brand p,
.brand h1,
.hero-copy p,
.panel-head p { margin: 0; }

.brand p {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand h1 {
  margin-top: 1px;
  font-size: 20px;
  letter-spacing: -.04em;
  line-height: 1.15;
}

.header-progress {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .74);
  white-space: nowrap;
}

.header-progress span {
  color: var(--muted);
  font-size: 10px;
}

.header-progress strong {
  color: var(--accent-dark);
  font-size: 14px;
}

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

.deck-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 50px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, .76);
  text-align: left;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.deck-step {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}

.deck-copy {
  display: block;
  min-width: 0;
}

.deck-copy strong,
.deck-copy small { display: block; }

.deck-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.deck-button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  box-shadow: 0 9px 22px rgba(23, 111, 94, .17);
}

.deck-button.active .deck-step {
  color: var(--accent-dark);
  background: #fff;
}

.deck-button.active .deck-copy strong,
.deck-button.active .deck-copy small { color: #fff; }

main {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 12px 12px calc(104px + var(--safe-bottom));
}

.study-hero {
  position: relative;
  overflow: hidden;
  padding: 14px;
  border: 1px solid rgba(23, 111, 94, .12);
  border-radius: 21px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(225, 241, 235, .78)),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.study-hero::after {
  position: absolute;
  right: -38px;
  bottom: -62px;
  width: 150px;
  height: 150px;
  border: 26px solid rgba(23, 111, 94, .055);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.hero-copy,
.progress-card { position: relative; z-index: 1; }

.hero-copy p {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.hero-copy h2 {
  margin: 3px 0;
  font-size: clamp(24px, 7vw, 32px);
  letter-spacing: -.055em;
  line-height: 1.06;
}

.hero-copy > span {
  display: none;
  max-width: 620px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.progress-card { margin-top: 11px; }

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.progress-copy span {
  color: var(--muted);
  font-size: 11px;
}

.progress-copy strong {
  color: var(--accent-dark);
  font-size: 12px;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 6px;
  background: rgba(22, 51, 44, .1);
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #3b927e);
  transition: width .25s ease;
}

.study-controls {
  margin-top: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 254, 250, .9);
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  display: block;
}

.search-mark {
  position: absolute;
  top: 15px;
  left: 16px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--accent-dark);
  border-radius: 50%;
  pointer-events: none;
}

.search-mark::after {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-dark);
  content: "";
  transform: rotate(45deg);
}

.search-box input,
.category-filter,
.utility-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-strong);
}

.search-box input {
  padding: 0 40px 0 43px;
  outline: none;
  font-size: 16px;
}

.search-box input::placeholder { color: #89938e; }

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(23, 111, 94, .11);
}

.utility-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.utility-row::-webkit-scrollbar { display: none; }

.category-filter {
  flex: 0 0 150px;
  padding: 0 12px;
  font-size: 14px;
}

.utility-button {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 0 10px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.utility-button.active-utility {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.reset-button { color: var(--muted); }

.results-bar { margin-top: 12px; }

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

.stat {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 254, 250, .78);
  text-align: center;
}

.stat span,
.stat strong { display: block; }

.stat span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 17px;
}

.secondary-stat { display: none; }

.view-switcher {
  position: fixed;
  right: 10px;
  bottom: calc(8px + var(--safe-bottom));
  left: 10px;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(201, 213, 207, .9);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 42px rgba(18, 43, 35, .22);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.view-switcher button {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 58px;
  padding: 5px 8px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  line-height: 1.15;
}

.view-switcher .view-icon {
  grid-column: 1 / -1;
  color: var(--accent-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 800;
}

.view-switcher button > strong {
  min-width: 17px;
  margin-left: 3px;
  padding: 1px 4px;
  border-radius: 6px;
  color: inherit;
  background: rgba(105, 120, 113, .1);
  font-size: 9px;
}

.view-switcher button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 800;
}

.view-switcher button.active > strong { background: rgba(23, 111, 94, .12); }

.touch-help,
.desktop-help {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.desktop-help { display: none; }

kbd {
  padding: 2px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-family: inherit;
  font-size: 10px;
}

.pagination {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: center;
  margin-top: 11px;
}

.page-button,
.page-status {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.page-button {
  padding: 0 12px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 750;
}

.page-button:disabled {
  color: #a8afab;
  background: rgba(255, 255, 255, .48);
  cursor: default;
}

.page-button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.page-status {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.page-status strong { color: var(--ink); }

.page-numbers { display: none; }

.pagination:not(.pagination-bottom) { display: none; }
.pagination-bottom { margin-top: 16px; }

.word-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 11px;
  align-items: start;
}

.word-card {
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(27, 55, 46, .055);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.word-card.favorite {
  border-color: rgba(226, 166, 59, .58);
  background: #fffdf7;
}

.word-card.removed {
  opacity: .76;
  background: #f1f3f1;
}

.word-card.expanded {
  border-color: var(--accent);
  box-shadow: 0 9px 25px rgba(23, 111, 94, .11);
}

.word-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px 65px;
  min-height: 78px;
}

.word-speak,
.quick-favorite,
.expand-trigger {
  min-width: 0;
  min-height: 48px;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.word-speak {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 10px 9px 10px 11px;
  text-align: left;
}

.play-badge,
.speak-mini {
  display: grid;
  place-items: center;
  border: 1px solid rgba(23, 111, 94, .15);
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
}

.play-badge {
  width: 40px;
  height: 40px;
  border-radius: 13px;
}

.word-copy {
  display: block;
  min-width: 0;
}

.word,
.word-gloss { display: block; }

.word {
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 7vw, 28px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.08;
}

.word-gloss {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.word-gloss.hidden-gloss { color: #929b96; }

.quick-favorite,
.expand-trigger { border-left: 1px solid var(--line); }

.quick-favorite {
  color: #a48745;
  font-size: 21px;
}

.quick-favorite.is-favorite {
  color: var(--warm);
  background: var(--warm-soft);
}

.expand-trigger {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 6px 4px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 780;
}

.expand-trigger .chevron {
  font-size: 18px;
  font-weight: 500;
  line-height: .7;
  transition: transform .16s ease;
}

.word-card.expanded .expand-trigger {
  color: #fff;
  background: var(--accent);
}

.word-card.expanded .expand-trigger .chevron { transform: rotate(180deg); }

.word-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(238, 243, 239, .55);
  font-size: 10px;
}

.word-meta b { color: var(--accent-dark); }

.detail {
  border-top: 1px solid var(--line);
  background: #fbfdfb;
}

.meaning-row {
  position: relative;
  min-height: 66px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.detail-label,
.panel-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.meaning-text {
  display: block;
  color: #31483f;
  font-size: 14px;
  line-height: 1.55;
}

.meaning-row.covered .meaning-text {
  filter: blur(5px);
  opacity: .25;
  user-select: none;
}

.reveal-meaning {
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(226, 166, 59, .55);
  border-radius: 12px;
  color: #76510f;
  background: var(--warm-soft);
  font-size: 12px;
  font-weight: 800;
}

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

.example-button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 54px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
}

.speak-mini {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.example-en,
.example-zh { display: block; }

.example-en {
  color: #263a33;
  font-size: 14px;
  line-height: 1.48;
}

.example-zh {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 800;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 13px;
}

.card-action,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--accent-dark);
  background: var(--surface-strong);
}

.card-action {
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 700;
}

.card-action:first-child { background: var(--accent-soft); }

.card-action.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.card-action.looping {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.loading-state,
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 58px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 254, 250, .82);
  text-align: center;
  font-size: 13px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 17px;
}

.empty-state span { font-size: 12px; }

.loading-dot {
  width: 24px;
  height: 24px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.memory-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(13, 35, 29, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.panel-open .memory-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.memory-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 61;
  overflow: auto;
  max-height: 88vh;
  max-height: 88dvh;
  padding-bottom: var(--safe-bottom);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 25px 25px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateY(104%);
  visibility: hidden;
  transition: transform .22s ease, visibility .22s;
}

.memory-panel.open {
  transform: translateY(0);
  visibility: visible;
}

.panel-grabber {
  width: 42px;
  height: 5px;
  margin: 9px auto 2px;
  border-radius: 4px;
  background: var(--line-strong);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-head > div { min-width: 0; }

.panel-head p {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

.panel-head h2 {
  margin: 4px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.icon-button {
  flex: 0 0 44px;
  width: 44px;
  padding: 0;
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.panel-body { padding: 18px; }

.memory-example {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #2a4038;
  background: #f9fbf9;
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.65;
}

.primary-link {
  display: grid;
  min-height: 49px;
  margin-top: 13px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.panel-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: calc(88px + var(--safe-bottom));
  left: 12px;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 9px 11px 9px 14px;
  border-radius: 14px;
  color: #fff;
  background: #172a24;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px);
  transition: opacity .16s ease, transform .16s ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast button {
  min-width: 50px;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

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

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 679px) {
  .topbar {
    min-height: 42px;
    padding-block: 4px;
  }

  .brand-mark,
  .brand p { display: none; }

  .brand h1 { font-size: 18px; }

  .header-progress { padding: 5px 8px; }
  .deck-button { min-height: 46px; }
  .deck-step { width: 28px; height: 28px; }
}

@media (min-width: 680px) {
  .header-inner {
    display: grid;
    grid-template-columns: auto minmax(430px, 620px);
    gap: 22px;
    align-items: center;
    padding: 10px 20px;
  }

  .topbar { min-height: 54px; padding: 0; }
  .deck-switcher { padding: 0; }

  main { padding: 22px 20px 48px; }

  .study-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
    gap: 28px;
    align-items: end;
    padding: 24px 26px;
  }

  .progress-card { margin-top: 0; }

  .hero-copy > span { display: block; }

  .utility-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) repeat(3, minmax(92px, auto));
    overflow: visible;
  }

  .category-filter {
    width: auto;
    min-width: 0;
  }

  .stats-row {
    display: flex;
    flex-wrap: wrap;
  }

  .stat {
    min-width: 76px;
    padding: 8px 12px;
  }

  .secondary-stat { display: block; }

  .view-switcher {
    position: static;
    width: 340px;
    flex: 0 0 auto;
    margin-top: 10px;
    border-radius: 14px;
    box-shadow: none;
  }

  .view-switcher button {
    grid-template-columns: auto auto auto;
    grid-template-rows: auto;
    gap: 5px;
    min-height: 43px;
    border-radius: 9px;
  }

  .view-switcher .view-icon { grid-column: auto; }

  .touch-help { display: none; }
  .desktop-help { display: block; }

  .pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
  }

  .page-button { min-width: 44px; padding: 0 12px; }
  .page-status { min-width: 92px; padding: 0 12px; }
  .page-numbers { display: flex; gap: 5px; }

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

  .toast {
    right: auto;
    bottom: 24px;
    left: 50%;
    width: auto;
    max-width: min(92vw, 520px);
    transform: translate(-50%, 15px);
  }

  .toast.show { transform: translate(-50%, 0); }
}

@media (min-width: 980px) {
  .study-controls {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 9px;
    padding: 9px;
  }

  .utility-row {
    display: flex;
    margin-top: 0;
  }

  .category-filter { width: 170px; }
  .utility-button { width: auto; min-width: 90px; padding: 0 13px; }

  .results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .view-switcher { margin-top: 0; }

  .word-grid { gap: 12px; }

  .memory-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(440px, 100vw);
    max-height: none;
    padding-bottom: 0;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
    transform: translateX(104%);
  }

  .memory-panel.open { transform: translateX(0); }
  .panel-grabber { display: none; }
  .panel-head { padding-top: 24px; }
}

@media (hover: hover) and (pointer: fine) {
  .deck-button:hover:not(.active) {
    border-color: var(--accent);
    transform: translateY(-1px);
  }

  .utility-button:hover,
  .page-button:hover:not(:disabled),
  .card-action:hover,
  .icon-button:hover { border-color: var(--accent); }

  .word-card:hover {
    border-color: rgba(23, 111, 94, .48);
    box-shadow: 0 10px 28px rgba(23, 70, 56, .1);
    transform: translateY(-1px);
  }

  .word-speak:hover,
  .quick-favorite:hover,
  .expand-trigger:hover,
  .example-button:hover { background: var(--accent-soft); }

  .primary-link:hover { background: var(--accent-dark); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
