﻿:root {
  --ink: #1a1a1a;
  --accent: #ff6f3c;
  --accent-2: #2a9d8f;
  --panel: #fff7ec;
  --panel-soft: #f1e3d3;
  --panel-trace: #fffaf2;
  --border: #ddd0c0;
  --sidebar-bg: #f2e8d9;
  --avatar-width: 380px;
  --sidebar-width: 150px;
  --sidebar-collapsed-width: 44px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Space Grotesk", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: #f6f0e6;
}

/* ── App shell ─────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: flex-basis 0.18s ease, width 0.18s ease;
  overflow: hidden;
  z-index: 10;
}

.sidebar.collapsed {
  flex-basis: var(--sidebar-collapsed-width);
  width: var(--sidebar-collapsed-width);
}

.sidebar-toggle {
  flex: 0 0 auto;
  width: 100%;
  height: 46px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}

.sidebar-toggle:hover {
  background: var(--panel-soft);
}

.sidebar-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background 0.1s;
  user-select: none;
}

.nav-item:hover {
  background: var(--panel-soft);
}

.nav-item.active {
  background: var(--panel-soft);
  border-left-color: var(--accent);
}

.nav-item-settings {
  margin-top: auto;
}

.nav-icon {
  font-size: 15px;
  flex: 0 0 18px;
  text-align: center;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapsed .nav-label {
  display: none;
}

.sidebar-footer {
  flex: 0 0 auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  justify-content: center;
  border-top: 1px solid var(--border);
}

.quota-label {
  width: 100%;
  overflow: hidden;
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  border: 1px solid var(--border);
  background: #fff;
  min-height: 30px;
  padding: 4px 10px;
  cursor: pointer;
}

.collapsed .quota-label,
.collapsed .logout-button {
  display: none;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d00000;
  transition: background 0.3s;
}
.conn-dot.connected    { background: #1f9d55; }
.conn-dot.connecting   { background: #ffb703; }

/* ── Authentication ────────────────────────────── */
.auth-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #fdf8f2;
}

.auth-panel {
  width: min(100%, 420px);
  border: 1px solid var(--border);
  background: #fff;
  padding: 28px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 22px;
}

.auth-brand strong {
  font-size: 25px;
}

.auth-brand span {
  color: #6d6257;
  font-size: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.auth-tabs button {
  min-height: 40px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
}

.auth-tabs button.active {
  border-bottom-color: var(--accent);
  color: #bd4319;
  font-weight: 700;
}

.auth-form,
.auth-form label {
  display: flex;
  flex-direction: column;
}

.auth-form {
  gap: 16px;
}

.auth-form label {
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  padding: 9px 11px;
  font: inherit;
}

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

.auth-code-row button,
.auth-submit {
  border: 1px solid var(--border);
  min-height: 44px;
  padding: 8px 13px;
  cursor: pointer;
}

.auth-code-row button {
  background: var(--panel);
}

.auth-submit {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.auth-form button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-error {
  color: #b42318;
  font-size: 13px;
}

.auth-notice {
  color: #16705f;
  font-size: 13px;
}

.auth-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #6d6257;
}

/* ── Main content ──────────────────────────────── */
.main-area {
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fdf8f2;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Chat toolbar ──────────────────────────────── */
.chat-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}

.scenario-current {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: calc(100% - 80px);
  padding: 5px 8px;
  border: 1px solid #c8dfd8;
  background: #eef8f5;
  border-radius: 6px;
  font-size: 12px;
}

.scenario-current-icon {
  flex: 0 0 auto;
  font-size: 16px;
}

.scenario-current-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-current button {
  flex: 0 0 auto;
  border: 1px solid #9acfc2;
  background: #fff;
  color: #17665b;
  border-radius: 4px;
  padding: 3px 7px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.scenario-current button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.ghost {
  border: 1px solid var(--border);
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border-radius: 4px;
  margin-left: auto;
}

.ghost:hover {
  background: var(--panel-soft);
}

/* ── Scenario cards ────────────────────────────── */
.scenario-panel {
  flex: 1 1 auto;
  align-content: start;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  padding: 28px;
  overflow-y: auto;
  background: #fffaf2;
}

.scenario-picker-header {
  grid-column: 1 / -1;
  padding: 4px 0 10px;
}

.scenario-picker-header h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: 0;
}

.scenario-card {
  min-height: 112px;
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto 1fr;
  gap: 4px 9px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}

.scenario-card:hover {
  border-color: var(--accent-2);
  box-shadow: 0 6px 16px rgba(42, 157, 143, 0.12);
  transform: translateY(-1px);
}

.scenario-state {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #66594c;
  font-size: 13px;
}

.scenario-state-error {
  border-color: #f0b8b8;
  background: #fff5f5;
  color: #9f1c1c;
}

.scenario-icon {
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #eef8f5;
  font-size: 17px;
}

.scenario-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.scenario-summary {
  color: #66594c;
  font-size: 12px;
  line-height: 1.45;
}

.scenario-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.scenario-note-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #fff;
}

