:root {
  color-scheme: light;
  --ink: #162018;
  --muted: #68706a;
  --line: #d9dfd8;
  --paper: #f7f8f4;
  --panel: #ffffff;
  --panel-soft: #eef3ea;
  --green: #2e6f4f;
  --green-dark: #1f4f39;
  --blue: #315f8a;
  --coral: #c65f4a;
  --amber: #b6822c;
  --shadow: 0 18px 55px rgba(28, 39, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f5f7f1 0%, #edf3f5 52%, #f7f1ec 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.brand h1,
.topbar h2,
.input-panel h3,
.pending-panel h3,
.review-side h3,
.upgrade-bank h3 {
  margin: 0;
}

.brand h1 {
  max-width: 240px;
  font-size: 30px;
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sheet-nav {
  display: grid;
  gap: 10px;
}

.nav-button,
.stage-step,
.mode-tab {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}

.nav-button {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  text-align: left;
}

.nav-button span {
  font-weight: 800;
}

.nav-button small,
.status-panel span,
.metric-strip small,
.helper-text,
.word-meta,
.feedback {
  color: var(--muted);
}

.nav-button.active {
  border-color: rgba(46, 111, 79, 0.28);
  background: var(--panel-soft);
}

.status-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-panel strong,
.status-panel span {
  display: block;
}

.status-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.18;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 10px;
  min-width: 280px;
}

.metric-strip div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  text-align: center;
}

.metric-strip span {
  display: block;
  color: var(--green-dark);
  font-size: 24px;
  font-weight: 900;
}

.sheet {
  display: none;
}

.sheet.active {
  display: block;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
}

.review-stage,
.review-side,
.input-panel,
.pending-panel,
.backup-panel,
.upgrade-card,
.upgrade-bank {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.review-stage {
  min-height: 620px;
  overflow: hidden;
}

.stage-rail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: #f9faf7;
}

.stage-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  border-right: 1px solid var(--line);
  border-radius: 0;
}

.stage-step:last-child {
  border-right: 0;
}

.stage-step span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #e2e8df;
  color: var(--green-dark);
  font-weight: 900;
}

.stage-step.active {
  background: #eaf2ee;
  color: var(--green-dark);
}

.review-card {
  padding: 32px;
}

.word-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.word-title h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef3f5;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.definition {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.45;
}

.example {
  margin: 18px 0;
  padding-left: 16px;
  border-left: 4px solid var(--amber);
  color: #334039;
  line-height: 1.7;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
}

.tag {
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #d8e0e5;
  border-radius: 8px;
  background: #f7fbfc;
  color: #284f72;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-action,
.secondary-action,
.danger-action,
.audio-button,
.choice-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: #fff;
}

.secondary-action {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-action {
  border-color: rgba(198, 95, 74, 0.24);
  background: #fff4f1;
  color: #9f3f2d;
}

.audio-button {
  background: var(--blue);
  color: #fff;
}

.review-input,
.upgrade-input {
  width: 100%;
  min-height: 58px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 20px;
}

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

.choice-button {
  min-height: 72px;
  border-color: var(--line);
  background: #fff;
  text-align: left;
  line-height: 1.35;
}

.choice-button.selected {
  border-color: var(--blue);
  background: #edf5fb;
}

.choice-button.correct {
  border-color: var(--green);
  background: #eaf5ee;
}

.choice-button.wrong {
  border-color: var(--coral);
  background: #fff0ed;
}

.unsure-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
}

.review-side {
  padding: 20px;
}

.queue-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.queue-filter,
.expression-filter {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.queue-filter.active,
.expression-filter.active {
  border-color: var(--green);
  background: #eaf5ee;
  color: var(--green-dark);
}

.word-queue,
.pending-list,
.expression-bank {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.queue-item,
.pending-item,
.bank-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.queue-item.active {
  border-color: var(--green);
  background: #f0f7f3;
}

.bank-item.active {
  border-color: var(--blue);
  background: #edf5fb;
}

.queue-item strong,
.pending-item strong,
.bank-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.word-meta {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(340px, 1fr);
  gap: 22px;
}

.input-panel,
.pending-panel,
.backup-panel {
  padding: 22px;
}

.pending-panel,
.backup-panel {
  grid-column: 1 / -1;
}

.word-form,
.expression-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: #2e3b33;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

.helper-text {
  margin: 10px 0 12px;
  line-height: 1.6;
}

.batch-box {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.section-heading span {
  color: var(--muted);
}

.section-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-action {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.review-insights {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.insight-tile {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.insight-tile strong {
  display: block;
  color: var(--green-dark);
  font-size: 22px;
}

.insight-tile span {
  color: var(--muted);
  font-size: 12px;
}

.pending-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.upgrade-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
}

.mode-tabs {
  grid-column: 1 / -1;
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.mode-tab {
  min-width: 160px;
  min-height: 46px;
  border-radius: 0;
}

.mode-tab.active {
  background: var(--green);
  color: #fff;
}

.upgrade-card,
.upgrade-bank {
  padding: 24px;
}

.bank-heading {
  margin-top: 28px;
}

.prompt-text {
  margin: 0;
  color: var(--muted);
}

.prompt-main {
  margin: 12px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.15;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101b14;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

  .brand h1 {
    max-width: none;
    font-size: 26px;
  }

  .sheet-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .review-layout,
  .upgrade-layout,
  .import-grid {
    grid-template-columns: 1fr;
  }

  .review-layout,
  .upgrade-layout {
    display: grid;
  }

  .topbar {
    display: grid;
  }

  .metric-strip {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .sheet-nav,
  .stage-rail,
  .choice-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .nav-button {
    padding: 12px;
  }

  .stage-step {
    justify-content: flex-start;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .review-card,
  .upgrade-card,
  .upgrade-bank,
  .input-panel,
  .pending-panel {
    padding: 18px;
  }

  .pending-item {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .mode-tab {
    width: 100%;
  }
}
