:root {
  --paper: #f7f2e8;
  --paper-2: #f1eadf;
  --panel: #fffdf8;
  --ink: #172033;
  --muted: #667085;
  --line: #ded2c0;
  --accent: #1f6f5f;
  --accent-blue: #2f7fd3;
  --soft-blue: #eef6ff;
  --soft-green: #e7f1ec;
  --soft-gold: #f5ead2;
  --soft-red: #fff1ef;
  --danger: #b42318;
  --success: #1f7a4d;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.58 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Noto Sans SC", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 54px;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.top-links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(255, 253, 248, .72);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  padding: 0 11px;
}

.top-links a:hover,
.top-links a:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 95, .13);
}

.hero-card,
.input-card,
.empty-state,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 14px rgba(23, 32, 51, .05);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 440px);
  gap: 22px;
  align-items: end;
  padding: clamp(22px, 4vw, 38px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 1;
  font-weight: 600;
}

h2 {
  margin: 0;
  font-size: clamp(19px, 2.2vw, 25px);
  line-height: 1.16;
}

h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.hero-copy {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.flow-strip {
  display: grid;
  gap: 8px;
  counter-reset: step;
}

.flow-strip span {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft-green);
  padding: 0 14px;
  font-weight: 850;
}

.flow-strip span::before {
  counter-increment: step;
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

.input-card,
.empty-state,
.card {
  margin-top: 16px;
  padding: clamp(16px, 2.4vw, 24px);
}

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

.section-subtitle {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
}

.mode-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #bfd5e9;
  border-radius: 999px;
  background: var(--soft-blue);
  color: #285f93;
  font-size: 12px;
  font-weight: 850;
  padding: 0 11px;
  white-space: nowrap;
}

.mode-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 12px;
}

.mode-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  padding: 0 13px;
}

.mode-tab.is-active {
  border-color: var(--accent);
  background: var(--soft-green);
  color: var(--accent);
}

.mode-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .68);
  margin: 0 0 12px;
  padding: 12px;
}

.mode-panel p {
  margin: 8px 0 0;
  color: var(--muted);
}

.mode-panel code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 1px 5px;
  color: var(--ink);
}

.bridge-status-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.bridge-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  padding: 0 10px;
  white-space: normal;
}

.bridge-status.checking {
  background: var(--soft-gold);
  color: #875a11;
}

.bridge-status.connected {
  background: var(--soft-green);
  color: var(--success);
}

.bridge-status.down {
  background: var(--soft-red);
  color: var(--danger);
}

#sentence-input {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 14px 15px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

#sentence-input:focus,
#practice-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(47, 127, 211, .14);
}

.command-row,
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.input-error {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 800;
}

.primary-command,
.secondary-command,
.ghost-command {
  min-height: 40px;
  border-radius: 999px;
  font-weight: 850;
  padding: 0 16px;
}

.primary-command {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.secondary-command {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-command {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.primary-command:hover,
.secondary-command:hover,
.ghost-command:hover,
.primary-command:focus-visible,
.secondary-command:focus-visible,
.ghost-command:focus-visible {
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(23, 32, 51, .08);
}

.empty-state {
  background: linear-gradient(135deg, rgba(255, 253, 248, .96), rgba(231, 241, 236, .72));
}

.empty-state p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
}

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

.card {
  margin-top: 0;
}

.card-wide {
  grid-column: 1 / -1;
}

.sentence-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-gold);
  padding: 14px;
}

.sentence-box span,
.small-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.sentence-box p,
.large-line,
.skeleton-card p,
.prompt-card p {
  margin: 0;
  font-size: 18px;
  line-height: 1.48;
}

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

.core-grid > div,
.skeleton-card,
.prompt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.zh {
  color: #344054;
}

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

.chunk-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  animation: cardIn .28s ease both;
}

.chunk-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 8px 0 0 8px;
  background: var(--accent-blue);
}

.chunk-text {
  margin: 0 0 9px;
  font-size: 18px;
  font-weight: 850;
}

.chunk-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: #285f93;
  font-size: 12px;
  font-weight: 850;
  padding: 0 9px;
}

