/* Colour tokens live in ui/tokens.css (loaded after this file), which also aliases the legacy
   names used here (--page, --text-*, --border, --accent-2..5). Don't redefine them here: a dark
   block in this file would out-rank those aliases. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 84px;
}

header.page-header {
  padding: 20px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--page);
  z-index: 5;
}

header.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

header.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 4px 0 0;
}

main {
  padding: 8px 16px 16px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.stat-tile .value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-tile .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

.list-item .title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.list-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
}
.btn:active { opacity: 0.8; }
.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

textarea, select, input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="file"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
}

.muted { color: var(--text-muted); font-size: 13px; }
.loading { text-align: center; padding: 40px 0; color: var(--text-muted); }

nav.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
}

nav.tabbar a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  padding: 6px 0;
}

nav.tabbar a .icon { font-size: 20px; display: block; margin-bottom: 2px; }
nav.tabbar a.active { color: var(--accent); }

.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 4px;
}
.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex: none;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-1);
  white-space: nowrap;
}
.pill.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  gap: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-sheet {
  background: var(--surface-1);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-sheet h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 12px;
}

.modal-body { margin-bottom: 16px; }

.modal-actions {
  display: flex;
  gap: 10px;
  padding-bottom: env(safe-area-inset-bottom);
}

.modal-actions .btn { width: auto; flex: 1; }

/* ---- Home: widget glance grid ---- */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));  /* long nowrap subtitles must not widen the grid */
  gap: 10px;
  margin-bottom: 12px;
}

.widget-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  display: block;
}

.widget-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  margin-bottom: 10px;
}

.widget-title { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.widget-value { font-size: 19px; font-weight: 700; margin-top: 3px; letter-spacing: -0.01em; }
.widget-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Health: KPI tiles (iOS/consulting-report style) ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

.kpi-value-row { display: flex; align-items: baseline; gap: 4px; margin-top: 6px; }
.kpi-value { font-size: 23px; font-weight: 700; letter-spacing: -0.01em; }
.kpi-unit { font-size: 11px; color: var(--text-muted); }
.kpi-delta { font-size: 11px; font-weight: 600; margin-left: auto; }

.kpi-gauge { height: 4px; border-radius: 2px; background: var(--border); margin-top: 10px; overflow: hidden; }
.kpi-gauge-fill { height: 100%; border-radius: 2px; }

.insight-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.insight-item:last-child { border-bottom: none; }
.insight-icon { font-size: 15px; flex: none; width: 20px; text-align: center; }
.insight-text { font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.insight-text strong { color: var(--text-primary); font-weight: 600; }

/* ---- English: flip cards ---- */
.flip-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.flip-card .front-word { font-size: 19px; font-weight: 700; }
.flip-card .back-content { display: none; }
.flip-card.flipped .front-word { display: none; }
.flip-card.flipped .back-content { display: block; }
.flip-card.flipped { background: var(--accent-soft); border-color: var(--accent); }
.flip-card .back-meaning { font-size: 17px; font-weight: 700; color: var(--accent); }
.flip-card .back-example { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.flip-card .flip-hint { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* ---- AI assistant: proactive feed + avatars ---- */
.feed-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.feed-scroll::-webkit-scrollbar { display: none; }
.feed-card {
  flex: none;
  width: 210px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
}
.feed-card .feed-label { font-size: 10px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.feed-card .feed-text { font-size: 13px; margin-top: 4px; line-height: 1.4; }

.chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex: none;
}

/* ---- Health: iOS-style segmented control ---- */
.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 4px 0 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-muted) 15%, transparent);
}

.segmented a,
.segmented button {
  flex: 1;
  text-align: center;
  padding: 7px 2px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.segmented a.active,
.segmented button.active {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

/* ---- Health: charts (tooltips over inline SVG) ---- */
.chart-wrap { position: relative; }

.chart-tip {
  position: absolute;
  z-index: 10;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-2);
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
}

/* ---- Assets: allocation bar (current fill + target marker line) ---- */
.alloc-bar { position: relative; height: 6px; border-radius: 3px; background: var(--border); margin-top: 8px; }
.alloc-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }
.alloc-bar .marker { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text-primary); border-radius: 1px; }

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text-primary); color: var(--page); padding: 8px 16px; border-radius: 999px;
  font-size: 13px; z-index: 100; box-shadow: var(--shadow-2);
}

/* ---- Assistant: home header + avatar ---- */
.home-header { display: flex; align-items: center; gap: 12px; }

.avatar-btn {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; text-decoration: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent-4) 26%, transparent));
  box-shadow: inset 0 0 0 1px var(--border);
}
.avatar-btn.small { width: 34px; height: 34px; font-size: 17px; }

