/* ---------------------------------------------------------------- */
/* Design tokens                                                     */
/* ---------------------------------------------------------------- */

:root {
  color-scheme: light;
  --font-ui: "Avenir Next", "SF Pro Text", -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-word: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC",
    "Noto Serif SC", Georgia, serif;

  --bg: #f5f2ea;
  --bg-deep: #efeae0;
  --surface: #fffdf8;
  --surface-2: #f3efe5;
  --surface-3: #eae4d6;
  --ink: #211f19;
  --ink-soft: #3b372d;
  --muted: #756f60;
  --faint: #9a9383;
  --line: #e3ddd0;
  --line-strong: #d4ccba;

  --accent: #266a4a;
  --accent-strong: #1c5338;
  --accent-soft: #e3efe5;
  --accent-ink: #fffdf8;

  --danger: #b24338;
  --danger-soft: #f9e8e4;
  --warn: #97630f;
  --warn-soft: #f8edd6;
  --info: #3b628c;
  --info-soft: #e7eef7;

  --shadow-sm: 0 1px 2px rgba(35, 30, 18, 0.05);
  --shadow: 0 20px 44px -28px rgba(40, 34, 20, 0.4);
  --radius: 18px;
  --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111310;
    --bg-deep: #0d0f0c;
    --surface: #191c16;
    --surface-2: #20241c;
    --surface-3: #272c22;
    --ink: #ece9dd;
    --ink-soft: #d6d2c4;
    --muted: #a19c8b;
    --faint: #7a7567;
    --line: #2d3228;
    --line-strong: #3b4134;

    --accent: #86c9a4;
    --accent-strong: #a6dcbc;
    --accent-soft: #1f3327;
    --accent-ink: #0e1d14;

    --danger: #e08a80;
    --danger-soft: #3a2421;
    --warn: #dfb36c;
    --warn-soft: #372e1f;
    --info: #8fb4dc;
    --info-soft: #1f2c3b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 20px 44px -28px rgba(0, 0, 0, 0.7);
  }
}

/* ---------------------------------------------------------------- */
/* Base                                                              */
/* ---------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 12% -8%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 62%),
    radial-gradient(900px 480px at 108% 6%, color-mix(in srgb, var(--warn) 7%, transparent), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 700;
}

a {
  color: var(--accent);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- */
/* Shell                                                             */
/* ---------------------------------------------------------------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-mark {
  width: 33px;
  height: 33px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  flex: none;
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand small {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--faint);
  margin-top: 2px;
  text-transform: uppercase;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  border: 1px solid var(--line);
}

.nav a {
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav a:hover {
  color: var(--ink);
}

.nav a.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.app-footer {
  max-width: 1080px;
  margin: 48px auto 0;
  padding: 20px 24px 40px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--faint);
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--accent);
}

.footer-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--faint);
}

/* ---------------------------------------------------------------- */
/* Shared pieces                                                     */
/* ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

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

.card-head > div {
  display: flex;
  align-items: center;
  min-width: 0;
}

.card-head h2 {
  font-size: 1.08rem;
  margin: 0;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-right: 10px;
  flex: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
  flex: none;
}

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

.small {
  font-size: 12.5px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 20px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    transform 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 22px -14px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-quiet {
  background: var(--surface-2);
  color: var(--ink-soft);
}

.btn-quiet:hover {
  background: var(--surface-3);
}

.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 12.5px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

.link-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  flex: none;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.boot-screen,
.loading-page {
  min-height: 58vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.boot-screen .spinner,
.loading-page .spinner {
  color: var(--accent);
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field > span {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

input,
textarea,
select {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
  resize: vertical;
  min-height: 150px;
  line-height: 1.75;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%238f897a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.field-help {
  font-size: 12px;
  color: var(--faint);
  margin: 0;
}

.field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.field input[type="range"]::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.range-value {
  float: right;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.form-row {
  display: flex;
  gap: 14px;
}

.form-row.split > .field:first-child {
  flex: 1.7;
}

.form-row.split > .field:last-child {
  flex: 1;
}

.form-error {
  margin: 14px 0 0;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.form-status {
  margin: 14px 0 0;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.form-status.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.form-status.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.live {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.done {
  background: var(--accent-soft);
  color: var(--accent);
}

.ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  text-decoration: none;
}

a.ai-pill:hover {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.ai-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.ai-pill.ok .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-pill.off .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

/* Progress */

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 62%, var(--info)));
  transition: width 0.4s ease;
}

/* Banners */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  background: var(--warn-soft);
  margin-bottom: 16px;
  font-size: 13px;
}

.banner strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.banner p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.empty-state {
  text-align: center;
  padding: 46px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.empty-state .empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--faint);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.empty-state h3 {
  font-size: 1rem;
  margin: 0 0 6px;
  color: var(--ink);
}

.empty-state p {
  font-size: 13px;
  margin: 0;
}

/* ---------------------------------------------------------------- */
/* Home                                                              */
/* ---------------------------------------------------------------- */

.hero {
  padding: 58px 0 34px;
  max-width: 760px;
}