.chunk-card p:last-child,
.difficulty-card p,
.rewrite-card p,
.replacement-note,
.hard-expression-note,
.practice-feedback {
  margin: 0;
  color: var(--muted);
}

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

.local-warning-list {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.local-warning-list p {
  margin: 0;
  border: 1px solid #c7d8ea;
  border-radius: 8px;
  background: var(--soft-blue);
  color: #285f93;
  font-weight: 800;
  padding: 10px 12px;
}

.hard-expression-card {
  display: grid;
  gap: 12px;
  border: 1px solid #b9d8cf;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(231, 241, 236, .92), rgba(255, 255, 255, .94));
  padding: 14px;
}

.hard-expression-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.hard-expression-title h3 {
  margin: 0;
  font-size: 20px;
}

.hard-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.simple-english {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
}

.hard-expression-detail {
  display: grid;
  gap: 9px;
  border-top: 1px solid rgba(31, 111, 95, .18);
  padding-top: 10px;
}

.hard-expression-detail strong,
.hard-expression-detail p {
  margin: 0;
}

.key-parts-block ul {
  display: grid;
  gap: 5px;
  margin: 6px 0 0;
  padding-left: 18px;
}

.key-parts-block li {
  color: var(--muted);
  font-size: 14px;
}

.key-parts-block li strong {
  color: var(--ink);
}

.hard-expression-note {
  margin-top: 12px;
  font-weight: 750;
}

.needs-review-section {
  margin-top: 12px;
  border: 1px dashed #c9b38c;
  border-radius: 8px;
  background: #fff8e8;
  padding: 13px;
}

.needs-review-section h3 {
  margin: 0 0 6px;
}

.needs-review-section p {
  margin: 0 0 8px;
  color: var(--muted);
}

.needs-review-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.dictionary-debug {
  margin-top: 10px;
  border: 1px solid #d7dde5;
  background: #f8fafc;
}

.dictionary-debug summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 850;
}

.dictionary-debug-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.dictionary-debug-body span {
  border: 1px solid #d7dde5;
  border-radius: 999px;
  background: #fff;
  color: #425466;
  font-size: 12px;
  font-weight: 850;
  padding: 7px 10px;
}

.difficulty-list,
.rewrite-list,
.replacement-table {
  display: grid;
  gap: 10px;
}

.difficulty-card,
.rewrite-card,
.replacement-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.difficulty-card {
  background: var(--soft-red);
}

.path-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 24px;
}

.path-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 13px;
}

.rewrite-card {
  border-color: #bfd5e9;
  background: var(--soft-blue);
}

.rewrite-card h3 {
  color: #285f93;
}

.rewrite-card .en {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 750;
}

.naturalize-section {
  border-color: #b9d9e8;
  background:
    linear-gradient(180deg, rgba(6, 182, 212, 0.08), transparent 34%),
    #fff;
}

.naturalize-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.34fr) minmax(0, 1fr);
  gap: 14px;
}

.naturalize-meaning,
.naturalize-variant,
.naturalize-change {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.naturalize-meaning p,
.naturalize-variant p,
.naturalize-change p {
  margin: 6px 0 0;
}

.naturalize-meaning {
  background: #f8fbff;
}

.naturalize-variants,
.naturalize-change-list {
  display: grid;
  gap: 10px;
}

.naturalize-variants {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
}

.naturalize-variant {
  border-color: #bfd5e9;
  background: var(--soft-blue);
}

.naturalize-variant p {
  color: #0b2239;
  font-size: clamp(17px, 1.8vw, 22px);
  font-weight: 780;
  line-height: 1.32;
}

.naturalize-changes {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.naturalize-changes ul {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding-left: 22px;
}

.naturalize-change {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.naturalize-change p {
  grid-column: 1 / -1;
  color: var(--muted);
}

.replacement-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.replacement-row strong {
  display: block;
}

.replacement-arrow {
  color: var(--accent);
  font-weight: 900;
}

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

.translation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.translation-card p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 18px;
  line-height: 1.55;
}

.translation-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 12px;
}

.practice-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.practice-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

#practice-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 15px;
}