/* ---- Assistant: composer ---- */
.composer-card {
  position: relative;
  border-radius: 16px;
  padding: 12px 12px 8px;
  margin: 6px 0 10px;
  border: 1px solid transparent;
  background-image:
    linear-gradient(var(--surface-1), var(--surface-1)),
    linear-gradient(135deg, var(--accent), var(--accent-4));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 12%, transparent);
}

.composer-card textarea {
  border: none; background: transparent; box-shadow: none;
  padding: 4px 4px 6px; resize: none; min-height: 26px; max-height: 160px;
  font-size: 16px; line-height: 1.5;
}
.composer-card textarea:focus { outline: none; }

.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--page); color: var(--text-primary);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.icon-btn:disabled { opacity: 0.4; }

.send-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%; border: none;
  background: var(--accent); color: var(--on-accent);
  font-size: 17px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.send-btn.stop { background: var(--critical); font-size: 12px; }
.send-btn:active { opacity: 0.85; }

textarea.dictating { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-5) 45%, transparent); border-radius: 10px; }

/* ---- Assistant: quick chips ---- */
.chip-row {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 2px 0 10px; margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: none; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-secondary); font-size: 13px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.chip:active { background: color-mix(in srgb, var(--accent) 12%, var(--surface-1)); color: var(--accent); }

/* ---- Assistant: home feed ---- */
.feed-item {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  padding: 12px 34px 12px 14px;
  margin-bottom: 10px;
  transition: opacity 0.18s ease;   /* no transform transition: the drag must follow the finger */
}
.feed-item.kind-approval { border-left-color: var(--accent-3); }
.feed-item.kind-reminder { border-left-color: var(--accent); }
.feed-item.kind-task_result { border-left-color: var(--accent-4); }
.feed-item.kind-alert { border-left-color: var(--accent-2); }
.feed-item.kind-error { border-left-color: var(--critical); background: color-mix(in srgb, var(--critical) 7%, var(--surface-1)); }
.feed-item.kind-email_draft { border-left-color: var(--accent); }
.feed-item.kind-todo_overdue { border-left-color: var(--warning); }
.feed-item.kind-english { border-left-color: var(--accent-4); }
.feed-item.swiped-out {
  opacity: 0; transform: translateX(-60px);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.feed-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.feed-kind { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-muted); text-transform: uppercase; }
