:root {
  color-scheme: dark;
  --bg: #141416;
  --panel: #111114;
  --surface: #1c1c1e;
  --surface-elevated: #242426;
  --surface-soft: #2c2c2e;
  --chrome-bg: #1c1c1e;
  --separator: rgba(255, 255, 255, 0.1);
  --separator-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text-secondary: #c7c7cc;
  --text-tertiary: #8e8e93;
  --blue: #0a84ff;
  --blue-soft: rgba(10, 132, 255, 0.16);
  --green-soft: rgba(52, 199, 89, 0.14);
  --green-line: rgba(52, 199, 89, 0.46);
  --orange-soft: rgba(255, 159, 10, 0.14);
  --orange-line: rgba(255, 159, 10, 0.42);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.24);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --control-radius: 14px;
  --secondary-border: var(--separator-strong);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #0b0b0f;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(10, 132, 255, 0.72);
  outline-offset: 2px;
}

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

.app-shell {
  width: min(100%, 430px);
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
}

.app-header {
  margin-bottom: 12px;
}

.entry-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: var(--surface);
}

.entry-tabs button,
.mini-btn,
.pos-btn,
.group-toggle,
.word-row,
.option-btn,
.ghost-btn,
.primary-btn,
.secondary-btn,
.link-btn,
.sense-card,
.action-btn {
  border: 0;
}

.entry-tabs button {
  min-width: 0;
  min-height: 36px;
  border-radius: 11px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.15;
}