#practice-input.is-wrong {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, .12);
}

#practice-input.is-correct {
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgba(31, 122, 77, .12);
}

.practice-feedback {
  min-height: 24px;
  margin-top: 10px;
  font-weight: 800;
}

.practice-feedback.correct {
  color: var(--success);
}

.practice-feedback.wrong {
  color: var(--danger);
}

.memory-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.memory-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-blue);
  padding: 13px;
}

.memory-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.stats-row span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  padding: 0 10px;
}

.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;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .hero-card,
  .output-grid,
  .core-grid,
  .chunk-list,
  .hard-expression-list,
  .translation-grid,
  .practice-grid,
  .naturalize-grid,
  .naturalize-variants {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

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

  .naturalize-change {
    grid-template-columns: 1fr;
  }

  .replacement-arrow {
    transform: rotate(90deg);
    width: max-content;
  }

  .mode-badge,
  .count-badge {
    white-space: normal;
    width: fit-content;
  }
}

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

/* Selectable visual themes. */
html[data-unpacker-theme] {
  --theme-grid-x: rgba(255, 255, 255, 0);
  --theme-grid-y: rgba(255, 255, 255, 0);
  --page-bg: linear-gradient(160deg, #08111f 0%, #10243a 48%, #07101d 100%);
  --hero-title-transform: none;
  --hero-title-shadow: none;
  --card-bg: rgba(13, 26, 45, 0.72);
  --card-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  --inner-bg: #13233a;
  --field-bg: #08111f;
  --chip-bg: rgba(34, 211, 238, 0.16);
  --flow-bg: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(132, 204, 22, 0.08));
  --naturalize-bg: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(132, 204, 22, 0.06)), rgba(13, 26, 45, 0.82);
  --primary-hover: #5eead4;
  --button-ink: #071019;
  color-scheme: dark;
}

html[data-unpacker-theme="dashboard"] {
  --paper: #08111f;
  --paper-2: #10243a;
  --panel: #0d1a2d;
  --ink: #f9fafb;
  --muted: #9fb0c6;
  --line: #24344d;
  --accent: #22d3ee;
  --accent-blue: #22d3ee;
  --accent-pink: #84cc16;
  --success: #84cc16;
}

html[data-unpacker-theme="app"] {
  --paper: #f8fafc;
  --paper-2: #eef2ff;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e2f2;
  --accent: #6366f1;
  --accent-blue: #6366f1;
  --accent-pink: #fb7185;
  --success: #1f7a4d;
  --page-bg: linear-gradient(155deg, #ffffff 0%, #f6f8ff 54%, #eaf4ff 100%);
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-shadow: 0 18px 48px rgba(79, 70, 229, 0.16);
  --inner-bg: #ffffff;
  --field-bg: #ffffff;
  --chip-bg: #e0e7ff;
  --flow-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(251, 113, 133, 0.08));
  --naturalize-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(251, 113, 133, 0.08)), #ffffff;
  --primary-hover: #4f46e5;
  --button-ink: #ffffff;
  color-scheme: light;
}