.feed-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.feed-title { font-size: 15px; font-weight: 600; line-height: 1.4; }
.feed-summary { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.feed-body {
  font-size: 13px; color: var(--text-secondary); margin-top: 6px; line-height: 1.5;
  white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-link { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.feed-actions { display: flex; gap: 8px; margin-top: 10px; }
.feed-dismiss {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border: none; background: none;
  color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0;
}
.feed-result { font-size: 13px; padding: 2px 0; color: var(--text-secondary); }
.feed-result.ok { color: var(--accent-3); font-weight: 600; }
.feed-result.bad { color: var(--critical); }
.feed-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 14px 0 18px; margin: 0; }
.feed-head { display: flex; justify-content: flex-end; margin: 0 2px 6px; }
.feed-read-all {
  border: none; background: none; padding: 2px 0; cursor: pointer;
  color: var(--accent); font-size: 12px; font-weight: 600; font-family: inherit;
}
.feed-read-all:disabled { opacity: 0.5; }

.btn.mini { width: auto; padding: 8px 16px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; }

/* ---- Chat ---- */
.chat-header { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; }
.chat-header h1 { font-size: 17px; }
.chat-header p { font-size: 12px; margin-top: 1px; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-head-text h1, .chat-head-text p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill-btn {
  flex: none; border: 1px solid var(--border); background: var(--surface-1);
  color: var(--accent); font-size: 13px; font-weight: 600; font-family: inherit;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}

.chat-log { padding: 4px 2px 8px; min-height: 40vh; }

.msg { display: flex; margin-bottom: 10px; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }

.msg .bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px; line-height: 1.55;
}
.msg.user .bubble {
  background: var(--accent); color: var(--on-accent);
  border-bottom-right-radius: 6px;
}
.msg.assistant .bubble {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md strong { font-weight: 700; }
.msg.user .md strong { color: var(--on-accent); }

.msg-actions { display: none; gap: 6px; margin-top: 8px; justify-content: flex-end; }
.mini-btn {
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  font-size: 11px; font-family: inherit; padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.mini-btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.mini-btn:disabled { opacity: 0.5; }

/* activity rows: 12px, muted, tiny spinner */
.act-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-muted);
  padding: 5px 0; line-height: 1.4;
}
.act-row.ok .act-mark { color: var(--accent-3); }
.act-row.bad .act-mark { color: var(--critical); }
.act-row.bad .act-label { color: var(--critical); }
.act-mark { flex: none; font-size: 11px; font-weight: 700; width: 12px; text-align: center; }
.act-label { min-width: 0; }
.act-spin {
  flex: none; width: 11px; height: 11px; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: act-spin 0.8s linear infinite;
}
@keyframes act-spin { to { transform: rotate(360deg); } }
.act-undo {
  margin-left: auto; flex: none;
  border: 1px solid var(--border); background: transparent; color: var(--accent);
  font-size: 11px; font-family: inherit; padding: 2px 9px; border-radius: 999px; cursor: pointer;
}
.act-undo:disabled { opacity: 0.5; }
.act-undone { margin-left: auto; font-size: 11px; color: var(--accent-3); }

.typing { color: var(--text-muted); animation: typing-pulse 1.2s ease-in-out infinite; }
@keyframes typing-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* inline approval card inside a bubble */
.approval-card {
  margin: 8px 0 2px; padding: 10px 12px;
  border-radius: 12px;
  border-left: 3px solid var(--accent-3);
  background: color-mix(in srgb, var(--accent-3) 8%, var(--page));
}
.approval-head { font-size: 11px; font-weight: 700; color: var(--accent-3); letter-spacing: 0.03em; }
.approval-title { font-size: 14px; font-weight: 600; margin-top: 4px; }
.approval-detail {
  font-size: 12px; color: var(--text-secondary); margin-top: 6px; line-height: 1.5;
  white-space: pre-wrap; max-height: 160px; overflow-y: auto;
  background: var(--surface-1); border-radius: 8px; padding: 8px 10px;
}
.approval-actions { display: flex; gap: 8px; margin-top: 10px; }
.approval-done { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--page); color: var(--text-secondary); }
.approval-done.ok { color: var(--accent-3); font-weight: 600; }
.approval-done.bad { color: var(--critical); }

.chat-error {
  margin: 8px 0 2px; padding: 8px 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--critical) 10%, transparent);
  color: var(--critical); font-size: 12px; line-height: 1.5;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.chat-empty { padding: 24px 8px; text-align: center; }
.chat-empty-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.chat-empty .chip-row { justify-content: flex-start; padding-top: 14px; }

/* composer pinned above the tab bar */
.chat-composer {
  position: sticky;
  bottom: calc(56px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom) / 2);
  background: var(--page);
  border-top: 1px solid var(--border);
  z-index: 4;
}
.chat-composer textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 160px;
  border-radius: 18px; padding: 10px 14px; font-size: 16px; line-height: 1.4;
  background: var(--surface-1);
}
.chat-composer .send-btn, .chat-composer .icon-btn { width: 40px; height: 40px; margin-bottom: 1px; }

/* history sheet */
.sheet-list { display: flex; flex-direction: column; }
.sheet-row {
  position: relative; display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  transition: opacity 0.18s ease;
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row.active { background: color-mix(in srgb, var(--accent) 8%, var(--surface-1)); }
.sheet-row.swiped-out {
  opacity: 0; transform: translateX(-60px);
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.sheet-link { flex: 1; min-width: 0; padding: 12px 40px 12px 0; text-decoration: none; color: inherit; }
.sheet-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.row-del {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; background: none;
  color: var(--text-muted); font-size: 19px; cursor: pointer; padding: 0;
}

/* ---- Assistant settings ---- */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-opt {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--page);
  font-size: 20px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.avatar-opt.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent-4) 22%, transparent));
}

.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); margin-top: 4px; }
.switch-row .title { font-size: 15px; font-weight: 500; }

.switch {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 51px; height: 31px; margin: 0;
  border: none; border-radius: 999px; cursor: pointer; position: relative;
  background: color-mix(in srgb, var(--text-muted) 32%, transparent);
  transition: background 0.2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.switch:checked { background: var(--accent-3); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.4; cursor: default; }

.badge.ghost { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-secondary); }

.mem-group { margin-bottom: 12px; }
.mem-cat { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; margin: 8px 0 2px; }
.mem-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.mem-row:last-child { border-bottom: none; }
.mem-content { font-size: 14px; line-height: 1.5; }
.mem-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.mem-add { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }

.job-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.job-row:last-of-type { border-bottom: none; }
.job-row .title { font-size: 15px; font-weight: 500; line-height: 1.4; }
.job-row .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.job-row.inactive .title { color: var(--text-muted); }
.job-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.job-last { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-edit { margin-top: 8px; }
.job-edit-row { display: flex; gap: 8px; margin-top: 6px; }
.job-edit-row:first-child { margin-top: 0; }
.job-edit-row input[type="time"], .job-edit-row select { flex: 1; width: auto; }
.job-edit-btn { margin-top: 6px; }

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .act-spin { animation: none; border-top-color: var(--accent); }
  .typing { animation: none; opacity: 0.7; }
  .feed-item, .sheet-row, .switch, .switch::after { transition: none; }
  .feed-item.swiped-out, .sheet-row.swiped-out { transform: none; }
}

/* ---- Assets: skeletons, spinner, tabular numbers ---- */
.skeleton-card {
  height: 92px; border: 1px solid var(--border); border-radius: 16px; margin-bottom: 12px;
  background: linear-gradient(100deg, var(--surface-1) 40%,
    color-mix(in srgb, var(--text-muted) 14%, var(--surface-1)) 50%, var(--surface-1) 60%);
  background-size: 200% 100%;
  animation: skeleton-slide 1.3s ease-in-out infinite;
}
@keyframes skeleton-slide { to { background-position: -200% 0; } }

.spinner {
  display: inline-block; width: 14px; height: 14px; flex: none;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spinner-turn 0.8s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spinner-turn { to { transform: rotate(360deg); } }

.num { font-variant-numeric: tabular-nums; }

.alert-strip {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.5;
}

/* collapsible account sections (持仓) */
.acct-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border);
  padding: 12px 0; cursor: pointer; color: inherit; font-family: inherit;
  font-size: 15px; font-weight: 600; text-align: left;
}
.acct-head .chev { color: var(--text-muted); font-size: 12px; transition: transform 0.15s ease; flex: none; }
.acct-head.collapsed { border-bottom-color: transparent; }
.acct-head.collapsed .chev { transform: rotate(-90deg); }

/* account share bar (概览 · 账户分布) */
.share-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 8px; }
.share-bar .fill { height: 100%; border-radius: 3px; background: var(--accent); }

/* screenshot import: tappable upload zone + thumbnail strip (持仓) */
.upload-zone {
  display: block; text-align: center; cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--text-muted) 45%, transparent);
  border-radius: 14px; padding: 24px 14px;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface-1));
}
.upload-zone:active { border-color: var(--accent); }
.upload-zone .uz-icon { font-size: 26px; }
.upload-zone .uz-title { font-size: 15px; font-weight: 600; color: var(--accent); margin-top: 6px; }
.upload-zone .uz-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
/* the real input stays in the DOM (a11y) but is visually hidden — the whole
   zone is its label, which is what makes it tappable on iOS */
.upload-zone input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0;
  border: 0; padding: 0; pointer-events: none;
}
.imp-thumbs { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; }
.imp-thumbs img {
  width: 56px; height: 56px; flex: none; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}

/* screenshot import preview table */
.import-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.import-table th {
  font-weight: 600; color: var(--text-muted); text-align: left;
  padding: 4px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.import-table td { padding: 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.import-table input[type="text"], .import-table input[type="number"], .import-table select {
  padding: 6px; font-size: 12px; border-radius: 8px; width: 100%;
}
.import-table input[type="checkbox"] { width: 17px; height: 17px; }

/* collapsed action history (建议) */
details.hist-card summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted);
  padding: 10px 0; list-style: none;
}
details.hist-card summary::-webkit-details-marker { display: none; }
details.hist-card summary::before { content: "▸ "; }
details.hist-card[open] summary::before { content: "▾ "; }

/* ---- English v2: search bar + suggestions ---- */
.en-search-wrap { position: relative; margin: 0 0 12px; }
.en-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-2); overflow: hidden;
}
.en-suggest-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--border);
  padding: 10px 12px; font-size: 14px; color: var(--text-primary);
  font-family: inherit; cursor: pointer;
}
.en-suggest-item:last-child { border-bottom: none; }

/* ---- English v2: scenario picker ---- */
.en-scenario-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.en-scenario {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px;
  padding: 12px; text-align: left; cursor: pointer; font-family: inherit; color: inherit;
}
.en-scenario:active { border-color: var(--accent); }
.en-scenario:disabled { opacity: 0.6; }
.en-scenario-icon { font-size: 22px; }
.en-scenario-title { font-size: 14px; font-weight: 700; margin-top: 6px; }
.en-scenario-desc { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

/* ---- English v2: chat bubbles extras ---- */
.en-msg-col { max-width: 84%; display: flex; flex-direction: column; }
.en-msg-col .bubble { max-width: 100%; }
.msg.user .en-msg-col { align-items: flex-end; }
.en-bubble-actions { display: flex; gap: 6px; margin-top: 4px; }
.en-trans-text {
  margin-top: 4px; padding: 8px 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-1));
  border: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}
