:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }

#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  min-height: 48px;
  padding: 12px 56px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-title { font-size: 18px; margin: 0; font-weight: 700; text-align: center; }
.topbar-right { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); min-width: 40px; z-index: 2; }
.topbar-popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); min-width: 132px; overflow: hidden; z-index: 30;
}
.topbar-popover button {
  display: block; width: 100%; border: none; background: none;
  padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text); cursor: pointer;
}
.topbar-popover button + button { border-top: 1px solid var(--border); }
.topbar-popover button:active { background: #f1f5f9; }
.home-onboard .btn { min-height: 44px; }
.home-onboard.card { padding: 14px; }
.home-onboard h2 { font-size: 16px; margin-bottom: 4px; }
.home-onboard p { margin: 0 0 10px; font-size: 13px; }
.home-onboard .btn { min-height: 40px; }

.home-tonight {
  padding: 18px 16px;
  margin-bottom: 12px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(145deg, #4f46e5 0%, #6366f1 55%, #818cf8 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.28);
}
.home-tonight-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-bottom: 6px;
}
.home-tonight-title {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.25;
  color: #fff;
}
.home-tonight-meta { margin: 0 0 14px; color: rgba(255,255,255,0.82); font-size: 13px; }
.home-tonight-start {
  background: #fff !important;
  color: var(--primary) !important;
  font-size: 16px;
  min-height: 48px;
}
.home-tonight-foot {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}
.home-tonight-foot .home-link { color: rgba(255,255,255,0.92); }

.review-plan-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.review-plan-stat {
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.review-plan-stat strong { display: block; font-size: 22px; color: var(--primary); }
.review-plan-stat span { font-size: 11px; color: var(--muted); }
.review-plan-section { margin-top: 14px; }
.review-plan-section h4 { margin: 0 0 8px; font-size: 14px; }
.review-plan-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.review-plan-row:last-child { border-bottom: none; }
.review-plan-word { font-weight: 600; font-size: 15px; }
.review-plan-meta { font-size: 12px; margin-top: 2px; }
.history-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.history-actions .btn { flex: 1; min-height: 42px; }

.main.home-view {
  padding: 12px 14px calc(76px + var(--safe-bottom));
}
.home-stack .home-card {
  padding: 14px;
  margin-bottom: 10px;
}
.home-stack .home-card:last-child { margin-bottom: 0; }
.home-card h3 { margin: 0 0 10px; font-size: 15px; }
.wechat-card {
  border: 1px solid #b7ebc6;
  background:
    radial-gradient(circle at top right, rgba(34,197,94,.18), transparent 34%),
    linear-gradient(180deg, #f3fff7 0%, #ffffff 100%);
  overflow: hidden;
}
.wechat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wechat-card-title { min-width: 0; }
.wechat-login-head {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
}
.wechat-login-copy h3 { margin-bottom: 4px; }
.wechat-mark {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.22);
}
.wechat-mark-main,
.wechat-mark-sub {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: #fff;
}
.wechat-mark-main {
  width: 24px;
  height: 24px;
  left: 9px;
  top: 12px;
}
.wechat-mark-sub {
  width: 18px;
  height: 18px;
  right: 9px;
  bottom: 11px;
  opacity: 0.92;
}
.wechat-mark-main::before,
.wechat-mark-main::after,
.wechat-mark-sub::before,
.wechat-mark-sub::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #16a34a;
}
.wechat-mark-main::before { left: 7px; top: 8px; }
.wechat-mark-main::after { right: 7px; top: 8px; }
.wechat-mark-sub::before { left: 5px; top: 6px; }
.wechat-mark-sub::after { right: 5px; top: 6px; }
.wechat-login-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.wechat-login-points span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.08);
  color: #166534;
  font-size: 12px;
  font-weight: 600;
}
.wechat-login-points span::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}
.wechat-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.wechat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #dcfce7;
}
.wechat-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #166534;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(34,197,94,.16), rgba(22,163,74,.08));
}
.wechat-badge {
  background: #dcfce7;
  color: #166534;
}
.btn-wechat {
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.22);
}
.btn-wechat:active { transform: scale(0.98); }
.wechat-login-note {
  margin: 10px 2px 0;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.5;
}
.home-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.home-card-head h3 { margin: 0; }
.home-foot { margin: 0; font-size: 13px; line-height: 1.4; }
.home-weekly-stats { margin-bottom: 8px; }
.home-weekly-stats .weekly-stat { padding: 8px 4px; }
.home-weekly-stats .weekly-stat strong { font-size: 20px; }
.home-weekly-stats .weekly-stat span { font-size: 11px; }
.home-list-row, .home-score-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.home-row-main { flex: 1; min-width: 0; }
.home-title {
  font-size: 15px; font-weight: 700; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-sub { font-size: 13px; margin-top: 3px; }
.home-aside {
  flex-shrink: 0; max-width: 38%; padding-left: 8px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  text-align: right; line-height: 1.3;
}
.home-link {
  flex-shrink: 0; border: none; background: none;
  color: var(--primary); font-size: 13px; font-weight: 600;
  padding: 4px 0; cursor: pointer; white-space: nowrap;
}
.home-link:active { opacity: 0.7; }
.home-practice { width: auto !important; min-height: 38px !important; padding: 8px 14px !important; font-size: 14px !important; flex-shrink: 0; }
.home-tappable { cursor: pointer; }
.home-tappable:active { background: #fafbff; }
.home-hint { text-align: center; margin: 32px 8px; font-size: 14px; }
.back-btn {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%); z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer;
}
.back-btn.hidden { display: none !important; }

.main { flex: 1; padding: 16px; padding-bottom: calc(80px + var(--safe-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.main.dictation-mode { background: #0f172a; color: #f8fafc; padding-bottom: 16px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + var(--safe-bottom));
}
.tabbar.hidden { display: none; }
.tab {
  border: none; background: transparent; padding: 12px 8px; border-radius: 12px;
  color: var(--muted); font-weight: 600;
}
.tab.active { background: #eef2ff; color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border: none; border-radius: 14px;
  background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-secondary { background: #eef2ff; color: var(--primary); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-icon { width: 40px; height: 40px; border: none; background: #f1f5f9; border-radius: 12px; font-size: 18px; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card-highlight {
  background: linear-gradient(180deg, #eef2ff 0%, #fff 100%);
  border: 1px solid #c7d2fe;
}
.card h2, .card h3 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); font-size: 14px; }

.hero-btn { font-size: 18px; min-height: 56px; margin-top: 8px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 0; }
.check-label input { width: 18px; height: 18px; flex-shrink: 0; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: #fff;
}
.field textarea { min-height: 160px; resize: vertical; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented button {
  min-height: 44px; border: 1px solid var(--border); background: #fff; border-radius: 12px;
}
.segmented button.active { border-color: var(--primary); background: #eef2ff; color: var(--primary); font-weight: 700; }

.tips {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.6;
}
.tips strong { display: block; margin-bottom: 4px; color: #92400e; }

.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 700; margin-bottom: 4px; }
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.list-actions .btn { width: auto; min-height: 40px; padding: 8px 12px; font-size: 14px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eef2ff; color: var(--primary); font-size: 12px; font-weight: 600;
}

.filter-bar { margin-bottom: 12px; }
.filter-pills {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill {
  flex: 0 0 auto; border: 1px solid var(--border); background: #fff;
  border-radius: 999px; padding: 8px 14px; font-size: 14px; color: #64748b;
}
.filter-pill.active {
  border-color: var(--primary); background: #eef2ff; color: var(--primary); font-weight: 700;
}
.filter-manage {
  margin-top: 8px; width: auto; min-height: 36px; padding: 6px 12px; font-size: 14px;
}
.wordlist-toolbar-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.wordlist-toolbar-primary .btn { width: 100%; min-height: 44px; padding: 10px 12px; font-size: 14px; }
.wordlist-toolbar-fold {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.wordlist-toolbar-fold .btn { width: 100%; min-height: 36px; padding: 6px 10px; font-size: 13px; }

.cat-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.cat-section-head {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.cat-section.collapsed .cat-section-head { border-bottom: none; }
.cat-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 12px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  color: #334155;
  min-height: 48px;
}
.cat-chevron {
  width: 16px;
  flex-shrink: 0;
  color: #64748b;
  font-size: 11px;
}
.cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  padding: 2px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.cat-del-btn {
  flex-shrink: 0;
  width: 40px;
  min-width: 40px;
  height: 40px;
  margin-right: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 24px;
  line-height: 1;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cat-del-btn:active { background: #fee2e2; color: var(--danger); }
.cat-section-body .list-item { padding-left: 14px; padding-right: 14px; }
.btn-danger-text { color: var(--danger) !important; }
.list-actions .btn-danger-text { min-height: 36px; padding: 6px 8px; font-size: 13px; }

.inline-field { display: flex; gap: 8px; align-items: center; }
.inline-field input { flex: 1; }
.inline-field .btn { width: auto; min-height: 44px; padding: 0 16px; flex-shrink: 0; }
.cat-del { width: auto; min-height: 40px; padding: 8px 12px; font-size: 14px; }

.badge-muted { background: #f1f5f9; color: #64748b; }

.weekly-card h3 { margin: 0 0 12px; font-size: 16px; }
.weekly-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.weekly-stat { text-align: center; padding: 10px 6px; background: #f8fafc; border-radius: 12px; }
.weekly-stat strong { display: block; font-size: 22px; color: var(--primary); line-height: 1.2; }
.weekly-stat span { font-size: 11px; color: var(--muted); }

.history-actions { margin-bottom: 12px; }
.history-actions .btn { width: auto; min-height: 40px; }

.score-detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.score-detail-head h3 { margin: 0; }
.score-toggle {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; border: none;
  font-weight: 800; font-size: 18px; cursor: pointer;
}
.score-toggle.ok { background: #dcfce7; color: var(--success); }
.score-toggle.bad { background: #fee2e2; color: var(--danger); }

.mistake-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.mistake-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.mistake-item:last-child { border-bottom: none; }
.mistake-item input { width: 18px; height: 18px; margin-top: 4px; flex-shrink: 0; }
.mistake-main { flex: 1; min-width: 0; }
.mistake-word { font-weight: 700; margin-bottom: 4px; }
.mistake-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.mistake-actions .btn { width: auto; min-height: 36px; flex: 1; }

.section-title { margin: 0 0 4px; font-size: 16px; }

.trend-card { margin-bottom: 12px; }
.trend-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.trend-head h3 { margin: 0; font-size: 16px; }
.trend-stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.trend-stats strong { color: var(--text); font-size: 14px; }
.trend-filters { margin-bottom: 8px; }
.trend-chart-wrap { width: 100%; margin: 0 -4px; }
.trend-chart { width: 100%; height: auto; display: block; }
.trend-grid { stroke: #f1f5f9; stroke-width: 1; }
.trend-axis { fill: #94a3b8; font-size: 10px; text-anchor: end; }
.trend-xlabel { fill: #94a3b8; font-size: 9px; }
.trend-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.trend-area { fill: #eef2ff; }
.trend-dot { cursor: pointer; stroke: #fff; stroke-width: 2; }
.trend-foot { margin: 8px 0 0; font-size: 12px; text-align: center; }

.preview-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview-table th, .preview-table td { border-bottom: 1px solid var(--border); padding: 8px 4px; text-align: left; vertical-align: top; }
.preview-table input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.photo-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.source-badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: #eef2ff; color: var(--primary); }
.source-badge.source-ok { background: #ecfdf5; color: #059669; }
.shift-hint { margin: 0 0 10px; color: #d97706; }
.preview-table tr.row-shift td { background: #fffbeb; }
.row-del { color: var(--danger); font-size: 20px; line-height: 1; padding: 4px 8px; }
.row-warn { background: #fff7ed; }

.dictation-screen { text-align: center; padding-top: 24px; }
.dictation-progress { font-size: 48px; font-weight: 800; margin: 24px 0 8px; }
.dictation-sub { color: #94a3b8; margin-bottom: 32px; }
.dictation-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dictation-controls .btn { background: #334155; }
.dictation-controls .btn-primary-lite { background: var(--primary); grid-column: span 2; }

.score-ring {
  width: 160px; height: 160px; border-radius: 50%; margin: 8px auto 16px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: linear-gradient(135deg, #eef2ff, #fdf4ff); border: 6px solid #c7d2fe;
}
.score-ring .num { font-size: 42px; font-weight: 800; color: var(--primary); line-height: 1; }
.score-ring .label { font-size: 14px; color: var(--muted); }

.detail-row { display: flex; gap: 8px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.detail-row.ok .mark { color: var(--success); }
.detail-row.bad .mark { color: var(--danger); }
.mark { font-weight: 800; width: 20px; }

.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-grid img { width: 100%; border-radius: 12px; aspect-ratio: 3/4; object-fit: cover; background: #e2e8f0; }
.photo-deleted {
  aspect-ratio: 3/4; border-radius: 12px; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}

.ocr-banner, .wake-banner {
  padding: 10px 16px; font-size: 13px; text-align: center;
}
.ocr-banner { background: #fff7ed; color: #9a3412; }
.ocr-banner.warn { background: #fef3c7; }
.ocr-banner.danger { background: #fee2e2; color: #991b1b; }
.wake-banner { background: #1e293b; color: #f8fafc; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; max-width: 90vw; text-align: center;
}
.loading {
  position: fixed; inset: 0; background: rgba(255,255,255,0.72); z-index: 99;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.spinner {
  width: 40px; height: 40px; border: 4px solid #e2e8f0; border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

input[type="file"] { display: none; }
.file-btn { margin-bottom: 12px; }
.release-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.release-sheet {
  width: min(420px, 100%); background: var(--card);
  border-radius: 16px 16px 12px 12px; padding: 20px 18px 18px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .18);
}
.release-sheet h3 { margin: 0 0 12px; font-size: 18px; }
.release-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; max-height: 50vh; overflow: auto; }
.release-item strong { display: block; margin-bottom: 4px; }
.release-item p { margin: 0; font-size: 13px; line-height: 1.5; }
.home-card-link { cursor: pointer; }
.home-card-link:active { opacity: .85; }
.feedback-input {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 15px; line-height: 1.5; resize: vertical; min-height: 120px;
}

.crop-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: #0f172a; color: #f8fafc;
  display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.crop-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.crop-toolbar strong { display: block; font-size: 16px; }
.crop-hint { margin: 4px 0 0; font-size: 12px; color: #94a3b8; }
.crop-close { color: #f8fafc; font-size: 24px; line-height: 1; }
.crop-presets { display: flex; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.crop-preset {
  padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06); color: #e2e8f0; cursor: pointer; font-size: 13px;
}
.crop-preset:active { background: rgba(79, 70, 229, 0.35); border-color: #818cf8; }
.crop-stage {
  flex: 1; min-height: 0; position: relative; margin: 0 12px;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none;
}
.crop-stage img { max-width: 100%; max-height: 100%; display: block; pointer-events: none; }
.crop-box {
  position: absolute; border: 2px solid #fff; border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move; touch-action: none;
}
.crop-handle.se {
  position: absolute; right: -10px; bottom: -10px; width: 22px; height: 22px;
  background: #fff; border: 2px solid var(--primary); border-radius: 50%;
  cursor: nwse-resize; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.crop-actions {
  display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.95);
}
.crop-actions .btn { flex: 1; }
.crop-actions .btn-secondary { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; border-color: rgba(255, 255, 255, 0.15); }

.align-preview { font-size: 13px; }
.align-preview .pair { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }

@media (min-width: 480px) {
  .dictation-controls { grid-template-columns: repeat(4, 1fr); }
  .dictation-controls .btn-primary-lite { grid-column: span 4; }
}

/* Engagement: streak, reminder, badges */
.streak-card {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fed7aa;
}
.streak-line { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.streak-fire { font-size: 18px; }

.reminder-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #bfdbfe;
}
.reminder-text { margin: 0 0 12px; font-size: 15px; line-height: 1.5; }
.reminder-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reminder-actions .btn { flex: 1; min-width: 120px; }

.mistake-tip { margin: 10px 0 0; font-size: 14px; color: var(--text); }
.mistake-tip strong { color: var(--primary); font-size: 16px; }

.medal-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.medal-row-inline { justify-content: center; max-width: 280px; margin: 12px auto 0; }
.medal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.medal-svg { width: 44px; height: 52px; }
.medal-label { font-size: 13px; font-weight: 600; }
.medal-th { font-size: 11px; color: var(--muted); }
.medal.locked { opacity: 0.35; filter: grayscale(0.8); }
.medal.locked .medal-svg { color: #94a3b8; }

.medal-iron.unlocked .medal-svg { color: #64748b; }
.medal-copper.unlocked .medal-svg { color: #b45309; }
.medal-silver.unlocked .medal-svg { color: #64748b; filter: drop-shadow(0 1px 2px rgba(100,116,139,.4)); }
.medal-gold.unlocked .medal-svg { color: #ca8a04; filter: drop-shadow(0 2px 4px rgba(202,138,4,.35)); }

.medal-iron.unlocked .medal-svg circle { fill: #64748b; }
.medal-copper.unlocked .medal-svg circle { fill: #b45309; }
.medal-silver.unlocked .medal-svg circle { fill: #94a3b8; }
.medal-gold.unlocked .medal-svg circle { fill: #eab308; }

.badge-unlock-card {
  text-align: center;
  background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
  border-color: #fde047;
  margin-bottom: 12px;
}
.badge-unlock-card p { margin: 0 0 4px; font-weight: 600; font-size: 15px; }

.score-improve {
  margin: 12px 0 4px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  color: #047857;
  font-size: 17px;
  font-weight: 700;
}

.preset-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f1f5f9;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.preset-search-wrap { margin-bottom: 12px; }
.preset-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: #f8fafc;
}
.preset-search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}
.preset-search-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.preset-listtype-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}
.preset-listtype-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.preset-listtype-chip.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: var(--primary);
}
.preset-subject-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.preset-subject-card:active { background: #f8fafc; }
.preset-subject-card strong { display: block; font-size: 17px; margin-bottom: 4px; }
.preset-subject-card span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.review-card {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff 0%, #fff 100%);
}
.review-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 999px;
}
.preset-edition-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
}
.preset-edition-card:active { background: #f8fafc; }
.preset-edition-card strong { display: block; font-size: 16px; margin-bottom: 4px; }
.preset-edition-card span { font-size: 13px; color: var(--muted); }
.preset-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.preset-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.preset-chip.active {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
}
.preset-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.preset-multi-hint { margin: 0 0 8px; font-size: 13px; }
.preset-multi-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
}
.preset-multi-count strong { color: var(--primary); }
.preset-multi-actions { display: flex; gap: 12px; }
.preset-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.preset-list-item.active .preset-check {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.preset-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px;
  cursor: pointer;
}
.preset-list-item:active { background: #f8fafc; }
.preset-list-item.active {
  border-color: var(--primary);
  background: #eef2ff;
}
.preset-list-main { flex: 1; min-width: 0; }
.preset-list-title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.preset-list-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.preset-confirm {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.preset-breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.preset-breadcrumb button {
  border: none;
  background: none;
  padding: 0;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}