html[data-unpacker-theme="portfolio"] {
  --paper: #faf7f2;
  --paper-2: #eee7f8;
  --panel: #ffffff;
  --ink: #211f2b;
  --muted: #6c6877;
  --line: #d8d0e3;
  --accent: #5b5bd6;
  --accent-blue: #5b5bd6;
  --accent-pink: #b45309;
  --success: #0f766e;
  --page-bg: linear-gradient(155deg, #fbf7f1 0%, #f7f4ff 48%, #ffffff 100%);
  --card-bg: rgba(255, 255, 255, 0.78);
  --card-shadow: 0 14px 34px rgba(65, 55, 85, 0.13);
  --inner-bg: #ffffff;
  --field-bg: #ffffff;
  --chip-bg: rgba(91, 91, 214, 0.14);
  --flow-bg: linear-gradient(180deg, rgba(91, 91, 214, 0.10), rgba(180, 83, 9, 0.04));
  --naturalize-bg: linear-gradient(180deg, rgba(91, 91, 214, 0.10), rgba(180, 83, 9, 0.04)), #ffffff;
  --primary-hover: #4338ca;
  --button-ink: #ffffff;
  color-scheme: light;
}

html[data-unpacker-theme="motion"] {
  --paper: #050505;
  --paper-2: #171017;
  --panel: #111111;
  --ink: #fff7ed;
  --muted: #b8b1a6;
  --line: #333333;
  --accent: #facc15;
  --accent-blue: #facc15;
  --accent-pink: #ec4899;
  --success: #facc15;
  --theme-grid-x: rgba(250, 204, 21, 0.05);
  --theme-grid-y: rgba(236, 72, 153, 0.04);
  --page-bg: linear-gradient(145deg, #050505 0%, #171017 52%, #090909 100%);
  --hero-title-transform: uppercase;
  --hero-title-shadow: 0 0 32px rgba(250, 204, 21, 0.16);
  --card-bg: linear-gradient(145deg, rgba(255, 247, 237, 0.035), rgba(236, 72, 153, 0.035)), rgba(17, 17, 17, 0.84);
  --card-shadow: 0 24px 64px rgba(236, 72, 153, 0.20);
  --inner-bg: #111111;
  --field-bg: #050505;
  --chip-bg: rgba(250, 204, 21, 0.16);
  --flow-bg: linear-gradient(120deg, rgba(250, 204, 21, 0.16), rgba(236, 72, 153, 0.10)), #111111;
  --naturalize-bg: linear-gradient(120deg, rgba(250, 204, 21, 0.18), rgba(236, 72, 153, 0.10)), rgba(17, 17, 17, 0.88);
  --primary-hover: #fde047;
  --button-ink: #090909;
}

html[data-unpacker-theme="project"] {
  --paper: #f1f5f9;
  --paper-2: #dff3ec;
  --panel: #ffffff;
  --ink: #102024;
  --muted: #587070;
  --line: #cbded9;
  --accent: #0f766e;
  --accent-blue: #0f766e;
  --accent-pink: #2563eb;
  --success: #2563eb;
  --page-bg: linear-gradient(155deg, #fbfefe 0%, #edf8f4 52%, #f2f7ff 100%);
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-shadow: 0 16px 40px rgba(15, 118, 110, 0.14);
  --inner-bg: #ffffff;
  --field-bg: #ffffff;
  --chip-bg: rgba(15, 118, 110, 0.13);
  --flow-bg: linear-gradient(135deg, rgba(15, 118, 110, 0.11), rgba(37, 99, 235, 0.08));
  --naturalize-bg: linear-gradient(135deg, rgba(15, 118, 110, 0.11), rgba(37, 99, 235, 0.08)), #ffffff;
  --primary-hover: #115e59;
  --button-ink: #ffffff;
  color-scheme: light;
}

html[data-unpacker-theme] body {
  color: var(--ink);
  background:
    linear-gradient(90deg, var(--theme-grid-x) 1px, transparent 1px),
    linear-gradient(180deg, var(--theme-grid-y) 1px, transparent 1px),
    var(--page-bg);
  background-size: 42px 42px, 42px 42px, auto;
}

.visual-theme-switch {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0 0;
}

.visual-theme-switch span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.visual-theme-switch button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.visual-theme-switch button:hover,
.visual-theme-switch button:focus-visible,
.visual-theme-switch button[aria-pressed="true"] {
  outline: none;
  border-color: var(--accent);
  color: var(--button-ink);
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

html[data-unpacker-theme] .hero-card {
  background: transparent;
}

html[data-unpacker-theme] h1 {
  text-transform: var(--hero-title-transform);
  text-shadow: var(--hero-title-shadow);
}

html[data-unpacker-theme] .hero-card,
html[data-unpacker-theme] .input-card,
html[data-unpacker-theme] .empty-state,
html[data-unpacker-theme] .card {
  border-color: var(--line);
}

html[data-unpacker-theme] .input-card,
html[data-unpacker-theme] .empty-state,
html[data-unpacker-theme] .card {
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

html[data-unpacker-theme] .flow-strip span,
html[data-unpacker-theme] .mode-panel,
html[data-unpacker-theme] .translation-card,
html[data-unpacker-theme] .hard-expression-card,
html[data-unpacker-theme] .rewrite-card,
html[data-unpacker-theme] .replacement-row,
html[data-unpacker-theme] .sentence-box,
html[data-unpacker-theme] .core-grid > div,
html[data-unpacker-theme] .chunk-card,
html[data-unpacker-theme] .chunk-meta,
html[data-unpacker-theme] .difficulty-card,
html[data-unpacker-theme] .prompt-card,
html[data-unpacker-theme] .practice-form,
html[data-unpacker-theme] .stats-row span,
html[data-unpacker-theme] .naturalize-meaning,
html[data-unpacker-theme] .naturalize-variant,
html[data-unpacker-theme] .naturalize-change,
html[data-unpacker-theme] .path-list li,
html[data-unpacker-theme] .memory-card,
html[data-unpacker-theme] .practice-card,
html[data-unpacker-theme] .skeleton-card,
html[data-unpacker-theme] .dictionary-debug,
html[data-unpacker-theme] .needs-review-section {
  border-color: var(--line);
  background: var(--inner-bg);
  color: var(--ink);
}

html[data-unpacker-theme] .flow-strip span {
  background: var(--flow-bg);
}

html[data-unpacker-theme] .naturalize-section {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  background: var(--naturalize-bg);
}

html[data-unpacker-theme] .mode-tab,
html[data-unpacker-theme] .secondary-command,
html[data-unpacker-theme] .ghost-command,
html[data-unpacker-theme] .show-answer-button {
  border-color: var(--line);
  background: var(--inner-bg);
  color: var(--muted);
}

html[data-unpacker-theme] .mode-tab.is-active,
html[data-unpacker-theme] .primary-command {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--button-ink);
}

html[data-unpacker-theme] .primary-command:hover,
html[data-unpacker-theme] .primary-command:focus-visible {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

html[data-unpacker-theme] #sentence-input,
html[data-unpacker-theme] #practice-input {
  border-color: var(--line);
  background: var(--field-bg);
  color: var(--ink);
}

html[data-unpacker-theme] .count-badge,
html[data-unpacker-theme] .mode-badge,
html[data-unpacker-theme] .bridge-status.connected,
html[data-unpacker-theme] .stats-row span {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  background: var(--chip-bg);
  color: var(--accent);
}

html[data-unpacker-theme] .flow-strip span::before,
html[data-unpacker-theme] .chunk-card::before {
  background: linear-gradient(135deg, var(--accent), var(--accent-pink));
}

html[data-unpacker-theme] .replacement-arrow,
html[data-unpacker-theme] .read-more,
html[data-unpacker-theme] .hard-expression-title h3,
html[data-unpacker-theme] .rewrite-card h3,
html[data-unpacker-theme] .post-tags span {
  color: var(--accent);
}

html[data-unpacker-theme] .zh {
  color: var(--ink);
}

@media (max-width: 820px) {
  .visual-theme-switch {
    justify-content: flex-start;
  }
}

/* Match luckymiya.cc dark dashboard visual system. */
@font-face {
  font-family: "Luckymiya Sans SC";
  src: url("../assets/fonts/NotoSansSC-Regular.otf") format("opentype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --paper: #08111f;
  --paper-2: #10243a;
  --panel: #0d1a2d;
  --ink: #f9fafb;
  --muted: #9fb0c6;
  --line: #24344d;
  --accent: #22d3ee;
  --accent-blue: #22d3ee;
  --soft-blue: rgba(34, 211, 238, 0.14);
  --soft-green: rgba(132, 204, 22, 0.12);
  --soft-gold: rgba(250, 204, 21, 0.14);
  --soft-red: rgba(248, 113, 113, 0.14);
  --danger: #f87171;
  --success: #84cc16;
}

body {
  background: linear-gradient(160deg, #08111f 0%, #10243a 48%, #07101d 100%);
  font-family: "Luckymiya Sans SC", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Noto Sans SC", sans-serif;
}

.page-shell {
  width: min(1160px, calc(100vw - 40px));
  padding-top: 22px;
}

.top-links {
  justify-content: flex-end;
  gap: 22px;
  margin-bottom: 0;
  min-height: 66px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.top-links a {
  min-height: 34px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  padding: 0;
}

.top-links a:hover,
.top-links a:focus-visible {
  border-color: transparent;
  color: var(--accent);
  box-shadow: none;
}

.hero-card {
  min-height: min(720px, calc(100dvh - 88px));
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  align-items: center;
  padding: 42px 0 50px;
}

.hero-card,
.input-card,
.empty-state,
.card {
  border-color: var(--line);
  background: rgba(13, 26, 45, 0.72);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

.hero-card {
  background: transparent;
  box-shadow: none;
}

.eyebrow {
  color: var(--accent);
}

h1 {
  max-width: 760px;
  color: var(--ink);
  font-family: "Luckymiya Sans SC", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Noto Sans SC", sans-serif;
  font-size: clamp(56px, 8vw, 96px);
  line-height: .98;
  font-weight: 900;
}

h2,
h3,
.large-line,
.rewrite-card .en,
.naturalize-variant p,
.memory-card strong {
  color: var(--ink);
}

.hero-copy {
  max-width: 650px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.62;
}

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

.flow-strip span,
.mode-panel,
.translation-card,
.hard-expression-card,
.rewrite-card,
.replacement-row,
.sentence-box,
.core-grid > div,
.chunk-card,
.chunk-meta,
.difficulty-card,
.prompt-card,
.practice-form,
.stats-row span,
.naturalize-meaning,
.naturalize-variant,
.naturalize-change,
.path-list li,
.memory-card,
.practice-card,
.skeleton-card,
.dictionary-debug,
.needs-review-section {
  border-color: var(--line);
  background: #13233a;
  color: var(--ink);
}

.flow-strip span {
  min-height: 84px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
}

.flow-strip span::before {
  color: #071019;
  background: linear-gradient(135deg, var(--accent), #84cc16);
}

.input-card,
.empty-state,
.card {
  margin-top: 20px;
}

.section-subtitle,
.mode-badge,
.mode-panel p,
.translation-note,
.hard-expression-note,
.small-label,
.chunk-card p,
.difficulty-card p,
.memory-card p,
.notes-section li,
.path-list li,
.translation-card p,
.naturalize-meaning p,
.naturalize-change p {
  color: var(--muted);
}

.mode-selector {
  gap: 8px;
}

.mode-tab,
.secondary-command,
.ghost-command,
.show-answer-button {
  border-color: var(--line);
  background: #0d1a2d;
  color: var(--muted);
}

.mode-tab:hover,
.mode-tab:focus-visible,
.secondary-command:hover,
.secondary-command:focus-visible,
.ghost-command:hover,
.ghost-command:focus-visible,
.show-answer-button:hover,
.show-answer-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .13);
}

.mode-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #071019;
}

.mode-panel code {
  border-color: var(--line);
  background: #08111f;
  color: var(--accent);
}

#sentence-input,
#practice-input {
  border-color: var(--line);
  background: #08111f;
  color: var(--ink);
}

#sentence-input::placeholder,
#practice-input::placeholder {
  color: #71839d;
}

#sentence-input:focus,
#practice-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .16);
}

.primary-command {
  border-color: var(--accent);
  background: var(--accent);
  color: #071019;
}

.primary-command:hover,
.primary-command:focus-visible {
  border-color: #5eead4;
  background: #5eead4;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .18);
}

.count-badge,
.bridge-status.connected {
  border-color: rgba(34, 211, 238, .32);
  background: rgba(34, 211, 238, .16);
  color: #67e8f9;
}

.bridge-status.checking {
  background: rgba(250, 204, 21, .16);
  color: #fde047;
}

.bridge-status.down,
.input-error {
  color: var(--danger);
}

.bridge-status.down {
  background: rgba(248, 113, 113, .16);
}

.naturalize-section {
  border-color: rgba(34, 211, 238, .42);
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(132, 204, 22, 0.06)),
    rgba(13, 26, 45, 0.82);
}

.naturalize-variant {
  border-color: rgba(34, 211, 238, .24);
  background: rgba(34, 211, 238, .10);
}

.replacement-arrow,
.read-more,
.hard-expression-title h3,
.rewrite-card h3,
.post-tags span {
  color: var(--accent);
}

.dictionary-debug-body span,
.hard-badges .pill {
  border-color: var(--line);
  background: #08111f;
  color: var(--muted);
}

.practice-feedback.correct {
  color: var(--success);
}

.practice-feedback.wrong {
  color: var(--danger);
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 28px, 760px);
  }

  .top-links {
    justify-content: flex-start;
    gap: 14px;
    min-height: auto;
  }

  .hero-card {
    min-height: auto;
    padding: 34px 0 42px;
  }

  h1 {
    font-size: clamp(42px, 12vw, 68px);
  }
}