details.en-fix { margin-top: 6px; max-width: 100%; }
details.en-fix summary {
  cursor: pointer; font-size: 11px; font-weight: 600; color: var(--warning);
  list-style: none; padding: 3px 9px; border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  border-radius: 999px; display: inline-block;
}
details.en-fix summary::-webkit-details-marker { display: none; }
details.en-fix[open] summary { margin-bottom: 6px; }
.en-fix-item {
  font-size: 12px; line-height: 1.5; color: var(--text-secondary);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px; margin-top: 5px;
}
.en-fix-item s { color: var(--critical); }

/* mic states: listening pulses, processing dims */
.icon-btn.listening {
  border-color: var(--critical); color: var(--critical);
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--critical) 40%, transparent); }
  50% { box-shadow: 0 0 0 7px transparent; }
}
.icon-btn.processing { opacity: 0.5; }

/* ---- English: hands-free voice conversation panel ---- */
/* pinned above the tab bar, like .chat-composer */
.en-voice {
  position: sticky;
  bottom: calc(56px + env(safe-area-inset-bottom));
  z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 0 10px;
  background: var(--page);
  border-top: 1px solid var(--border);
}
.en-voice-status { font-size: 13px; color: var(--text-secondary); min-height: 18px; text-align: center; }
.en-voice-orb {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  border: none; color: var(--on-accent); background: var(--accent);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.15s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.en-voice-orb:active { transform: scale(0.94); }
.en-voice-orb[data-state="idle"] { background: var(--text-primary); color: var(--page); box-shadow: none; }
.en-voice-orb[data-state="connecting"],
.en-voice-orb[data-state="thinking"] { opacity: 0.75; animation: typing-pulse 1.2s ease-in-out infinite; }
.en-voice-orb[data-state="listening"] { animation: orb-ring 1.4s ease-out infinite; }
.en-voice-orb[data-state="speaking"] { background: var(--good); box-shadow: 0 6px 20px color-mix(in srgb, var(--good) 35%, transparent); }
@keyframes orb-ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 18px transparent; }
}
.en-voice-actions { display: flex; gap: 10px; }
.en-voice-actions .btn { width: auto; padding: 7px 14px; font-size: 13px; }

/* ---- English v2: session report card ---- */
.en-score-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.en-score-tile {
  background: var(--page); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 4px; text-align: center;
}
.en-score-icon { font-size: 16px; }
.en-score-num { font-size: 20px; font-weight: 700; margin-top: 2px; }
.en-score-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- English v2: shadowing ---- */
.en-shadow-focus {
  margin-top: 6px; font-size: 12px; color: var(--accent-4);
  background: color-mix(in srgb, var(--accent-4) 8%, transparent);
  border-radius: 8px; padding: 5px 8px; display: inline-block;
}
.en-w-ok { font-size: 14px; }
.en-w-miss {
  font-size: 14px; color: var(--critical); text-decoration: underline;
  text-decoration-style: wavy; text-underline-offset: 3px;
}
.en-w-miss em { font-style: normal; font-size: 10px; margin-left: 1px; }

/* ---- English v2: reading ---- */
mark.en-kw {
  background: color-mix(in srgb, var(--warning) 30%, transparent);
  color: inherit; border-radius: 4px; padding: 0 2px; cursor: pointer;
}
.en-word-pop {
  position: absolute; z-index: 60; width: min(300px, calc(100vw - 24px));
  margin: 0; padding: 12px; box-shadow: var(--shadow-2);
}
.en-opt {
  display: block; width: 100%; text-align: left;
  background: var(--page); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-top: 6px; font-size: 14px; color: var(--text-primary);
  font-family: inherit; cursor: pointer;
}
.en-opt:disabled { cursor: default; opacity: 0.85; }
.en-opt.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--page)); }
.en-opt.wrong { border-color: var(--critical); background: color-mix(in srgb, var(--critical) 8%, var(--page)); }
.en-explain { margin-top: 8px; font-size: 13px; line-height: 1.5; }

/* ---- English v2: dictionary ---- */
.en-d-tag { margin: 8px 4px 0 0; }
.en-d-forms { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.en-d-form {
  font-size: 12px; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}
.en-d-form em { font-style: normal; color: var(--text-muted); margin-right: 3px; }

/* grade buttons on the review flashcard */
.btn.secondary.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.btn.secondary.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .icon-btn.listening { animation: none; }
}