.scenario-note-title {
  font-weight: 700;
  line-height: 1.4;
}

.scenario-note-text {
  margin-top: 2px;
  color: #66594c;
  font-size: 13px;
  line-height: 1.5;
}

/* ── History ───────────────────────────────────── */
.history {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.bubble {
  max-width: 86%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow-wrap: anywhere;
}

.bubble.user {
  align-self: flex-end;
  background: #ffe8d6;
  border-color: #f5d0b8;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--panel-soft);
}

.agent-loading {
  min-width: 150px;
}

.agent-loading-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
}

.agent-loading-text {
  color: #66594c;
  font-size: 13px;
}

.agent-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 16px;
}

.agent-loading-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: agent-thinking 1.15s ease-in-out infinite;
}

.agent-loading-dots i:nth-child(2) {
  animation-delay: 0.14s;
}

.agent-loading-dots i:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes agent-thinking {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.38;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.bubble.trace {
  align-self: flex-start;
  background: var(--panel-trace);
  max-width: 100%;
  border-radius: 6px;
}

.bubble.scenario {
  align-self: stretch;
  max-width: 100%;
  background: #eef8f5;
  border-color: #b2ddd5;
  border-radius: 8px;
}

.bubble .role {
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.bubble .text-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.bubble .text-row .text {
  flex: 1;
}

.replay-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.replay-btn:hover {
  opacity: 1;
  background: var(--panel-soft);
}

.assistant-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-actions button,
.reply-suggestions button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.assistant-actions button:hover,
.reply-suggestions button:hover {
  border-color: var(--accent-2);
  background: #eef8f5;
}

.assistant-actions button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.grammar-panel {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #c0ccf0;
  background: #f0f4ff;
  border-radius: 6px;
}

.grammar-title {
  margin-bottom: 5px;
  color: #3b4d83;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grammar-panel-loading {
  min-height: 42px;
  display: flex;
  align-items: center;
}

.grammar-streaming {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #66729a;
  font-size: 12px;
  font-weight: 500;
}

.grammar-content {
  font-size: 13px;
  line-height: 1.6;
}

.grammar-error {
  margin-top: 6px;
  color: #b42318;
  font-size: 12px;
}

.bubble .text,
.trace-summary,
.trace-text,
.trace-pre {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 14px;
}

/* Markdown 渲染内容样式 */
.bubble .md-content {
  white-space: normal;
}
.bubble .md-content p {
  margin: 0 0 0.4em;
}
.bubble .md-content p:last-child {
  margin-bottom: 0;
}
.bubble .md-content ul,
.bubble .md-content ol {
  margin: 0.3em 0;
  padding-left: 1.4em;
}
.bubble .md-content li {
  margin-bottom: 0.15em;
}
.bubble .md-content code {
  background: var(--panel-soft, rgba(0,0,0,0.06));
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}
.bubble .md-content pre {
  background: var(--panel-soft, rgba(0,0,0,0.06));
  padding: 8px;
  border-radius: 4px;
  overflow-x: auto;
}
.bubble .md-content strong {
  font-weight: 600;
}
.bubble .md-content ruby {
  ruby-align: center;
  ruby-position: over;
}
.bubble .md-content rt {
  font-size: 0.62em;
  color: #7b5e45;
  letter-spacing: 0.02em;
  user-select: none;
}
.bubble .md-content hr {
  border: none;
  border-top: 1px solid var(--border, #ddd);
  margin: 0.6em 0;
}

/* ── Learning cards ────────────────────────────── */
.learning-block {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.learning-card {
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid transparent;
}

.lc-furigana    { background: #eef8f5; border-color: #b2ddd5; }
.lc-translation { background: #f0f4ff; border-color: #c0ccf0; }
.lc-correction  { background: #fff8e8; border-color: #f0d88a; }
.lc-vocab       { background: #f5f0ff; border-color: #c8b8ec; }
.lc-review      { background: #fff0f5; border-color: #f0b8cc; }

.learning-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
  margin-bottom: 4px;
}

.learning-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.learning-list {
  margin: 0;
  padding-left: 16px;
  line-height: 1.65;
}

/* ── Trace ─────────────────────────────────────── */
.trace-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  border-radius: 4px;
}

.trace-summary {
  margin-top: 8px;
  font-size: 13px;
}

.trace-content {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trace-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trace-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.72;
}

.trace-pre {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--border);
  background: #f9f3eb;
  overflow-x: auto;
  word-break: break-word;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Composer ──────────────────────────────────── */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.reply-suggestions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 9px 18px 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
  overflow-x: auto;
}

.reply-suggestions button {
  flex: 0 0 auto;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-suggestions-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #66594c;
  font-size: 12px;
  line-height: 28px;
  white-space: nowrap;
}

.mini-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid #c8dfd8;
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: loading-spin 0.75s linear infinite;
}

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

.composer-icon {
  font-size: 16px;
  opacity: 0.4;
  flex: 0 0 auto;
}

.composer input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
  font-size: 14px;
  border-radius: 6px;
  outline: none;
}

.composer input:focus {
  border-color: var(--accent-2);
}

.composer button[type="submit"] {
  flex: 0 0 auto;
  border: none;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
}

.composer button[type="submit"]:hover {
  background: #e85d2a;
}

.composer input:disabled,
.composer button[type="submit"]:disabled {
  cursor: wait;
  opacity: 0.58;
}

/* ── Vocabulary learning ───────────────────────── */
.page-vocabulary {
  background: #fffaf2;
}

.vocab-page-header {
  flex: 0 0 auto;
  padding: 28px 30px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.vocab-page-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.vocab-page-header p {
  margin: 6px 0 0;
  color: #66594c;
  font-size: 13px;
}

.vocab-level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 14px;
  padding: 24px 30px;
  overflow-y: auto;
}

.vocab-level-card {
  min-height: 142px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}

.vocab-level-card:hover {
  border-color: var(--accent-2);
  box-shadow: 0 7px 18px rgba(42, 157, 143, 0.12);
  transform: translateY(-1px);
}

.vocab-level-name {
  font-size: 25px;
  font-weight: 700;
}

.vocab-level-count,
.vocab-level-meta {
  color: #66594c;
  font-size: 12px;
}

.vocab-level-progress-track {
  width: 100%;
  height: 6px;
  margin-top: auto;
  overflow: hidden;
  border-radius: 3px;
  background: #eee3d6;
}

.vocab-level-progress-track span,
.vocab-study-progress span {
  display: block;
  height: 100%;
  background: var(--accent-2);
  transition: width 0.2s ease;
}

.vocab-state {
  margin: 24px 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #66594c;
  font-size: 13px;
}

.vocab-state-error {
  color: #a82820;
}

.vocab-study-toolbar {
  flex: 0 0 auto;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.vocab-back-button,
.vocab-nav-button,
.vocab-audio-button {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

.vocab-study-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.vocab-study-heading strong {
  font-size: 18px;
}

.vocab-study-heading span,
.vocab-progress-summary {
  color: #66594c;
  font-size: 12px;
}

.vocab-progress-summary {
  margin-left: auto;
  display: flex;
  gap: 14px;
}

.vocab-study-progress {
  flex: 0 0 4px;
  height: 4px;
  background: #eee3d6;
}

.vocab-study-loading {
  flex: 1;
  justify-content: center;
}

.vocab-detail {
  flex: 1 1 auto;
  min-height: 0;
  padding: 26px 30px 32px;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior-x: contain;
}

.vocab-word-hero {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.vocab-word-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.vocab-word {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.25;
}

.vocab-reading {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 18px;
  color: #17665b;
}

.vocab-romaji {
  color: #7b6a59;
  font-size: 13px;
}

.vocab-word-badges,
.vocab-meanings {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.vocab-word-badges span,
.vocab-meanings span {
  padding: 4px 8px;
  border: 1px solid #c8dfd8;
  border-radius: 5px;
  background: #eef8f5;
  font-size: 12px;
}

.vocab-word-badges .vocab-pending-badge {
  border-color: #e7c785;
  background: #fff8e8;
  color: #775a18;
}

.vocab-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.vocab-info-section h2,
.vocab-conjugation-section h2,
.vocab-example-section h2 {
  margin: 0 0 9px;
  font-size: 14px;
  letter-spacing: 0;
}

.vocab-info-section p {
  margin: 0;
  color: #443a31;
  font-size: 13px;
  line-height: 1.75;
}

.vocab-conjugation-section,
.vocab-example-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

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

.vocab-conjugations div {
  min-height: 58px;
  padding: 9px 11px;
  border-left: 3px solid var(--accent-2);
  background: #fff;
}

.vocab-conjugations span,
.vocab-conjugations strong {
  display: block;
}

.vocab-conjugations span {
  color: #7b6a59;
  font-size: 11px;
}

.vocab-conjugations strong {
  margin-top: 3px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
}

.vocab-example-section {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.vocab-example-section h2 {
  margin-bottom: 0;
}

.vocab-example {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.vocab-example > div {
  flex: 1;
  min-width: 0;
}

.vocab-example p {
  margin: 0;
}

.vocab-example-ja {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.vocab-example-ja ruby {
  ruby-align: center;
  ruby-position: over;
}

.vocab-example-ja rt {
  color: #7b5e45;
  font-size: 0.62em;
  line-height: 1;
  user-select: none;
}

.vocab-example-zh {
  margin-top: 3px !important;
  color: #66594c;
  font-size: 12px;
}

.vocab-audio-message {
  color: #17665b;
  font-size: 12px;
}

.vocab-audio-button {
  flex: 0 0 38px;
  font-size: 15px;
}

.vocab-unenriched-note {
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid #e7c785;
  border-radius: 6px;
  background: #fff8e8;
  color: #775a18;
  font-size: 12px;
  line-height: 1.6;
}

.vocab-study-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 38px minmax(110px, 1fr) minmax(110px, 1fr) 38px;
  gap: 9px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.vocab-study-actions button:disabled,
.vocab-audio-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.vocab-learning-button,
.vocab-mastered-button {
  min-height: 38px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.vocab-learning-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
}

.vocab-mastered-button {
  border: 1px solid #167565;
  background: var(--accent-2);
  color: #fff;
}

/* ── Placeholder pages ─────────────────────────── */
.page-placeholder {
  align-items: center;
  justify-content: center;
}

.placeholder-body {
  text-align: center;
  opacity: 0.4;
  user-select: none;
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 14px;
}

.placeholder-body h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.placeholder-body p {
  margin: 0;
  font-size: 14px;
}

/* ── Avatar panel ──────────────────────────────── */
.avatar-panel {
  flex: 0 0 var(--avatar-width);
  width: var(--avatar-width);
  height: 100vh;
  height: 100dvh;
  border-left: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.avatar-frame {
  flex: 1 1 auto;
  min-height: 0;
  background-color: #fffdf8;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
}

.avatar-label {
  flex: 0 0 auto;
  text-align: center;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.45;
  border-top: 1px solid var(--border);
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 1100px) {
  :root {
    --avatar-width: 300px;
  }
}

@media (max-width: 860px) {
  .avatar-panel {
    display: none;
  }

  .scenario-panel {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .vocab-level-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 640px) {
  :root {
    --mobile-nav-height: 62px;
  }

  body {
    background: #fffaf2;
  }

  button,
  .nav-item {
    touch-action: manipulation;
  }

  #app {
    display: block;
    width: 100%;
  }

  .sidebar,
  .sidebar.collapsed {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    display: block;
    border-top: 1px solid var(--border);
    border-right: 0;
    background: rgba(242, 232, 217, 0.98);
    overflow: visible;
    z-index: 50;
  }

  .sidebar-toggle,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    width: 100%;
    height: var(--mobile-nav-height);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0;
    overflow: hidden;
  }

  .nav-item {
    min-width: 0;
    min-height: var(--mobile-nav-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 5px 8px 4px;
    border-top: 3px solid transparent;
    border-left: 0;
    font-size: 12px;
    text-align: center;
  }

  .nav-item.active {
    border-top-color: var(--accent);
    border-left-color: transparent;
  }

  .nav-icon {
    flex: 0 0 auto;
    font-size: 20px;
    line-height: 1.15;
  }

  .nav-label,
  .collapsed .nav-label {
    display: block;
    width: 100%;
  }

  .main-area {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }

  .chat-toolbar {
    min-height: 50px;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 7px 10px;
  }

  .scenario-current {
    flex: 1 1 auto;
    max-width: none;
    padding: 5px 6px;
  }

  .scenario-current-text {
    flex: 1 1 auto;
  }

  .scenario-current button,
  .ghost {
    min-height: 34px;
  }

  .ghost {
    margin-left: 0;
    padding: 5px 9px;
  }

  .scenario-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 18px 12px 24px;
  }

  .scenario-picker-header {
    padding: 2px 2px 6px;
  }

  .scenario-picker-header h1 {
    font-size: 19px;
  }

  .scenario-card {
    min-height: 124px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 4px 7px;
    padding: 11px 10px;
  }

  .scenario-summary {
    font-size: 11px;
  }

  .history {
    gap: 8px;
    padding: 10px;
  }

  .bubble {
    max-width: 94%;
    padding: 9px 10px;
    border-radius: 8px;
  }

  .bubble .text,
  .trace-summary,
  .trace-text,
  .trace-pre {
    font-size: 14px;
  }

  .replay-btn {
    min-width: 34px;
    min-height: 34px;
  }

  .assistant-actions button {
    min-height: 36px;
    padding: 6px 10px;
  }

  .reply-suggestions {
    gap: 7px;
    padding: 7px 10px 0;
    scrollbar-width: none;
  }

  .reply-suggestions::-webkit-scrollbar {
    display: none;
  }

  .reply-suggestions button {
    min-height: 38px;
    max-width: min(82vw, 300px);
    padding: 7px 11px;
  }

  .composer {
    gap: 8px;
    padding: 8px 10px;
  }

  .composer-icon {
    display: none;
  }

  .composer input {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px;
  }

  .composer button[type="submit"] {
    min-width: 66px;
    min-height: 44px;
    padding: 10px 14px;
  }

  .vocab-page-header {
    padding: 18px 14px 13px;
  }

  .vocab-page-header h1 {
    font-size: 20px;
  }

  .vocab-page-header p {
    line-height: 1.5;
  }

  .vocab-level-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 12px 24px;
  }

  .vocab-level-card {
    min-height: 130px;
    gap: 7px;
    padding: 14px 12px;
  }

  .vocab-level-name {
    font-size: 23px;
  }

  .vocab-level-meta {
    line-height: 1.45;
  }

  .vocab-state {
    margin: 18px 14px;
  }

  .vocab-study-toolbar {
    min-height: 52px;
    gap: 10px;
    padding: 6px 10px;
  }

  .vocab-back-button,
  .vocab-nav-button,
  .vocab-audio-button {
    width: 44px;
    height: 44px;
  }

  .vocab-study-heading {
    min-width: 0;
  }

  .vocab-progress-summary {
    display: none;
  }

  .vocab-detail {
    padding: 18px 14px 24px;
  }

  .vocab-word-hero {
    padding-bottom: 17px;
  }

  .vocab-word-main {
    gap: 7px 9px;
  }

  .vocab-word {
    max-width: 100%;
    font-size: 32px;
    overflow-wrap: anywhere;
  }

  .vocab-reading {
    font-size: 16px;
  }

  .vocab-info-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px 0;
  }

  .vocab-conjugation-section,
  .vocab-example-section {
    padding: 18px 0;
  }

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

  .vocab-example {
    align-items: flex-start;
    gap: 10px;
    padding: 11px 10px;
  }

  .vocab-audio-button {
    flex-basis: 44px;
  }

  .vocab-study-actions {
    grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 7px;
    padding: 8px 10px;
  }

  .vocab-learning-button,
  .vocab-mastered-button {
    min-height: 44px;
    padding: 6px;
    font-size: 12px;
  }
}

@media (max-width: 370px) {
  .scenario-panel,
  .vocab-level-grid {
    grid-template-columns: 1fr;
  }

  .scenario-card {
    min-height: 104px;
  }

  .vocab-conjugations {
    grid-template-columns: 1fr;
  }
}