/* Match luckymiya.cc Motion theme. */
:root {
  --paper: #050505;
  --paper-2: #171017;
  --panel: #111111;
  --ink: #fff7ed;
  --muted: #b8b1a6;
  --line: #333333;
  --accent: #facc15;
  --accent-blue: #facc15;
  --accent-pink: #ec4899;
  --soft-blue: rgba(250, 204, 21, 0.14);
  --soft-green: rgba(236, 72, 153, 0.12);
  --soft-gold: rgba(250, 204, 21, 0.18);
  --soft-red: rgba(248, 113, 113, 0.14);
  --danger: #f87171;
  --success: #facc15;
}

body {
  background:
    linear-gradient(90deg, rgba(250, 204, 21, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(236, 72, 153, 0.04) 1px, transparent 1px),
    linear-gradient(145deg, #050505 0%, #171017 52%, #090909 100%);
  background-size: 42px 42px, 42px 42px, auto;
}

.top-links,
.hero-card {
  animation: motionEnter 420ms cubic-bezier(0.15, 0.85, 0.28, 1) both;
}

.input-card,
.empty-state,
.card {
  border-radius: 2px;
  background:
    linear-gradient(145deg, rgba(255, 247, 237, 0.035), rgba(236, 72, 153, 0.035)),
    rgba(17, 17, 17, 0.84);
  box-shadow: 0 24px 64px rgba(236, 72, 153, 0.20);
  animation: motionLiftIn 360ms cubic-bezier(0.15, 0.85, 0.28, 1) both;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.input-card {
  animation-delay: 80ms;
}

.empty-state,
#output > .card:nth-child(1) {
  animation-delay: 130ms;
}

#output > .card:nth-child(2) {
  animation-delay: 170ms;
}

#output > .card:nth-child(3) {
  animation-delay: 210ms;
}

