/* ============================================================
   地道口语 · AI 口语陪练
   视觉：极简主义（白 / 灰 / 黑 + 单一强调色）
   ============================================================ */

:root {
  --bg: #FFFFFF;
  --surface: #F7F7F5;
  --ink: #111111;
  --muted: #6B6B6B;
  --line: #EAEAEA;
  --accent: #1A6EFF;

  --radius: 8px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; background: #FFFFFF; }

body {
  margin: 0;
  overflow: hidden;
  background: #FFFFFF;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled { cursor: default; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::selection { background: var(--ink); color: #FFFFFF; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 骨架 ---------- */

.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #FFFFFF;
}

/* ---------- 通用元件 ---------- */

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  color: var(--muted);
  transition: background-color 180ms ease-out, color 180ms ease-out;
}

.icon-btn:hover { background: var(--surface); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

.avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-me { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

/* ---------- 左侧栏 ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg);
}

.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(20px + env(safe-area-inset-top)) 16px 16px 20px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.brand-text p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin: 0 16px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 180ms ease-out, background-color 180ms ease-out;
}

.search:focus-within { border-color: var(--ink); background: var(--bg); }
.search svg { width: 18px; height: 18px; flex: 0 0 auto; }

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
}

.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.side-actions { padding: 12px 16px 4px; }

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.btn-new:hover { background: var(--surface); border-color: var(--ink); }
.btn-new svg { width: 18px; height: 18px; }

.side-actions-review { padding-top: 8px; }

.btn-review {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.btn-review:hover { background: var(--surface); border-color: var(--ink); }
.btn-review svg { width: 18px; height: 18px; }

.review-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 20px 8px;
  color: var(--muted);
  font-size: 12px;
}

.side-label span { font-variant-numeric: tabular-nums; }

.conv-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 8px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conv-list::-webkit-scrollbar,
.stream::-webkit-scrollbar { width: 8px; }

.conv-list::-webkit-scrollbar-thumb,
.stream::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius);
}

.conv-list::-webkit-scrollbar-track,
.stream::-webkit-scrollbar-track { background: transparent; }

.conv {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px 44px 10px 12px;
  border-radius: var(--radius);
  text-align: left;
  transition: background-color 160ms ease-out;
}

.conv:hover { background: var(--surface); }
.conv.active { background: var(--surface); }

.conv-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.conv-surface {
  position: relative;
  z-index: 1;
  background: var(--bg);
  transition: transform 200ms ease-out;
  touch-action: pan-y;
  will-change: transform;
}

.conv-delete {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  width: 96px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease-out;
}

.conv-item.swiping .conv-delete,
.conv-item.open .conv-delete { visibility: visible; }

.conv-item.open .conv-delete { pointer-events: auto; }

.conv-more {
  position: absolute;
  top: 50%;
  right: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(-50%);
  border-radius: 6px;
  color: var(--muted);
  transition: background-color 160ms ease-out, color 160ms ease-out, opacity 160ms ease-out;
}

.conv-more:hover { background: var(--surface); color: var(--ink); }
.conv-more::before { content: ""; position: absolute; inset: -8px; }
.conv-more svg { width: 18px; height: 18px; }

.conv-item.swiping .conv-more,
.conv-item.open .conv-more {
  opacity: 0;
  pointer-events: none;
}

.conv-main { min-width: 0; }

.conv-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.conv-line2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.conv-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.conv-empty {
  padding: 32px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}

.conv-menu {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.conv-menu[hidden] { display: none; }

.conv-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  transition: background-color 160ms ease-out;
}

.conv-menu button:hover { background: var(--surface); }

.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-text { min-width: 0; }

.me-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.me-sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.streak {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.streak span { margin-left: 2px; }

/* ---------- 聊天区 ---------- */

.chat {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  animation: chat-in 200ms ease-out both;
}

.app.chat-open .chat { display: flex; }

@keyframes chat-in {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

.chat-head {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  height: calc(64px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 4px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.api-notice {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.api-notice[hidden] { display: none; }

.back-btn { display: inline-grid; }

.chat-who { min-width: 0; flex: 1 1 auto; }

.chat-who h2 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-who p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-actions { display: flex; align-items: center; gap: 4px; }

#autoReadBtn[aria-pressed="true"] {
  background: var(--ink);
  color: #FFFFFF;
}

#autoReadBtn[aria-pressed="true"]:hover { background: var(--ink); color: #FFFFFF; }

.menu {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top));
  right: 12px;
  z-index: 30;
  min-width: 200px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.menu[hidden] { display: none; }

.menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  transition: background-color 160ms ease-out;
}

.menu button:hover { background: var(--surface); }

/* ---------- 消息流 ---------- */

.stream {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 16px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  scroll-behavior: smooth;
}

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.day-divider::before,
.day-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

.stream-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  animation: msg-in 200ms ease-out both;
}

.msg-in .avatar { margin-top: 0; }
.msg.follow .avatar { visibility: hidden; }

.msg-body { min-width: 0; max-width: min(560px, calc(100% - 52px)); }

.bubble {
  position: relative;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
}

.bubble p { margin: 0; white-space: pre-wrap; }

.bubble-in {
  background: var(--bg);
  border: 1px solid var(--line);
}

.bubble-in .cn {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.bubble-out {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #FFFFFF;
}

.msg-out {
  justify-content: flex-end;
}

.msg-out .msg-body {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.msg-out .msg-body.has-ask { padding-left: 36px; }

.ask-native {
  position: absolute;
  top: 50%;
  left: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}

.ask-native:hover {
  border-color: var(--ink);
  background: var(--surface);
}

.speak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  transition: color 160ms ease-out, opacity 160ms ease-out;
}

.speak svg { width: 16px; height: 16px; }
.speak:hover { color: var(--ink); }
.speak.speaking { color: var(--ink); }

.note {
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.note-head .speak { margin-top: 0; }

.note-en {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
}

.note-cn {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.hide-cn .cn,
.hide-cn .note-cn { display: none; }

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 56px;
  padding: 14px 16px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 输入区 ---------- */

.composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 180ms ease-out;
}

.composer-box:focus-within { border-color: var(--ink); }

.composer-box textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  padding: 7px 4px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.5;
}

.composer-box textarea::placeholder { color: var(--muted); }

.mic { width: 36px; height: 36px; }
.mic.listening { background: var(--ink); color: #FFFFFF; }

.send-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  border: 1px solid transparent;
  color: #FFFFFF;
  transition: background-color 160ms ease-out, opacity 160ms ease-out;
}

.send-btn:hover { opacity: 0.9; }
.send-btn:disabled {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}
.send-btn svg { width: 20px; height: 20px; }

/* ---------- 弹窗 ---------- */

dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

dialog::backdrop { background: rgba(17, 17, 17, 0.32); }

.dialog-card {
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.dialog-body { color: var(--ink); }
.dialog-body p { margin: 0; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.btn-dialog {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 160ms ease-out, border-color 160ms ease-out;
}

.btn-dialog:hover { background: var(--surface); border-color: var(--ink); }
.btn-dialog.dark { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.btn-dialog.dark:hover { opacity: 0.9; background: var(--ink); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.setting-row:first-child { border-top: 0; padding-top: 0; }

.setting-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.setting-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toggle {
  flex: 0 0 auto;
  height: 32px;
  min-width: 64px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background-color 160ms ease-out, color 160ms ease-out, border-color 160ms ease-out;
}

.toggle[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

.setting-foot {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- 外国人会这么说 ---------- */

.native-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.native-quote {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
}

.native-phrase {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.native-phrase-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.native-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.native-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.native-tools .speak { margin-top: 0; }
.native-fav.saved { color: var(--ink); }

.native-speak { margin-top: 0; }

.native-en {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}

.native-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.native-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.native-meta span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.native-meta p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.native-alts { margin-top: 4px; }

.native-alt-title {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.native-alt-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.native-alt-list li { border-top: 1px solid var(--line); }
.native-alt-list li:first-child { border-top: 0; }

.native-alt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 4px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  transition: background-color 160ms ease-out;
}

.native-alt:hover { background: var(--surface); }

.native-alt svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--muted);
}

.native-alt span { min-width: 0; }

.native-foot {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.native-skeleton {
  height: 14px;
  margin: 10px 0;
  border-radius: 4px;
  background: var(--line);
  animation: native-pulse 1.4s ease-in-out infinite;
}

.native-skeleton.short { width: 60%; }

.native-loading-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@keyframes native-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.native-empty {
  margin-top: 12px;
  padding: 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.native-empty-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.native-empty-text {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 复习 ---------- */

.review-card {
  display: flex;
  flex-direction: column;
  width: 440px;
  max-width: calc(100vw - 32px);
  min-height: 480px;
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.review-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.review-progress {
  min-height: 17px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.review-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  padding-top: 24px;
}

.review-front,
.review-back {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

.review-eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.review-zh {
  margin: 0 0 32px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.review-hint {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.review-en {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.review-speak {
  align-self: flex-start;
  margin: 0 0 16px;
}

.review-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.review-meta span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.review-meta p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.review-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.review-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 24px;
}

.review-btn {
  flex: 1 1 0;
  height: 40px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, opacity 160ms ease-out;
}

.review-btn.primary {
  border: 1px solid transparent;
  background: var(--accent);
  color: #FFFFFF;
}

.review-btn.primary:hover { opacity: 0.9; }

.review-btn.secondary {
  border: 1px solid var(--line);
  background: var(--bg);
}

.review-btn.secondary:hover {
  border-color: var(--ink);
  background: var(--surface);
}

.review-empty {
  display: flex;
  flex: 1 1 auto;
  min-height: 360px;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.review-empty-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.review-empty-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.review-empty .review-actions {
  margin-top: 24px;
  padding-top: 0;
}

.recap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.recap-cell {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.recap-cell strong {
  display: block;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.recap-cell span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.recap-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.recap-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.recap-list li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.5;
}

.recap-list li span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 访问密码门禁 ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  animation: gate-in 180ms ease-out;
}

.gate[hidden] { display: none; }

@keyframes gate-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.gate-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.gate-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.gate-title {
  margin: 24px 0 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.gate-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.gate-form {
  width: 100%;
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  transition: border-color 180ms ease-out;
}

.gate-input::placeholder { color: var(--muted); }
.gate-input:focus { border-color: var(--ink); }

.gate-submit {
  width: 100%;
  height: 48px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  transition: opacity 180ms ease-out;
}

.gate-submit:hover { opacity: 0.9; }
.gate-submit:disabled { opacity: 0.5; }

.gate-error {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.gate-error[hidden] { display: none; }

.gate-offline {
  margin: 16px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gate-offline[hidden] { display: none; }

.gate-foot {
  margin: 32px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 安装引导 ---------- */

.setting-steps {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.setting-steps li { margin-bottom: 8px; }
.setting-steps li:last-child { margin-bottom: 0; }
.setting-steps strong { font-weight: 600; }

/* ---------- 小屏微调 ---------- */

@media (max-width: 400px) {
  .dialog-card { padding: 20px; }
  .review-card { padding: 20px; }
  .review-zh { font-size: 22px; }
  .chat-actions .icon-btn { width: 32px; }
}

@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;
  }
}