.hero h1 {
  font-size: clamp(2.2rem, 5.2vw, 3.55rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
  margin: 16px 0 18px;
  font-weight: 750;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero .lede {
  max-width: 52ch;
  margin: 0;
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--muted);
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.hero-chips span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.hero-chips span::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(270px, 0.78fr);
  gap: 20px;
  align-items: start;
}

.create-card {
  padding: 26px;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.create-form textarea {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13.5px;
  min-height: 178px;
}

.source-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.source-tab {
  appearance: none;
  border: 0;
  padding: 7px 14px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.source-tab:hover {
  color: var(--ink);
}

.source-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.source-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pane-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: -4px;
  font-size: 11.5px;
  color: var(--faint);
}

.md-drop {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.md-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.md-badge {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.md-drop-text {
  flex: 1;
  min-width: 0;
}

.md-drop-text strong {
  display: block;
  font-size: 13.5px;
}

.md-drop-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.md-file-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--faint);
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.create-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.create-footer-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.create-footer-info p {
  margin: 0;
  line-height: 1.5;
}

.create-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: -4px;
}

.format-hints {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--faint);
}

.create-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.create-actions p {
  margin: 0;
  max-width: 38ch;
  line-height: 1.5;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.how-card h2 {
  font-size: 0.95rem;
  margin-bottom: 18px;
}

.how-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.how-list li {
  display: flex;
  gap: 12px;
}

.how-list li > span {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex: none;
  margin-top: 1px;
}

.how-list strong {
  display: block;
  font-size: 13.5px;
}

.how-list p {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 18px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-sm);
}

.mini-stats div {
  text-align: center;
  min-width: 0;
}

.mini-stats strong {
  display: block;
  font-family: var(--font-word);
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.mini-stats span {
  display: block;
  font-size: 10.5px;
  margin-top: 4px;
  color: color-mix(in srgb, var(--bg) 62%, transparent);
  white-space: nowrap;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 46px 0 18px;
}

.section-head h2 {
  font-size: 1.25rem;
  margin: 0 0 4px;
}

.section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.section-head.compact {
  margin: 0 0 14px;
  align-items: center;
}

.section-head.compact h2 {
  font-size: 1rem;
}

.section-head.compact span {
  font-size: 12px;
  color: var(--faint);
}

.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 15px;
}

.list-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

.list-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.list-top .date {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--faint);
  text-transform: uppercase;
}

.list-card h3 {
  font-size: 1.02rem;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.list-card .progress {
  margin-bottom: 12px;
}

.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--faint);
}

.list-foot .go {
  color: var(--accent);
  font-weight: 700;
}

.inline-warn {
  margin-top: 10px;
  font-size: 11px;
  color: var(--warn);
}

/* ---------------------------------------------------------------- */
/* Detail / practice                                                 */
/* ---------------------------------------------------------------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 22px;
}

.back-link:hover {
  color: var(--accent);
}

.detail-head {
  padding: 22px 0 26px;
}

.detail-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.detail-meta {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--faint);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.detail-head h1 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  margin: 0;
  overflow-wrap: anywhere;
}

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
}

.meta-chips span {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.meta-chips .source-chip {
  max-width: min(100%, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

.practice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 19px 22px;
  margin-bottom: 16px;
}

.practice-head-main {
  min-width: 0;
}

.round-label {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}

.round-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

.round-sub strong {
  color: var(--ink);
}

.round-limit-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.round-limit-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.round-limit-row input[type="number"] {
  width: 72px;
  padding: 6px 8px;
  font-size: 13px;
  text-align: center;
}

.round-limit-row > span {
  color: var(--faint);
  font-size: 11px;
}

.round-progress {
  width: 210px;
  flex: none;
}

.round-progress > span {
  display: block;
  font-size: 11.5px;
  color: var(--faint);
  text-align: right;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.word-form {
  padding: 0;
  overflow: visible;
}

.word-list {
  display: flex;
  flex-direction: column;
}

.word-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 16px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.word-row.is-active {
  background: color-mix(in srgb, var(--accent-soft) 58%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.word-row.is-active .answer-input {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: var(--surface);
}

.word-row.is-viewed {
  background: color-mix(in srgb, var(--warn-soft) 48%, transparent);
}

.word-row.is-viewed .word-text {
  color: var(--muted);
}

.answer-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.meaning-toggle {
  align-self: flex-end;
  font-size: 11.5px;
}

.revealed-meaning {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 8px;
  padding: 10px 12px;
  border: 1px dashed color-mix(in srgb, var(--warn) 42%, var(--line-strong));
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn-soft) 58%, var(--surface-2));
  font-size: 13px;
  line-height: 1.55;
}

.revealed-meaning[hidden] {
  display: none;
}

.revealed-meaning .label {
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.revealed-meaning-text {
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.locked-note {
  color: var(--warn);
  font-size: 10.5px;
  font-weight: 650;
}

.viewed-blank {
  color: var(--warn);
}

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

.word-index {
  font-size: 11px;
  font-weight: 650;
  color: var(--faint);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.word-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.word-text {
  font-family: var(--font-word);
  font-size: 1.38rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.word-meta {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0;
  white-space: nowrap;
}

.streak {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.answer-input {
  font-size: 14px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 8;
  padding: 10px 12px 12px;
  background: linear-gradient(to top, var(--bg) 58%, transparent);
}

.submit-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.answer-progress {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.answer-progress strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.submit-hint {
  font-size: 11px;
  color: var(--faint);
  margin-left: auto;
  white-space: nowrap;
}

.submit-inner .btn {
  flex: none;
}

/* Results */

.score-card {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.score-card.is-done {
  background:
    radial-gradient(120% 150% at 100% 0%, var(--accent-soft), transparent 58%),
    var(--surface);
}

.score-ring {
  width: 98px;
  height: 98px;
  border-radius: 50%;
  flex: none;
  background: conic-gradient(var(--accent) var(--pct), var(--surface-3) 0);
  display: grid;
  place-items: center;
  position: relative;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--surface);
}

.score-ring > div {
  position: relative;
  display: flex;
  align-items: baseline;
  font-family: var(--font-word);
  letter-spacing: -0.03em;
}

.score-ring strong {
  font-size: 1.9rem;
  line-height: 1;
}

.score-ring span {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 1px;
}

.score-main {
  min-width: 0;
}

.score-main h2 {
  font-size: 1.55rem;
  margin: 4px 0 7px;
}

.score-main > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.score-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.inline-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.inline-note.warn {
  color: var(--warn);
}

.result-group {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.result-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.result-group-head h3 {
  margin: 0;
  font-size: 13.5px;
}

.result-group-head span {
  font-size: 11.5px;
  color: var(--muted);
}

.result-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.result-row:last-child {
  border-bottom: 0;
}

.result-row.bad {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--danger-soft) 70%, transparent),
    transparent 62%
  );
}

.result-row.ok {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--accent-soft) 55%, transparent),
    transparent 58%
  );
}

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