.input-card:hover,
.card:hover {
  border-color: rgba(250, 204, 21, 0.58);
  transform: translateY(-2px);
  box-shadow: 0 30px 78px rgba(236, 72, 153, 0.26);
}

.hero-card {
  min-height: min(720px, calc(100dvh - 88px));
  border-bottom-color: var(--line);
  background: transparent;
}

.eyebrow,
.small-label,
.section-head h2,
.mode-badge,
.count-badge {
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  text-transform: uppercase;
  text-shadow: 0 0 32px rgba(250, 204, 21, 0.16);
}

.hero-copy {
  color: var(--muted);
}

.top-links a {
  transition: color 160ms ease, transform 160ms ease;
}

.top-links a:hover,
.top-links a:focus-visible {
  color: var(--accent);
  transform: translateY(-1px);
}

.flow-strip span,
.mode-panel,
.translation-card,
.hard-expression-card,
.rewrite-card,
.replacement-row,
.naturalize-meaning,
.naturalize-variant,
.naturalize-change,
.path-list li,
.memory-card,
.practice-card,
.skeleton-card,
.dictionary-debug,
.needs-review-section {
  border-radius: 2px;
  border-color: var(--line);
  background: #1f1f1f;
}

.flow-strip span {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(250, 204, 21, 0.16), rgba(236, 72, 153, 0.10)),
    #111111;
  animation: motionLiftIn 360ms cubic-bezier(0.15, 0.85, 0.28, 1) both;
}

