:root {
  --bg: #f6f3ee;
  --bg-2: #eef4f2;
  --surface: #fffdfa;
  --surface-2: #f9f6f1;
  --border: rgba(17, 24, 39, 0.1);
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-2: #f59e0b;
  --accent-3: #2563eb;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.12);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px 600px at 12% 8%, rgba(14, 116, 144, 0.18), transparent 60%),
    radial-gradient(500px 500px at 88% 6%, rgba(245, 158, 11, 0.18), transparent 60%),
    radial-gradient(640px 640px at 85% 80%, rgba(34, 197, 94, 0.14), transparent 60%);
  z-index: 0;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(transparent 0, rgba(17, 24, 39, 0.03) 1px, transparent 1px);
  background-size: 100% 24px;
  opacity: 0.6;
  z-index: 0;
  pointer-events: none;
}

.topbar,
.coachbar,
.container,
.footer {
  position: relative;
  z-index: 1;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  animation: pageIn 0.6s ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 253, 250, 0.78);
  box-shadow: var(--shadow-soft);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar nav a {
  color: var(--text);
  margin-left: 0;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(15, 118, 110, 0.08);
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.topbar nav a:hover {
  background: rgba(15, 118, 110, 0.16);
  border-color: rgba(15, 118, 110, 0.22);
  transform: translateY(-1px);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 20px;
}

.coachbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 253, 250, 0.7);
  backdrop-filter: blur(10px);
}

.coach-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  animation: riseIn 0.5s ease both;
}

.coach-item .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.coach-item .value {
  font-weight: 700;
  font-size: 20px;
}

.coach-item .hint {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.charts {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.chart-card {
  min-height: 240px;
}

.chart-card canvas {
  width: 100%;
  height: 200px;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  animation: riseIn 0.6s ease both;
}

.card.highlight {
  border-color: rgba(15, 118, 110, 0.4);
  box-shadow: 0 14px 40px rgba(15, 118, 110, 0.25);
}

.card.subtle {
  border-style: dashed;
  background: var(--surface-2);
  box-shadow: none;
}

.assistant-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.08));
}

.dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dash-focus {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(245, 158, 11, 0.08));
}

.dash-focus::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  right: -30px;
  top: -40px;
  background: rgba(15, 118, 110, 0.12);
  pointer-events: none;
}

.dash-focus > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--muted);
}

.dash-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 6px;
}

.stat-card.accent {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.2);
}

.stat-note {
  font-size: 12px;
  color: var(--muted);
}

.assistant-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--muted);
}

.assistant-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.assistant-metrics .metric {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.assistant-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.assistant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.assistant-plan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.plan-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 4px;
}

.plan-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.plan-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-display);
}

.plan-hint {
  font-size: 11px;
  color: var(--muted);
}

.coach-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 118, 110, 0.25);
  background: rgba(15, 118, 110, 0.08);
  color: #0f3d37;
  font-size: 14px;
}

.next-action {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.next-action .label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--muted);
}

.next-action .next-text {
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(120deg, #0f766e, #22c55e);
  color: #ffffff;
  border: none;
  box-shadow: 0 10px 26px rgba(15, 118, 110, 0.25);
}

.btn.secondary {
  border-color: rgba(15, 118, 110, 0.5);
  color: var(--accent);
}

.assistant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.label {
  color: var(--muted);
  font-size: 14px;
}

.value {
  font-size: 36px;
  font-weight: 700;
  font-family: var(--font-display);
}

h1,
h2,
h3 {
  margin: 0 0 12px 0;
  font-family: var(--font-display);
}

form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}

input,
textarea,
select,
button {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: rgba(15, 118, 110, 0.4);
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
}

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

button.primary {
  background: linear-gradient(120deg, #0f766e, #22c55e);
  color: #ffffff;
  border: none;
  box-shadow: 0 10px 26px rgba(15, 118, 110, 0.25);
}

button.secondary {
  border-color: rgba(15, 118, 110, 0.5);
  color: var(--accent);
  background: #ffffff;
}

button.ghost {
  border-color: var(--border);
  background: var(--surface-2);
}

.link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
}

.link.danger {
  color: var(--danger);
}