.result-word-wrap {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.result-word {
  font-family: var(--font-word);
  font-size: 1.2rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.result-meta {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0;
}

.verdict {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.verdict.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.verdict.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.verdict.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.result-badges {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.error-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.error-badge.spelling {
  background: var(--warn-soft);
  color: var(--warn);
}

.error-badge.meaning,
.error-badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.answer-block {
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13.5px;
  min-height: 52px;
  overflow-wrap: anywhere;
}

.answer-block .label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 2px;
}

.answer-block .blank {
  color: var(--faint);
}

.answer-block.answer-viewed {
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  background: color-mix(in srgb, var(--warn-soft) 82%, var(--surface-2));
}

.answer-block.answer-viewed .label {
  color: var(--warn);
}

.answer-block.answer-bad {
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  background: color-mix(in srgb, var(--danger-soft) 82%, var(--surface-2));
}

.answer-block.answer-bad .label {
  color: var(--danger);
}

.result-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.source {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--faint);
  font-size: 10px;
  white-space: nowrap;
}

.source.ai {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Done / confetti */

.done-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 46px 28px 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(80% 130% at 50% 0%, var(--accent-soft), transparent 68%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.done-mark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 14px 32px -14px color-mix(in srgb, var(--accent) 85%, transparent);
  position: relative;
  z-index: 1;
}

.done-mark svg {
  width: 30px;
  height: 30px;
}

.done-hero h2 {
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  margin: 0 0 8px;
  position: relative;
  z-index: 1;
}

.done-hero > p {
  margin: 0 auto;
  max-width: 46ch;
  color: var(--muted);
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.done-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 36px;
  margin: 26px 0 4px;
  position: relative;
  z-index: 1;
}

.done-stats strong {
  display: block;
  font-family: var(--font-word);
  font-size: 1.45rem;
  line-height: 1.2;
}

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

.done-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -28px;
  width: 7px;
  height: 13px;
  border-radius: 2px;
  opacity: 0.8;
  animation: confetti-fall 3.4s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.9;
  }
  100% {
    transform: translateY(430px) rotate(560deg);
    opacity: 0;
  }
}

/* History */

.history-section {
  margin-top: 38px;
}

.round-card {
  margin-bottom: 9px;
  padding: 0;
  overflow: hidden;
}

.round-card summary {
  list-style: none;
  display: grid;
  grid-template-columns: auto 1fr auto 16px;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.round-card summary::-webkit-details-marker {
  display: none;
}

.round-card summary:hover {
  background: var(--surface-2);
}

.round-n {
  font-size: 13.5px;
  font-weight: 700;
}

.round-score {
  font-size: 12.5px;
  color: var(--muted);
}

.round-date {
  font-size: 11.5px;
  color: var(--faint);
  text-align: right;
  white-space: nowrap;
}

.chev {
  color: var(--faint);
  font-size: 11px;
  transition: transform 0.18s ease;
  text-align: center;
}

details[open] > summary .chev {
  transform: rotate(180deg);
}

.round-body {
  border-top: 1px solid var(--line);
}

/* Edit / danger */

.edit-panel {
  margin-top: 26px;
  padding: 0;
  overflow: hidden;
}

.edit-panel > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
}

.edit-panel > summary::-webkit-details-marker {
  display: none;
}

.edit-panel > summary:hover {
  background: var(--surface-2);
}

.summary-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--faint);
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--line);
}

.edit-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

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

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.danger-zone {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 30px 0 8px;
  font-size: 11.5px;
  color: var(--faint);
}

/* Mastered */

.mastered-panel {
  margin-top: 22px;
  padding: 0;
  overflow: hidden;
}

.mastered-panel > summary {
  list-style: none;
  padding: 15px 20px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mastered-panel > summary::-webkit-details-marker {
  display: none;
}

.mastered-panel > summary:hover {
  background: var(--surface-2);
}

.mastered-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
}

.mastered-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12.5px;
}

.mastered-item strong {
  font-family: var(--font-word);
  font-size: 14px;
  font-weight: 600;
}

.mastered-item span {
  color: var(--muted);
  text-align: right;
}

/* ---------------------------------------------------------------- */
/* History page                                                      */
/* ---------------------------------------------------------------- */

.page-head {
  padding: 54px 0 30px;
  max-width: 740px;
}

.page-head h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  margin: 12px 0 12px;
}

.page-head .lede {
  margin: 0;
  color: var(--muted);
  font-size: 15.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 13px;
  margin-bottom: 38px;
}

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-family: var(--font-word);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.stat-value small {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 3px;
}

.stat-label {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.history-list {
  padding: 0;
  overflow: hidden;
}

.history-translation-head {
  margin-top: 46px;
}

.history-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 150px auto 16px;
  align-items: center;
  gap: 18px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  list-style: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.history-row::-webkit-details-marker {
  display: none;
}

.history-row:last-child {
  border-bottom: 0;
}

.history-row:hover {
  background: var(--surface-2);
}

.history-entry[open] > .history-row {
  background: var(--surface-2);
}

.history-entry:last-child > .history-row {
  border-bottom: 0;
}

.history-entry-body {
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 42%, transparent);
}

.history-entry-body[hidden] {
  display: none;
}

.history-entry:last-child .history-entry-body {
  border-bottom: 0;
}

.history-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  color: var(--muted);
  font-size: 11.5px;
}

.history-entry-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.history-entry-body .round-card {
  margin-bottom: 8px;
}

.history-entry-body .round-card:last-child {
  margin-bottom: 0;
}

.history-date {
  text-align: center;
  border-right: 1px solid var(--line);
  padding-right: 12px;
}

.history-date strong {
  display: block;
  font-family: var(--font-word);
  font-size: 1.45rem;
  line-height: 1.1;
}

.history-date span {
  font-size: 10.5px;
  color: var(--muted);
}

.history-main {
  min-width: 0;
}

.history-main h3 {
  font-size: 14.5px;
  margin: 0 0 3px;
  overflow-wrap: anywhere;
}