.flow-strip span:nth-child(1) { animation-delay: 80ms; }
.flow-strip span:nth-child(2) { animation-delay: 125ms; }
.flow-strip span:nth-child(3) { animation-delay: 170ms; }
.flow-strip span:nth-child(4) { animation-delay: 215ms; }

.flow-strip span::before {
  color: #090909;
  background: linear-gradient(135deg, var(--accent), var(--accent-pink));
}

.mode-tab,
.secondary-command,
.ghost-command,
.show-answer-button,
.primary-command {
  border-radius: 2px;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.mode-tab,
.secondary-command,
.ghost-command,
.show-answer-button {
  background: #111111;
  color: var(--muted);
}

.mode-tab:hover,
.mode-tab:focus-visible,
.secondary-command:hover,
.secondary-command:focus-visible,
.ghost-command:hover,
.ghost-command:focus-visible,
.show-answer-button:hover,
.show-answer-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, .16);
}

.mode-tab.is-active,
.primary-command {
  border-color: var(--accent);
  background: var(--accent);
  color: #090909;
}

.primary-command:hover,
.primary-command:focus-visible {
  border-color: #fde047;
  background: #fde047;
  transform: translateY(-2px);
  box-shadow:
    0 0 0 3px rgba(250, 204, 21, .20),
    0 18px 42px rgba(236, 72, 153, .22);
}