.entry-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.card {
  min-width: 0;
  min-height: calc(100vh - 96px);
  min-height: calc(100dvh - 96px);
  padding: 14px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.empty-state {
  display: grid;
  align-content: center;
  gap: 18px;
  place-items: center;
  min-height: calc(100vh - 150px);
  min-height: calc(100dvh - 150px);
  color: var(--text-secondary);
  text-align: center;
}

.empty-illustration {
  position: relative;
  width: 118px;
  height: 88px;
}

.empty-illustration::before {
  content: "";
  position: absolute;
  inset: 10px 8px 0;
  border: 1px solid rgba(10, 132, 255, 0.34);
  border-radius: 22px;
  background: rgba(10, 132, 255, 0.08);
}

.empty-illustration span {
  position: absolute;
  left: 31px;
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: rgba(10, 132, 255, 0.48);
}

.empty-illustration span:nth-child(1) {
  top: 31px;
}

.empty-illustration span:nth-child(2) {
  top: 45px;
  width: 42px;
}

.empty-illustration span:nth-child(3) {
  top: 59px;
  width: 62px;
}

.empty-state h2 {
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.direct-word-list,
.target-unit,
.content-block,
.setup-section,
.reveal-block,
.meaning-action,
.round-actions {
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  font-weight: 650;
  text-align: left;
}

.group-toggle span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.line-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.group-toggle .line-icon,
.word-row .line-icon,
.sense-card .line-icon {
  color: var(--text-tertiary);
}

.word-list {
  display: grid;
  gap: 0;
  padding: 0 10px 10px;
}

.direct-word-list {
  display: grid;
  gap: 0;
  padding: 4px 10px;
}

.word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 10px 2px 10px 8px;
  border-top: 1px solid var(--separator);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.word-row:first-child {
  border-top: 0;
}

.word-row strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.08;
}

.word-row small,
.word-row span {
  min-width: 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.target-unit {
  padding: 14px;
}

.target-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.target-bar h1 {
  color: var(--text);
  font-size: 32px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.05;
}

.target-bar p {
  margin-top: 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.setup-layout,
.practice-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  min-height: calc(100vh - 124px);
  min-height: calc(100dvh - 124px);
}

.setup-content,
.practice-content {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.mini-btn,
.ghost-btn,
.secondary-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--secondary-border);
  border-radius: var(--control-radius);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.secondary-btn {
  width: 100%;
}

.text-btn {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.bottom-actions {
  display: grid;
  gap: 9px;
  align-self: end;
  margin-top: 14px;
  position: sticky;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 5;
  padding-top: 10px;
  background: var(--panel);
}

.setup-section {
  margin-top: 0;
  padding: 14px;
}

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

.pos-grid.single {
  grid-template-columns: 1fr;
}

.pos-btn {
  min-width: 0;
  min-height: 44px;
  border-radius: var(--control-radius);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
}

.pos-btn.active {
  background: var(--blue);
  color: #fff;
}

.pos-btn:disabled {
  color: #636366;
  background: rgba(118, 118, 128, 0.12);
}

.sense-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 74px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  text-align: left;
}

.sense-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(118, 118, 128, 0.18);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.blurred-sense {
  display: inline-block;
  max-width: 100%;
  color: var(--text-secondary);
  filter: blur(4px);
  user-select: none;
}

.segmented-progress {
  margin-top: 12px;
}

.round-count {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.segments {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.segments span {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.24);
}

.segments span.active {
  background: var(--blue);
}

.content-block {
  padding: 14px;
}

.content-block p {
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.55;
}

.question-block p {
  font-size: 17px;
  font-weight: 650;
}

.options {
  display: grid;
  gap: 8px;
}

.option-btn {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
}

.option-btn span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(118, 118, 128, 0.18);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.option-btn strong {
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.42;
}

.option-btn.selected {
  border-color: rgba(10, 132, 255, 0.58);
  background: var(--blue-soft);
}

.option-btn.selected span {
  background: var(--blue);
  color: #fff;
}

.round-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.round-actions.single {
  grid-template-columns: 1fr;
}

.primary-btn,
.action-btn {
  width: 100%;
  min-height: 48px;
  border-radius: var(--control-radius);
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  box-shadow: none;
}

.control-btn,
.bottom-actions .primary-btn {
  min-height: 48px;
  font-size: 15px;
  font-weight: 650;
  border-radius: var(--control-radius);
}

.primary-btn:disabled,
.action-btn:disabled {
  opacity: 0.42;
}

.action-btn:disabled {
  border: 1px solid var(--separator);
  background: var(--surface-elevated);
  color: var(--text-tertiary);
}

.meaning-action {
  padding: 0;
  border: 0;
  background: transparent;
}

.meaning-action .primary-btn {
  margin: 0;
}

.meaning-action.secondary .primary-btn {
  min-height: 48px;
  border: 1px solid var(--secondary-border);
  background: var(--surface-elevated);
  color: var(--text);
}

.meaning-hint {
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.inline-feedback {
  padding: 13px 14px 14px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.bottom-actions .inline-feedback {
  margin-bottom: 0;
}

.inline-feedback.correct {
  border-color: var(--green-line);
  background: var(--green-soft);
}

.inline-feedback.incorrect {
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.feedback-pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--separator-strong);
  background: rgba(118, 118, 128, 0.14);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.inline-feedback.correct .feedback-pill {
  border-color: rgba(52, 199, 89, 0.42);
  background: rgba(52, 199, 89, 0.16);
  color: #8ee89f;
}

.inline-feedback.incorrect .feedback-pill {
  border-color: rgba(255, 159, 10, 0.36);
  background: rgba(255, 159, 10, 0.12);
  color: #ffd08a;
}

.inline-feedback p {
  margin-top: 11px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.58;
}

.reveal-page {
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr auto;
  gap: 10px;
  min-height: calc(100vh - 124px);
  min-height: calc(100dvh - 124px);
  align-content: start;
}

.reveal-main {
  padding: 16px;
  border: 1px solid rgba(10, 132, 255, 0.28);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.reveal-main h2 {
  color: var(--text);
  font-size: 32px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.05;
}

.reveal-main .part {
  margin-top: 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.reveal-main .usage {
  margin-top: 14px;
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.5;
}

.reveal-main .scene {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.reveal-block {
  padding: 13px 14px;
}

.reveal-block h3 {
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.reveal-block p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.52;
}

details.reveal-block summary {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

details.reveal-block p {
  margin-top: 9px;
}

.reveal-actions {
  display: grid;
  gap: 8px;
  padding: 0;
  margin-top: auto;
}

.reveal-bottom {
  margin-top: 8px;
}

.reveal-actions p {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
}

.reveal-actions .control-btn {
  min-height: 48px;
  border-radius: var(--control-radius);
}

.action-row {
  display: grid;
  gap: 8px;
}

.action-row.stacked {
  grid-template-columns: 1fr;
}

.link-btn {
  min-height: 46px;
  border-radius: var(--control-radius);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.hidden {
  display: none;
}

@media (hover: hover) {
  button {
    cursor: pointer;
  }

  button:hover:not(:disabled) {
    background-color: var(--surface-soft);
  }

  .primary-btn:hover:not(:disabled),
  .action-btn:hover:not(:disabled),
  .entry-tabs button.active:hover:not(:disabled) {
    background-color: #2997ff;
  }

  .option-btn.selected:hover:not(:disabled),
  .pos-btn.active:hover:not(:disabled) {
    background-color: #2997ff;
  }

}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 10px;
  }

  .card {
    padding: 12px;
    border-radius: 22px;
  }

  .entry-tabs button {
    font-size: 11px;
  }

  .target-bar {
    display: grid;
  }

  .text-btn {
    justify-self: start;
  }

  .target-bar h1,
  .reveal-main h2 {
    font-size: 29px;
  }

  .content-block p {
    font-size: 15px;
  }

  .question-block p {
    font-size: 16px;
  }

  .option-btn strong {
    font-size: 14px;
  }
}

/* Simplified app-shell layout */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  background: var(--bg);
}

.app-header {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border-bottom: 0;
  background: var(--bg);
}

.nav-bar {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: max(14px, env(safe-area-inset-top)) 14px 14px;
  border-bottom: 1px solid var(--separator);
  background: var(--chrome-bg);
}

.app-title {
  max-width: calc(100% - 84px);
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
}

.nav-back-btn {
  position: absolute;
  left: 10px;
  top: max(14px, env(safe-area-inset-top));
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.nav-back-btn .line-icon {
  width: 25px;
  height: 25px;
}

.nav-back-btn.hidden {
  display: none;
}

.entry-tabs {
  margin: 18px 14px 6px;
  background: var(--bg);
}

.card {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 0;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

.direct-word-list,
.target-unit,
.content-block,
.setup-section,
.reveal-main,
.reveal-block {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.direct-word-list {
  padding: 0;
}

.word-group-card {
  overflow: hidden;
  border: 1px solid var(--separator);
  border-radius: 16px;
  background: var(--surface);
}

.word-group-card + .word-group-card {
  margin-top: 12px;
}

.word-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 1px 0 16px;
}

.word-group-header h2 {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.25;
}

.word-group-toggle {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text-tertiary);
}

.word-group-toggle .line-icon {
  width: 22px;
  height: 22px;
}

.word-group-card .direct-word-list {
  border-top: 1px solid var(--separator);
}

.word-group-card .word-row {
  padding-inline: 16px 12px;
}

.word-group-card .word-row:last-child {
  border-bottom: 0;
}

.word-row {
  min-height: 62px;
  padding: 12px 0;
  border-top: 0;
  border-bottom: 1px solid var(--separator);
}

.word-row strong {
  color: var(--text);
  font-size: 23px;
  font-weight: 700;
}

.setup-layout,
.practice-layout,
.reveal-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.setup-content,
.practice-content,
.reveal-page {
  gap: 0;
}

.target-unit,
.content-block,
.setup-section,
.reveal-main,
.reveal-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--separator);
}

.reveal-main {
  border-bottom: 0;
}

.target-bar h1,
.reveal-main h2 {
  color: var(--text);
  font-size: 32px;
  font-weight: 750;
}

.target-copy,
.reveal-title {
  min-width: 0;
}

.target-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 8px;
}

.reveal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pronounce-btn {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: rgba(118, 118, 128, 0.1);
  color: var(--text-secondary);
}

.pronounce-btn .line-icon {
  width: 21px;
  height: 21px;
  stroke-width: 1.9;
}

.target-bar p,
.reveal-main .part {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  margin-top: 8px;
  padding: 0 9px;
  border: 1px solid var(--separator);
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.text-btn {
  color: var(--text-tertiary);
  font-weight: 600;
}

.pos-grid,
.pos-grid.single {
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
}

.pos-btn {
  min-height: 44px;
}

.sense-card {
  min-height: 68px;
  margin: 0;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--separator);
  border-radius: 0;
  background: transparent;
}

.sense-card:last-child {
  border-bottom: 0;
}

.blurred-sense {
  color: var(--text-secondary);
}

.content-block p {
  font-size: 16px;
  font-weight: 500;
}

.question-block p {
  font-size: 17px;
  font-weight: 650;
}

.options {
  padding: 14px 0;
}

.bottom-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  width: calc(100% + 28px);
  margin: auto -14px 0;
  padding: 12px 14px max(16px, calc(env(safe-area-inset-bottom) + 10px));
  border-top: 1px solid var(--separator);
  background: var(--chrome-bg);
}

.meaning-action,
.round-actions {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.reveal-main .usage {
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
}

.reveal-main .scene {
  color: var(--text-secondary);
}

.reveal-block h3,
details.reveal-block summary {
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 600;
}

.reveal-block p {
  color: var(--text);
  font-size: 15px;
  line-height: 1.56;
}

.reveal-actions {
  padding: 0;
}

@media (hover: hover) {
  .nav-back-btn:hover:not(:disabled),
  .text-btn:hover:not(:disabled),
  .pronounce-btn:hover:not(:disabled),
  .word-group-toggle:hover:not(:disabled),
  .word-row:hover:not(:disabled),
  .sense-card:hover:not(:disabled) {
    background-color: transparent;
  }

  .text-btn:hover:not(:disabled) {
    color: var(--text-secondary);
  }

  .pronounce-btn:hover:not(:disabled) {
    border-color: var(--separator-strong);
    color: var(--text);
  }

  .word-group-toggle:hover:not(:disabled) {
    color: var(--text-secondary);
  }

  .nav-back-btn:hover:not(:disabled) {
    color: var(--text);
  }
}