.history-main p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.history-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- */
/* Settings                                                          */
/* ---------------------------------------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.settings-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

#embedding-api-fields {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#embedding-api-fields[hidden] {
  display: none;
}

#embedding-api-fields > .btn {
  align-self: flex-start;
}

.preset-row button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preset-row button {
  appearance: none;
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.preset-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 2px;
}

.simple-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.simple-list li {
  padding-left: 14px;
  position: relative;
}

.simple-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
}

.simple-list code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- */
/* Toast & dialog                                                    */
/* ---------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 120;
  width: min(92vw, 480px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
  animation: toast-in 0.22s ease both;
}

.toast::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  margin-top: 7px;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast.error::before {
  background: #fff;
}

.toast.warn {
  background: var(--warn);
  color: #fff;
}

.toast.warn::before {
  background: #fff;
}

.toast.leaving {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

.dialog {
  border: 0;
  padding: 0;
  width: min(430px, 92vw);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  backdrop-filter: blur(3px);
}

.dialog-body {
  padding: 26px 26px 8px;
}

.dialog-body h3 {
  font-size: 1.08rem;
  margin: 0 0 9px;
}

.dialog-body p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 20px 26px 24px;
}

/* ---------------------------------------------------------------- */
/* Dictation                                                         */
/* ---------------------------------------------------------------- */

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 20px;
}

.mode-tab {
  padding: 7px 16px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.dictation-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.switch-copy {
  flex: 1;
  min-width: 0;
}

.switch-copy strong {
  display: block;
  font-size: 13.5px;
}

.switch-copy small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch-row input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-row input:checked + .switch-track::after {
  transform: translateX(18px);
  background: var(--accent-ink);
}

.switch-row input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-row input:disabled + .switch-track {
  opacity: 0.5;
}

.dictation-panel {
  padding: 22px 24px;
  scroll-margin-top: 90px;
}

.dictation-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dictation-topline .round-label {
  margin-bottom: 0;
}

.dictation-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dictation-count strong {
  color: var(--ink);
  font-size: 15px;
}

.dictation-play {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--line);
}

.play-orb {
  width: 96px;
  height: 96px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 18px 32px -18px color-mix(in srgb, var(--accent) 85%, transparent);
  transition: transform 0.18s ease, background 0.18s ease;
}

.play-orb svg {
  width: 38px;
  height: 38px;
}

.play-orb:hover {
  background: var(--accent-strong);
  transform: scale(1.03);
}

.play-orb:active {
  transform: scale(0.98);
}

.play-orb.playing {
  animation: speaker-pulse 1.2s ease-in-out infinite;
}

@keyframes speaker-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 38%, transparent);
  }
  50% {
    box-shadow: 0 0 0 16px transparent;
  }
}

.dictation-play-copy {
  min-width: 0;
}

.dictation-play-copy strong {
  display: block;
  font-size: 1.02rem;
}

.dictation-play-copy p {
  margin: 4px 0 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.dictation-play-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dictation-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 20px;
}

.field-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 700;
}

.field-tag.required {
  background: var(--warn-soft);
  color: var(--warn);
}

.dictation-nav {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.dictation-live-feedback {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.dictation-live-feedback .result-row {
  border-bottom: 0;
}

.dictation-fields input:disabled {
  opacity: 0.78;
  cursor: not-allowed;
}

.dictation-fill {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--muted);
}

.dictation-fill .progress {
  flex: 1;
}

.dictation-map {
  margin-top: 16px;
  padding: 18px 20px;
}

.dictation-map-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
}

.dictation-map-head span {
  font-size: 11px;
  color: var(--faint);
}

.dictation-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px;
}

.map-dot {
  appearance: none;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.map-dot:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.map-dot.filled,
.map-dot.correct {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
}

.map-dot.wrong {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  color: var(--danger);
}

.map-dot.current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 5px 12px -7px color-mix(in srgb, var(--accent) 80%, transparent);
}

.score-substats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.score-substats span {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
}

.dictation-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.answer-block.spelling-bad,
.answer-block.meaning-bad {
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  background: color-mix(in srgb, var(--danger-soft) 82%, var(--surface-2));
}

.answer-block.spelling-bad .label,
.answer-block.meaning-bad .label {
  color: var(--danger);
}

.answer-block.answer-correct {
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface-2));
}

.answer-block.answer-correct .label {
  color: var(--accent);
}

/* ---------------------------------------------------------------- */
/* Wheel battle                                                      */
/* ---------------------------------------------------------------- */

.wheel-entry {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 22px;
  padding: 20px 24px;
  background:
    radial-gradient(120% 150% at 100% 0%, var(--accent-soft), transparent 58%),
    var(--surface);
}

.wheel-entry-copy {
  flex: 1;
  min-width: 0;
}

.wheel-entry-copy h2 {
  margin: 4px 0 6px;
  font-size: 1.25rem;
}

.wheel-entry-copy p {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.wheel-entry-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex: none;
}

.wheel-entry-stats > div {
  min-width: 68px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

.wheel-entry-stats strong {
  display: block;
  font-family: var(--font-word);
  font-size: 1.15rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.wheel-entry-stats span {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 9.5px;
  white-space: nowrap;
}

.wheel-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 26px;
  background:
    radial-gradient(120% 150% at 100% 0%, var(--accent-soft), transparent 58%),
    var(--surface);
}

.wheel-summary-copy {
  min-width: 0;
}

.wheel-summary-copy h2 {
  font-size: 1.45rem;
  margin: 6px 0 8px;
}

.wheel-summary-copy > p {
  max-width: 52ch;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
}

.wheel-summary-meta {
  margin-top: 10px !important;
  font-size: 11.5px !important;
  color: var(--faint) !important;
}

.wheel-live-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 8px;
  flex: none;
  width: min(480px, 100%);
}

.wheel-live-stats > div {
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
  min-width: 0;
}