.primary-command:active,
.secondary-command:active,
.ghost-command:active,
.mode-tab:active,
.show-answer-button:active {
  transform: translateY(0) scale(.98);
}

#sentence-input,
#practice-input {
  border-radius: 2px;
  background: #050505;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

#sentence-input:focus,
#practice-input:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 4px rgba(250, 204, 21, .18),
    0 18px 42px rgba(236, 72, 153, .12);
  transform: translateY(-1px);
}

.count-badge,
.mode-badge,
.bridge-status.connected {
  border-color: rgba(250, 204, 21, .36);
  background: rgba(250, 204, 21, .16);
  color: #fde047;
}

.naturalize-section {
  border-color: rgba(250, 204, 21, .52);
  background:
    linear-gradient(120deg, rgba(250, 204, 21, 0.18), rgba(236, 72, 153, 0.10)),
    rgba(17, 17, 17, 0.88);
}

.naturalize-variant {
  border-color: rgba(236, 72, 153, .34);
  background:
    linear-gradient(145deg, rgba(236, 72, 153, .12), rgba(250, 204, 21, .08)),
    #111111;
}

.sentence-box,
.core-grid > div,
.chunk-card,
.prompt-card,
.practice-form {
  background: #111111;
}

.sentence-box {
  border-color: rgba(250, 204, 21, .32);
  background:
    linear-gradient(120deg, rgba(250, 204, 21, .18), rgba(250, 204, 21, .06)),
    #111111;
}

.chunk-card::before {
  background: linear-gradient(180deg, var(--accent), var(--accent-pink));
}

.chunk-meta,
.hard-badges .pill {
  background: #050505;
  color: var(--muted);
}

.difficulty-card {
  border-color: rgba(248, 113, 113, .34);
  background:
    linear-gradient(145deg, rgba(248, 113, 113, .14), rgba(236, 72, 153, .08)),
    #111111;
}

.practice-form {
  border-color: rgba(250, 204, 21, .28);
}

.stats-row span {
  border-radius: 2px;
  background: #050505;
  color: var(--muted);
}

.zh {
  color: var(--ink);
}

.replacement-arrow,
.read-more,
.hard-expression-title h3,
.rewrite-card h3,
.post-tags span {
  color: var(--accent);
}

.dictionary-debug-body span,
.hard-badges .pill {
  border-radius: 2px;
  background: #050505;
}

@keyframes motionEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes motionLiftIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 820px) {
  .hero-card {
    min-height: auto;
  }

  .flow-strip span {
    min-height: 70px;
  }
}

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