.danger-link {
  background: none;
  border: none;
  color: var(--danger);
  padding: 0;
  font-weight: 600;
}

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

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

.small {
  font-size: 13px;
}

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

.chip {
  background: rgba(15, 118, 110, 0.12);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: #0f3d37;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table tbody tr:hover td {
  background: rgba(15, 118, 110, 0.06);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.task-list {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.task {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: grid;
  gap: 6px;
}

.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-title {
  font-weight: 600;
}

.task-detail {
  font-size: 13px;
}

.task-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.3);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  width: fit-content;
  margin-top: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.3);
  color: var(--accent);
  font-size: 12px;
  background: rgba(15, 118, 110, 0.08);
  width: fit-content;
}

.pill.solid {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

.pill.subtle {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.25);
}

.pill.success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #166534;
}

.pill.warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
}

.pill.neutral {
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.25);
  color: #475569;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #22c55e);
  transition: width 0.3s ease;
}

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

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.timeline-item {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: grid;
  gap: 6px;
}

.timeline-time {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.timeline-title {
  font-weight: 600;
}

.timeline-content {
  font-size: 13px;
}

.timeline-suggestion {
  font-size: 13px;
  color: var(--text);
}

.timeline-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  width: fit-content;
}

.flash-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.flash {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
}

.flash.success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #166534;
}

.flash.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #7f1d1d;
}

.flash.warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
}

.flash.info {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: #1e3a8a;
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 24px 0 40px;
  font-size: 13px;
}

.train .word h1 {
  font-size: 48px;
  margin: 8px 0;
}

.train {
  position: relative;
}

.delete-form {
  position: absolute;
  top: 14px;
  right: 14px;
}

.delete-icon {
  border: none;
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-radius: 999px;
  padding: 6px;
  cursor: pointer;
}

.delete-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

.word-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.train details {
  background: var(--surface-2);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.reveal-hint {
  margin: 6px 0 8px;
}

.answer {
  display: none;
}

.answer.visible {
  display: block;
}

.decision-bar {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(15, 118, 110, 0.3);
  background: rgba(15, 118, 110, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.decision-text {
  font-size: 13px;
  color: var(--text);
}

.decision-choice {
  font-weight: 700;
}

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

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.train .meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.hotkeys {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.16);
  color: #0f3d37;
  font-size: 13px;
}

.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.3);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
  padding: 6px;
  cursor: pointer;
}

.tts-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.tts-btn:hover {
  background: rgba(15, 118, 110, 0.18);
}

.tts-btn.mini {
  padding: 4px;
}

.tts-btn.mini svg {
  width: 16px;
  height: 16px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.example {
  color: #1d4ed8;
}

.candidate {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--surface-2);
}

.candidate .word {
  font-weight: 700;
  margin-right: 8px;
}

.candidate .phonetic {
  color: var(--muted);
  margin-right: 8px;
}

.candidate .meaning {
  color: var(--text);
  margin-top: 6px;
}

.candidate .example {
  color: #1d4ed8;
  font-size: 13px;
  margin-top: 4px;
}

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

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

@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .dash-hero {
    grid-template-columns: 1fr;
  }

  .dash-stats {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 640px) {
  .container {
    padding: 16px;
  }

  .topbar {
    padding: 14px 16px;
  }

  .topbar nav a {
    padding: 6px 10px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .coachbar {
    padding: 10px 16px;
  }

  .card {
    padding: 14px;
  }

  .value {
    font-size: 28px;
  }

  .train .word h1 {
    font-size: 34px;
  }

  .word-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .delete-form {
    top: 10px;
    right: 10px;
  }

  .assistant-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .assistant-actions {
    width: 100%;
  }

  .assistant-plan {
    grid-template-columns: 1fr;
  }

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

  .dash-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .dash-focus h2 {
    font-size: 22px;
  }

  .dash-stats {
    grid-template-columns: 1fr;
  }

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

  .decision-bar {
    align-items: flex-start;
  }

  .chart-card canvas {
    height: 180px;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .topbar nav {
    gap: 6px;
  }

  .topbar nav a {
    font-size: 13px;
  }

  .brand {
    font-size: 18px;
  }

  .coach-item .value {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .container,
  .card,
  .coach-item {
    animation: none;
  }
}