.wheel-live-stats strong {
  display: block;
  font-family: var(--font-word);
  font-size: 1.25rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.wheel-live-stats span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.wheel-live-stats > div:last-child strong {
  font-size: 1.02rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.wheel-list {
  padding: 0;
  margin-top: 16px;
  overflow: hidden;
}

.wheel-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.wheel-list-head strong {
  display: block;
  font-size: 13.5px;
}

.wheel-list-head span {
  font-size: 11.5px;
  color: var(--muted);
}

.wheel-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(220px, 0.9fr);
  align-items: center;
  gap: 16px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease, opacity 0.2s ease;
  scroll-margin-top: 90px;
}

.wheel-row:last-child {
  border-bottom: 0;
}

.wheel-row.is-hidden {
  display: none;
}

.wheel-row.is-submitting {
  opacity: 0.72;
}

.wheel-row.is-correct {
  background: var(--accent-soft);
}

.wheel-row.wheel-return {
  animation: wheel-return 0.5s ease both;
}

.wheel-index {
  font-size: 11px;
  font-weight: 650;
  color: var(--faint);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.wheel-word-wrap {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.wheel-word {
  font-family: var(--font-word);
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.wheel-speak {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.wheel-speak svg {
  width: 13px;
  height: 13px;
}

.wheel-speak:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wheel-speak.playing {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wheel-word-meta {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

.wheel-source {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--faint);
  font-size: 9.5px;
}

.wheel-prof {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.wheel-prof.pos {
  background: var(--accent-soft);
  color: var(--accent);
}

.wheel-prof.neg {
  background: var(--danger-soft);
  color: var(--danger);
}

.wheel-prof.zero {
  background: var(--surface-3);
  color: var(--faint);
}

.wheel-entry {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.wheel-input {
  font-size: 14px;
  padding: 9px 11px;
  background: var(--surface-2);
}

.wheel-check {
  appearance: none;
  flex: none;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 9px 11px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wheel-check:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.wheel-check:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wheel-reveal {
  grid-column: 2 / -1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.wheel-reveal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.wheel-reveal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.wheel-feedback {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.wheel-row.is-revealed {
  align-items: start;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--warn-soft) 70%, transparent),
    transparent 68%
  );
}

.wheel-row.is-revealed .wheel-entry {
  display: none;
}

.wheel-row.is-revealed .wheel-index {
  padding-top: 6px;
}

.wheel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 46px 24px;
  margin-top: 16px;
  background:
    radial-gradient(90% 140% at 50% 0%, var(--accent-soft), transparent 68%),
    var(--surface);
}

.wheel-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 46px 24px;
  margin-top: 16px;
  background:
    radial-gradient(90% 140% at 50% 0%, var(--accent-soft), transparent 68%),
    var(--surface);
}

.wheel-gate-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-word);
  font-size: 1.5rem;
  font-weight: 700;
}

.wheel-gate h2 {
  margin: 4px 0 8px;
  font-size: 1.6rem;
}

.wheel-gate p {
  max-width: 48ch;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
}

.wheel-empty-mark {
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 14px 30px -16px color-mix(in srgb, var(--accent) 85%, transparent);
}

.wheel-empty-mark svg {
  width: 26px;
  height: 26px;
}

.wheel-empty h2 {
  margin: 4px 0 8px;
  font-size: 1.5rem;
}

.wheel-empty p {
  margin: 0;
  max-width: 46ch;
  font-size: 13.5px;
  color: var(--muted);
}

.wheel-empty-countdown {
  margin-top: 14px;
  font-family: var(--font-word);
  font-size: 2rem;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.wheel-curve {
  padding: 0;
  margin-top: 18px;
  overflow: hidden;
}

.wheel-curve > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 20px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.wheel-curve > summary::-webkit-details-marker {
  display: none;
}

.wheel-curve > summary:hover {
  background: var(--surface-2);
}

.wheel-curve-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}

.wheel-curve-body p {
  margin: 14px 0 0;
}

.wheel-curve-ladder {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

@keyframes wheel-return {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ---------------------------------------------------------------- */
/* Small-essay translation                                           */
/* ---------------------------------------------------------------- */

.translation-head {
  padding-bottom: 16px;
}

.translation-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 20px;
}

.translation-stat {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.translation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 20px;
  align-items: start;
}

.translation-practice {
  padding: 26px;
}

.translation-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.translation-topline .round-label {
  margin-bottom: 0;
}

.translation-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.translation-pattern {
  display: inline-block;
  margin-bottom: 14px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.translation-prompt {
  margin: 0 0 22px;
  padding-left: 18px;
  border-left: 3px solid var(--accent);
  font-family: var(--font-word);
  font-size: 1.35rem;
  line-height: 1.85;
  letter-spacing: 0;
  color: var(--ink);
}

.translation-practice textarea {
  min-height: 170px;
  font-size: 15px;
  line-height: 1.8;
}

.translation-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.translation-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.translation-chars,
.translation-shortcut {
  color: var(--faint);
  font-size: 11px;
}

.translation-side {
  min-width: 0;
}

.translation-review {
  padding: 24px;
}

.translation-score-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.translation-score-head .score-ring {
  width: 86px;
  height: 86px;
  flex: none;
}

.translation-score-copy {
  min-width: 0;
}

.translation-score-copy h2 {
  margin: 2px 0 4px;
  font-size: 1.3rem;
}

.translation-score-copy p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.translation-score-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11.5px;
}

.review-block {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface-2);
}

.review-block .label {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-block p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.review-answer {
  color: var(--ink) !important;
}

.review-section {
  margin-top: 18px;
}

.review-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12.5px;
}

.review-list li {
  position: relative;
  padding-left: 16px;
  line-height: 1.55;
}

.review-list.ok li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 800;
}

.review-issue {
  margin-bottom: 7px;
  padding: 9px 11px;
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: var(--warn-soft);
}

.review-issue p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
}

.issue-type {
  display: inline-block;
  margin-bottom: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn);
  font-size: 10px;
  font-weight: 750;
}

.issue-suggestion {
  margin-top: 3px !important;
  color: var(--muted) !important;
  font-size: 12px !important;
}

.review-ok {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
}

.translation-review-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.translation-tips h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.translation-map {
  margin-top: 20px;
  padding: 18px 20px;
}

.translation-map-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.translation-map-head strong {
  display: block;
  font-size: 13.5px;
}

.translation-map-head span {
  color: var(--muted);
  font-size: 11.5px;
}

.translation-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}

.translation-dot {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.translation-dot span {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.translation-dot small {
  font-size: 10px;
  color: var(--faint);
}

.translation-dot:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.translation-dot.scored {
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}

.translation-dot.scored small {
  color: var(--accent);
}

.translation-dot.current {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.translation-dot.current small {
  color: var(--accent-ink);
  opacity: 0.8;
}

.translation-stat-link {
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.translation-stat-link:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.translation-history {
  margin: 0 0 16px;
  padding: 16px 18px;
}

.translation-history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.translation-history-head strong {
  font-size: 13.5px;
}

.translation-history-head span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 11.5px;
}

.translation-history-link {
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.translation-history-link:hover {
  text-decoration: underline;
}

.translation-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.translation-history-item {
  appearance: none;
  display: grid;
  grid-template-columns: auto auto auto auto;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.translation-history-item:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.translation-history-item.active {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

.th-num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.th-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.th-time {
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.th-open {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
}

.translation-history-item.active .th-time,
.translation-history-item.active .th-open {
  color: var(--accent);
  opacity: 0.75;
}

/* Translation archive */

.archive-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
}

.archive-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 380px);
  flex: 1;
}

.archive-filter > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.archive-filter select {
  max-width: 420px;
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 13px;
}

.archive-count {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
}

.archive-toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.archive-item {
  padding: 0;
  overflow: hidden;
}

.archive-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 16px 20px;
  list-style: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.archive-summary::-webkit-details-marker {
  display: none;
}

.archive-summary:hover {
  background: var(--surface-2);
}

.archive-score {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.archive-score.great {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent);
  color: var(--accent-ink);
}

.archive-score.good {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

.archive-score.ok {
  border-color: color-mix(in srgb, var(--warn) 32%, var(--line));
  background: var(--warn-soft);
  color: var(--warn);
}

.archive-score.low {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: var(--warn-soft);
  color: var(--warn);
}

.archive-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.archive-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.archive-title strong {
  font-size: 13.5px;
}

.archive-time {
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.archive-subtitle {
  color: var(--muted);
  font-size: 11px;
}

.archive-prompt,
.archive-answer {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12.5px;
  line-height: 1.6;
}

.archive-prompt {
  color: var(--ink-soft);
  font-family: var(--font-word);
}

.archive-answer {
  color: var(--muted);
  font-style: italic;
}

.archive-caret {
  align-self: center;
  color: var(--faint);
  font-size: 14px;
  transition: transform 0.15s ease;
}

.archive-item[open] .archive-caret {
  transform: rotate(180deg);
}

.archive-detail {
  padding: 2px 20px 20px;
  border-top: 1px solid var(--line);
}

.archive-detail .review-block:first-child {
  margin-top: 14px;
}

/* ---------------------------------------------------------------- */
/* AI Wiki drawer                                                    */
/* ---------------------------------------------------------------- */

body.ai-open {
  overflow: hidden;
}

.ai-fab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 80;
  appearance: none;
  border: 0;
  border-radius: 14px 0 0 14px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
  transition: background 0.16s ease, color 0.16s ease, opacity 0.2s ease;
}

.ai-fab:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.ai-fab-mark {
  color: var(--accent);
  font-size: 14px;
  writing-mode: horizontal-tb;
}

.ai-fab:hover .ai-fab-mark {
  color: var(--accent-ink);
}

.ai-open .ai-fab {
  opacity: 0;
  pointer-events: none;
}

.ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: color-mix(in srgb, var(--ink) 34%, transparent);
  backdrop-filter: blur(2px);
}

.ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  display: flex;
  width: min(440px, 100vw);
  height: 100vh;
  height: 100dvh;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -24px 0 60px -36px rgba(20, 16, 8, 0.55);
  transform: translateX(103%);
  transition: transform 0.24s ease;
}

.ai-drawer.is-open {
  transform: translateX(0);
}

.ai-drawer-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  height: 100%;
}

.ai-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.ai-drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}

.ai-drawer-title strong {
  display: block;
  font-size: 14px;
}

.ai-drawer-title small {
  display: block;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10.5px;
}

.ai-drawer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.ai-drawer-actions button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 6px 8px;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.ai-drawer-actions button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.ai-drawer-actions .ai-close {
  border: 0;
  background: transparent;
  padding: 4px 7px;
  font-size: 18px;
}

.ai-header-link {
  padding: 6px 4px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}

.ai-header-link:hover {
  color: var(--accent);
}

.ai-thread-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
  flex: none;
}

.ai-thread-meta a {
  color: var(--accent);
  text-decoration: none;
}

.ai-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 16px 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  flex: none;
}

.ai-notice a {
  color: var(--warn);
  font-weight: 700;
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 94%;
}

.ai-msg.user {
  align-self: flex-end;
}

.ai-msg.assistant {
  align-self: flex-start;
}

.ai-msg-role {
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ai-msg.user .ai-msg-role {
  text-align: right;
}

.ai-msg-body {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.ai-msg.user .ai-msg-body {
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.ai-msg.assistant .ai-msg-body {
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  background: var(--surface-2);
}

.ai-retrieval {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 2px;
  padding: 5px 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.5;
  max-width: 100%;
}

.ai-retrieval-meta {
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}

.ai-retrieval-sources {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-retrieval-warn {
  color: var(--danger);
}

.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  background: var(--surface-2);
}

.ai-typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  animation: ai-blink 1s infinite;
}

.ai-typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ai-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

.ai-welcome {
  margin: auto;
  padding: 20px 8px;
  text-align: center;
  color: var(--muted);
}

.ai-welcome-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
}

.ai-welcome h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 1.15rem;
}

.ai-welcome p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
}

.ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  text-align: left;
}

.ai-suggestions button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-soft);
  padding: 8px 10px;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.4;
  cursor: pointer;
}

.ai-suggestions button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.ai-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.ai-composer textarea {
  min-height: 74px;
  resize: none;
  font-size: 13.5px;
  line-height: 1.6;
}

.ai-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-composer-hint {
  color: var(--faint);
  font-size: 10px;
}

.ai-composer .btn {
  flex: none;
}

/* Markdown in answers and wiki */

.markdown-body {
  font-size: 13.5px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body > *:last-child {
  margin-bottom: 0;
}

.markdown-body p {
  margin: 0 0 8px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin: 12px 0 6px;
  font-size: 13.5px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.markdown-body ul,
.markdown-body ol {
  margin: 6px 0 8px;
  padding-left: 20px;
}

.markdown-body li {
  margin: 2px 0;
}

.markdown-body strong {
  font-weight: 750;
}

.markdown-body code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-3);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.markdown-body pre {
  margin: 8px 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.markdown-body pre code {
  padding: 0;
  background: none;
  font-size: 11.5px;
  line-height: 1.6;
}

.markdown-body blockquote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted);
}

.markdown-body hr {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.ai-user-text {
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- */
/* AI Wiki page                                                      */
/* ---------------------------------------------------------------- */

.wiki-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.wiki-search {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.wiki-search > span {
  color: var(--faint);
  font-size: 16px;
}

.wiki-search input {
  padding: 10px 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 13.5px;
}

.wiki-search input:focus {
  background: transparent;
  box-shadow: none;
}

.wiki-count {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
}

.wiki-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.wiki-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.wiki-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
}

.wiki-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--faint);
  font-size: 10.5px;
}

.wiki-card h3 {
  display: -webkit-box;
  margin: 4px 0 2px;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.wiki-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.wiki-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  color: var(--faint);
  font-size: 10.5px;
}

.wiki-card-foot .go {
  color: var(--accent);
  font-weight: 700;
}

.wiki-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wiki-thread {
  padding: 8px 24px;
}

.wiki-message {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.wiki-message:last-child {
  border-bottom: 0;
}

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

.wiki-role {
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.wiki-message.assistant .wiki-role {
  color: var(--accent);
}

.wiki-message-head time {
  color: var(--faint);
  font-size: 10.5px;
}

.wiki-message-body {
  font-size: 14px;
  line-height: 1.75;
}

.wiki-message.user .wiki-message-body {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.wiki-user-text {
  white-space: pre-wrap;
  color: var(--ink);
}

/* ---------------------------------------------------------------- */
/* Animations                                                        */
/* ---------------------------------------------------------------- */

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

/* ---------------------------------------------------------------- */
/* Auth / login                                                      */
/* ---------------------------------------------------------------- */

.auth-page {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-shell {
  width: 100%;
  max-width: 440px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 0 0 18px;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 21px;
  line-height: 1;
}

.auth-brand small {
  display: block;
  margin-top: 1px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-card {
  padding: 28px;
}

.auth-head h1 {
  margin: 4px 0 8px;
  font-size: 1.7rem;
}

.auth-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.auth-form[hidden],
.auth-notice[hidden],
.auth-invite-meta[hidden],
.token-result[hidden] {
  display: none;
}

.auth-notice {
  margin-top: 18px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.auth-notice.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-notice.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-invite-meta {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.token-result {
  padding-top: 8px;
  text-align: center;
}

.token-result-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
}

.token-result h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.token-result p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.token-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.token-box code {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
  overflow-wrap: anywhere;
}

.auth-error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.55;
}

.auth-error[hidden] {
  display: none;
}

.auth-foot,
.auth-bottom {
  margin: 16px 0 0;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.55;
  text-align: center;
}

.auth-bottom {
  margin-top: 14px;
  font-size: 10.5px;
}

@media (max-width: 520px) {
  .auth-page {
    padding: 20px 14px;
  }

  .auth-card {
    padding: 22px 18px;
  }

  .auth-head h1 {
    font-size: 1.5rem;
  }
}

/* ---------------------------------------------------------------- */
/* Account                                                           */
/* ---------------------------------------------------------------- */

.account-handle {
  color: var(--faint);
  font-size: 0.55em;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: middle;
}

.account-secret {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.account-secret[hidden] {
  display: none;
}

.account-secret > strong {
  display: block;
  font-size: 13px;
}

.account-secret p {
  margin: 4px 0 10px;
}

.account-secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-secret-row code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.invite-create-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.invite-create-row .field {
  min-width: 130px;
  flex: 1;
}

.invite-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.invite-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.invite-row-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
}

.invite-row-main strong {
  font-size: 12.5px;
}

.invite-status {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.invite-status.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.invite-status.used {
  background: var(--info-soft);
  color: var(--info);
}

.invite-status.expired,
.invite-status.revoked {
  background: var(--danger-soft);
  color: var(--danger);
}

.account-facts {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
}

.account-facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.account-facts dt {
  color: var(--faint);
}

.account-facts dd {
  margin: 0;
  color: var(--ink-soft);
  text-align: right;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- */
/* Responsive                                                        */
/* ---------------------------------------------------------------- */

@media (max-width: 900px) {
  .home-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .score-card {
    align-items: flex-start;
  }
}

@media (max-width: 680px) {
  .header-inner {
    padding: 11px 16px;
  }

  .header-inner .brand small {
    display: none;
  }

  .nav a {
    padding: 6px 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  .nav {
    max-width: calc(100vw - 132px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .page {
    padding: 0 16px 32px;
  }

  .hero {
    padding: 38px 0 26px;
  }

  .hero .lede {
    font-size: 15px;
  }

  .hero-chips span:nth-child(3) {
    display: none;
  }

  .side-stack {
    grid-template-columns: 1fr;
  }

  .create-card,
  .card {
    padding: 19px;
  }

  .form-row.split {
    flex-direction: column;
  }

  .create-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .create-actions .btn {
    width: 100%;
  }

  .source-tabs {
    width: 100%;
  }

  .source-tab {
    flex: 1;
    justify-content: center;
  }

  .md-drop {
    flex-wrap: wrap;
  }

  .md-drop .btn {
    width: 100%;
  }

  .create-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .create-footer .btn {
    width: 100%;
  }

  .section-head {
    margin-top: 36px;
    align-items: flex-start;
  }

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

  .detail-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .practice-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .round-progress {
    width: 100%;
  }

  .word-row {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px 12px;
    padding: 14px 16px;
  }

  .word-index {
    grid-row: 1 / span 2;
    align-self: start;
    padding-top: 9px;
  }

  .answer-cell {
    grid-column: 2;
  }

  .answer-input {
    grid-column: 2;
  }

  .submit-inner {
    gap: 10px;
    padding: 9px 9px 9px 13px;
  }

  .submit-hint {
    display: none;
  }

  .answer-progress {
    margin-right: auto;
  }

  .submit-inner .btn {
    padding: 10px 15px;
    font-size: 13.5px;
  }

  .score-card {
    flex-direction: column;
    gap: 18px;
    padding: 22px;
  }

  .score-ring {
    width: 82px;
    height: 82px;
  }

  .score-ring strong {
    font-size: 1.55rem;
  }

  .score-actions .btn {
    flex: 1;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .round-card summary {
    grid-template-columns: auto 1fr 16px;
  }

  .round-date {
    display: none;
  }

  .history-row {
    grid-template-columns: 52px minmax(0, 1fr) auto 16px;
    gap: 12px;
    padding: 13px 16px;
  }

  .history-entry-body {
    padding: 0 16px 16px;
  }

  .history-progress {
    display: none;
  }

  .history-date {
    padding-right: 8px;
  }

  .history-date strong {
    font-size: 1.25rem;
  }

  .result-row {
    padding: 14px 16px;
  }

  .result-group-head {
    padding: 13px 16px;
  }

  .edit-panel > summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

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

  .done-hero {
    padding: 36px 20px 32px;
  }

  .done-stats {
    gap: 12px 24px;
  }

  .toast-stack {
    bottom: 16px;
  }

  .app-footer {
    margin-top: 36px;
    padding: 18px 16px 32px;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  .mode-tabs {
    display: flex;
    width: 100%;
  }

  .mode-tab {
    flex: 1;
    text-align: center;
  }

  .dictation-settings {
    padding: 14px 16px;
  }

  .dictation-panel {
    padding: 18px 16px;
  }

  .dictation-play {
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 18px;
  }

  .play-orb {
    width: 74px;
    height: 74px;
  }

  .play-orb svg {
    width: 30px;
    height: 30px;
  }

  .dictation-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dictation-map {
    padding: 16px;
  }

  .dictation-map-grid {
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  }

  .map-dot {
    height: 30px;
    font-size: 11px;
  }

  .dictation-result-grid {
    grid-template-columns: 1fr;
  }

  .wheel-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 20px;
  }

  .wheel-entry {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px;
  }

  .wheel-entry-stats {
    width: 100%;
  }

  .wheel-entry .btn {
    width: 100%;
  }

  .wheel-live-stats {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .wheel-list-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
  }

  .wheel-row {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px 12px;
    padding: 13px 16px;
  }

  .wheel-index {
    padding-top: 6px;
  }

  .wheel-entry {
    grid-column: 2;
  }

  .wheel-reveal {
    grid-column: 2 / -1;
  }

  .wheel-reveal-grid {
    grid-template-columns: 1fr;
  }

  .wheel-word {
    font-size: 1.22rem;
  }

  .wheel-speak {
    width: 30px;
    height: 30px;
  }

  .wheel-empty {
    padding: 36px 20px;
  }

  .wheel-gate {
    padding: 36px 20px;
  }

  .translation-layout {
    grid-template-columns: 1fr;
  }

  .translation-side {
    position: static;
  }

  .translation-practice {
    padding: 20px 16px;
  }

  .translation-prompt {
    font-size: 1.18rem;
    padding-left: 14px;
  }

  .translation-actions-right {
    width: 100%;
    justify-content: space-between;
  }

  .translation-shortcut {
    display: none;
  }

  .translation-score-head {
    align-items: flex-start;
    gap: 12px;
  }

  .translation-score-head .score-ring {
    width: 72px;
    height: 72px;
  }

  .translation-review {
    padding: 18px 16px;
  }

  .translation-map {
    padding: 16px;
  }

  .translation-map-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }

  .archive-toolbar {
    padding: 14px 16px;
  }

  .archive-filter {
    min-width: 100%;
  }

  .archive-filter select {
    max-width: none;
  }

  .archive-toolbar-actions {
    margin-left: 0;
  }

  .archive-summary {
    gap: 10px;
    padding: 14px 16px;
  }

  .archive-detail {
    padding: 2px 16px 16px;
  }

  .nav a {
    padding: 6px 9px;
    font-size: 12px;
  }

  .ai-fab {
    right: 16px;
    bottom: 88px;
    top: auto;
    transform: none;
    flex-direction: row;
    gap: 5px;
    padding: 9px 13px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.06em;
    writing-mode: horizontal-tb;
  }

  .ai-fab-mark {
    font-size: 12px;
    writing-mode: horizontal-tb;
  }

  .ai-drawer {
    width: 100vw;
    border-left: 0;
  }

  .ai-drawer-head {
    padding: 12px 14px 10px;
  }

  .ai-drawer-title small {
    max-width: 150px;
  }

  .ai-drawer-actions {
    gap: 4px;
  }

  .ai-drawer-actions button {
    padding: 5px 6px;
  }

  .ai-messages {
    padding: 14px;
  }

  .ai-composer {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }

  .ai-composer-foot {
    justify-content: flex-end;
  }

  .ai-composer-hint {
    display: none;
  }

  .wiki-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .wiki-count {
    text-align: right;
  }

  .wiki-grid {
    grid-template-columns: 1fr;
  }

  .wiki-thread {
    padding: 4px 16px;
  }

  .wiki-message-body {
    font-size: 13.5px;
  }

  .wiki-detail-actions {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .brand > span:last-child {
    display: none;
  }

  .nav {
    max-width: calc(100vw - 78px);
  }

  .nav a {
    padding: 6px 9px;
    font-size: 12px;
  }
}

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

  .confetti {
    display: none;
  }
}
