* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ── PAPER THEME ──────────────────────────────────────────────────────────────
   Ink-on-paper aesthetic. Warm parchment backgrounds, deep ink text,
   sienna/brown accents — like a handwritten journal on aged paper.
   Dark screens (recording, processing, PIN) use warm ink-black with
   amber candlelight accents for contrast.
   Font: Iowan Old Style (Kindle's iOS font) → Georgia → serif fallback.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #F7F0DF; --surface: #EDE3C6; --surface2: #E2D5B0;
  --accent: #7C5C3E; --accent2: #9B7355;
  --text: #1E140A; --text2: #7A6040;
  --danger: #B5351F; --border: #CDBF9E; --card: #F2E8D0;
  /* Dark-screen palette (recording, processing, PIN) */
  --dark-bg1: #1A1208; --dark-bg2: #231610;
  --dark-text: #F7F0DF; --dark-text2: rgba(247,240,223,0.6);
  --amber: #D4A05A; --amber2: #E8BF7A;
}

body {
  font-family: 'Lora', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  background: var(--bg); color: var(--text);
  height: 100dvh; overflow: hidden; position: fixed; width: 100%;
}
/* Dark screens (recording, processing, PIN) — paint the status-bar area dark so
   iOS doesn't show the parchment body colour bleeding through above the screen div. */
html.dark-chrome, html.dark-chrome body { background: var(--dark-bg1); }

/* SCREENS */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; height: 100dvh; overflow: hidden; }
.screen.active { display: flex; }
.screen.swipe-prev { display: flex; overflow: hidden; }
.screen.screen-enter { animation: screen-slide-up 0.28s cubic-bezier(0.32,0.72,0,1) both; }
.screen.screen-exit { display: flex; animation: screen-slide-down 0.24s cubic-bezier(0.32,0.72,0,1) both; pointer-events: none; }
@keyframes screen-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes screen-slide-down { from { transform: translateY(0); } to { transform: translateY(100%); } }

/* LOADING / SPLASH — parchment, centred wordmark */
#screen-loading { background: var(--bg); align-items: center; justify-content: center; gap: 32px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 2.5px solid transparent; border-top-color: var(--accent2); border-right-color: var(--accent); animation: spin 0.9s cubic-bezier(0.4,0,0.2,1) infinite; }
.splash-spinner { margin-top: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Shared splash logo — used on both loading and welcome screens */
.splash-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.splash-wordmark {
  font-family: 'Caveat', cursive;
  font-size: 64px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
}
.splash-sub {
  font-family: 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text2);
}

/* WELCOME */
#screen-welcome { background: var(--bg); align-items: center; justify-content: center; gap: 28px; padding: 40px; text-align: center; }
.welcome-sub { font-size: 16px; color: var(--text2); line-height: 1.7; max-width: 280px; }
.welcome-btns { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 280px; }

/* AUTH */
#screen-auth { background: var(--bg); padding: 60px 32px 40px; justify-content: flex-start; gap: 14px; overflow-y: auto; }
.auth-toggle { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; }
.auth-tab { flex: 1; padding: 10px; text-align: center; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text2); transition: all 0.2s; font-family: inherit; }
.auth-tab.active { background: var(--accent); color: var(--dark-text); }
.auth-input { background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 16px 18px; font-size: 16px; color: var(--text); width: 100%; outline: none; font-family: inherit; }
.auth-input:focus { border-color: var(--accent); }
.auth-error { font-size: 13px; color: var(--danger); text-align: center; min-height: 18px; transition: opacity 0.2s; }
.auth-error-show { animation: err-slide 0.25s ease; }
@keyframes err-slide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.btn-spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(247,240,223,0.35); border-top-color: var(--dark-text); animation: spin 0.8s linear infinite; vertical-align: middle; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text2); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-social { background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 14px 24px; font-size: 15px; font-weight: 500; color: var(--text); width: 100%; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: inherit; }
.btn-social-apple { margin-top: -2px; }
.remember-row { display: flex; align-items: center; }
.remember-label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text2); cursor: pointer; user-select: none; }
.remember-label input[type="checkbox"] { display: none; }
.remember-check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border); background: var(--surface); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.remember-label input[type="checkbox"]:checked + .remember-check { background: var(--accent); border-color: var(--accent); }
.remember-label input[type="checkbox"]:checked + .remember-check::after { content: '✓'; color: var(--dark-text); font-size: 13px; font-weight: 700; }

/* PIN SCREENS — dark warm ink, focus */
#screen-pin-setup, #screen-lock, #screen-pin-remove { background: linear-gradient(160deg, var(--dark-bg1), var(--dark-bg2)); align-items: center; justify-content: center; gap: 24px; padding: max(40px, env(safe-area-inset-top)) 40px 40px; text-align: center; color: var(--dark-text); overflow: hidden; }
.pin-dots { display: flex; gap: 16px; justify-content: center; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(247,240,223,0.35); transition: background 0.15s; }
.pin-dot.filled { background: var(--amber); border-color: var(--amber); }
.pin-dot.pin-bounce { animation: pin-pop 0.18s ease; }
@keyframes pin-pop { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 280px; }
.pin-btn { background: rgba(247,240,223,0.07); border: 1.5px solid rgba(247,240,223,0.15); border-radius: 50%; width: 72px; height: 72px; font-size: 22px; font-weight: 500; color: var(--dark-text); cursor: pointer; margin: auto; display: flex; align-items: center; justify-content: center; transition: background 0.15s; font-family: inherit; }
.pin-btn:active { background: rgba(247,240,223,0.15); }
.pin-btn.empty { background: transparent; border-color: transparent; pointer-events: none; }
#screen-pin-setup .btn-ghost, #screen-lock .btn-ghost, #screen-pin-remove .btn-ghost { color: var(--dark-text2); }

/* HOME */
#screen-home { background: var(--bg); }
.home-header { padding: max(56px, calc(env(safe-area-inset-top) + 20px)) 24px 16px; display: flex; align-items: center; justify-content: space-between; }
.home-title { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.settings-btn { width: 40px; height: 40px; background: var(--surface); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; border: 1.5px solid var(--border); }
.entries-list { flex: 1; overflow-y: scroll; padding: 8px 20px 420px; min-height: 0; -webkit-overflow-scrolling: touch; }
.pull-indicator { display: flex; align-items: center; justify-content: center; gap: 8px; overflow: hidden; height: 0; opacity: 0; }
.pull-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(124,92,62,0.22); border-top-color: var(--accent2); flex-shrink: 0; }
.pull-indicator span { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: 0.5px; }
.entry-wrapper { position: relative; margin-bottom: 12px; border-radius: 18px; overflow: hidden; }
.entry-delete-reveal { position: absolute; right: 0; top: 0; bottom: 0; width: 80px; background: transparent; display: flex; align-items: center; justify-content: center; border-radius: 0 18px 18px 0; z-index: 0; opacity: 0; }
/* Hide delete reveals while a drag is in progress */
#entries-list.is-sorting .entry-delete-reveal { opacity: 0 !important; pointer-events: none; }
.entry-delete-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--danger); border: none; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex-shrink: 0; transition: transform 0.15s ease; font-family: inherit; }
.entry-card { background: var(--card); border: 1.5px solid var(--border); border-radius: 18px; padding: 18px; cursor: pointer; position: relative; z-index: 1; will-change: transform; box-shadow: 0 2px 8px rgba(30,20,10,0.07); transition: border-color 0.12s ease; }
.entry-card:active:not(.swiped) { border-color: var(--accent); transform: scale(0.97); transition: transform 0.12s ease, border-color 0.12s ease; }
.entry-ghost { opacity: 0.35; background: var(--surface2); }
.entry-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.entry-date { font-size: 12px; color: var(--text2); font-weight: 500; }
.entry-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; line-height: 1.35; }
.entry-meta-text { font-size: 12px; color: var(--text2); }
.drag-handle { font-size: 20px; color: var(--text2); cursor: grab; padding: 4px 2px; line-height: 1; touch-action: none; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px; text-align: center; }
.empty-icon { font-size: 48px; color: var(--text2); }
.empty-icon svg { width: 48px; height: 48px; }
/* SVG icons sized for their contexts */
.screen-hero-icon { display: flex; justify-content: center; }
.screen-hero-icon svg { width: 48px; height: 48px; color: var(--accent); }
.analytics-habit-icon svg { width: 28px; height: 28px; }
.entry-delete-btn svg { width: 20px; height: 20px; }
.entry-delete-btn--confirm { transform: scale(1.15); }
/* Inline mood SVG marks — sized to sit inline with text */
.mood-svg { display: inline-flex; align-items: center; width: 18px; height: 18px; flex-shrink: 0; }
.mood-svg svg { width: 18px; height: 18px; }
.empty-title { font-size: 20px; font-weight: 600; }
.empty-sub { font-size: 14px; color: var(--text2); line-height: 1.7; }
/* FAB gradient — full-width, fades in from transparent at bottom, peaks
   with opacity across the button zone, fades back to transparent at top.
   Full-width means zero side edges; only the transparent top/bottom vanish. */
#screen-home::before {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 220px;
  background: linear-gradient(to top,
    transparent 28%,
    rgba(247,240,223,0.75) 52%,
    rgba(247,240,223,0.92) 68%,
    transparent 100%);
  pointer-events: none;
  z-index: 55;
}
/* Nav gradient — solid base that covers the bottom nav bar, fades upward. */
#screen-home::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 150px;
  background: linear-gradient(to top, #F7F0DF 44%, transparent 100%);
  pointer-events: none;
  z-index: 55;
}

/* Record FAB — circle button floating above the nav bar */
.record-fab {
  position: fixed;
  bottom: calc(68px + max(16px, env(safe-area-inset-bottom)));
  left: 50%;
  transform: translateX(-50%);
  background: none;
  z-index: 60;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.record-fab:active { transform: translateX(-50%) scale(0.93); opacity: 0.75; }
/* SVG background disc — solid fill so cards don't show through the ring */
.record-bg { fill: var(--bg); }
/* SVG ring — thick ink stroke */
.record-ring { fill: none; stroke: var(--text); stroke-width: 7; }
/* SVG dot — warm accent fill */
.record-dot { fill: var(--accent); }
.entry-flash { animation: entry-highlight 1.5s ease; }
@keyframes entry-highlight { 0%,100% { border-color: var(--border); } 15%,85% { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,62,0.18); } }

/* RECORDING — dark warm ink, like writing by candlelight */
#screen-recording { background: linear-gradient(160deg, var(--dark-bg1) 0%, var(--dark-bg2) 100%); align-items: center; justify-content: center; gap: 32px; padding: 40px; text-align: center; color: var(--dark-text); }
.rec-close { position: absolute; top: max(56px, calc(env(safe-area-inset-top) + 20px)); left: 24px; font-size: 24px; cursor: pointer; color: var(--dark-text2); }
.rec-label { font-size: 14px; color: var(--amber); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.rec-timer { font-size: 56px; font-weight: 200; letter-spacing: 2px; font-variant-numeric: tabular-nums; color: var(--dark-text); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); margin: 0 auto; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.3; } }
.waveform-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.waveform { display: flex; align-items: center; gap: 4px; height: 60px; }
.pause-overlay { position: absolute; inset: -16px; background: rgba(0,0,0,0.45); border-radius: 16px; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.pause-overlay-visible { opacity: 1; }
.wave-bar { width: 4px; border-radius: 4px; background: var(--amber); animation: wave 0.8s ease-in-out infinite; min-height: 4px; }
@keyframes wave { 0%,100% { height:8px; } 50% { height:40px; } }
.rec-hint { font-size: 14px; color: var(--dark-text2); line-height: 1.7; max-width: 260px; }
.rec-controls { display: flex; align-items: center; gap: 24px; }
.pause-btn { width: 56px; height: 56px; border-radius: 50%; background: rgba(247,240,223,0.08); border: 2px solid rgba(247,240,223,0.18); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--dark-text); }
.stop-btn { width: 80px; height: 80px; border-radius: 50%; background: var(--danger); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 32px rgba(181,53,31,0.4); }
.stop-icon { width: 28px; height: 28px; background: var(--dark-text); border-radius: 6px; }
#screen-recording .btn-ghost { color: var(--dark-text2); }

/* REVIEW & MERGE */
#screen-review { background: var(--bg); align-items: center; justify-content: center; gap: 20px; padding: 40px; text-align: center; }
#screen-merge { background: var(--bg); align-items: center; justify-content: center; gap: 20px; padding: 40px; text-align: center; }
.merge-options { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; margin-top: 8px; }
.merge-entry-list { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-bottom: 10px; }
.merge-entry-btn { background: var(--surface) !important; border: 1.5px solid var(--border) !important; border-radius: 16px !important; text-align: left; padding: 16px 20px; line-height: 1.4; color: var(--text) !important; transition: border-color 0.15s; font-family: inherit; }
.merge-entry-btn:active { border-color: var(--accent) !important; opacity: 0.9; }
.merge-divider { display: flex; align-items: center; gap: 10px; color: var(--text2); font-size: 12px; margin: 4px 0 14px; }
.merge-divider::before, .merge-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* PROCESSING — dark warm ink */
#screen-processing { background: linear-gradient(160deg, var(--dark-bg1) 0%, var(--dark-bg2) 100%); align-items: center; justify-content: center; gap: 24px; padding: 40px; text-align: center; color: var(--dark-text); }
#screen-processing-error { background: linear-gradient(160deg, var(--dark-bg1) 0%, var(--dark-bg2) 100%); align-items: center; justify-content: center; gap: 20px; padding: 40px; text-align: center; color: var(--dark-text); }
#screen-processing-error .btn-secondary { background: rgba(247,240,223,0.08); border-color: rgba(247,240,223,0.2); color: var(--dark-text); }
#screen-processing-error .btn-ghost { color: var(--dark-text2); }
.pulse-loader { display: flex; align-items: center; gap: 7px; height: 48px; }
.pulse-loader div { width: 5px; border-radius: 3px; background: var(--amber); animation: pulse-bar 1.1s ease-in-out infinite; }
.pulse-loader div:nth-child(1) { animation-delay: 0s; }
.pulse-loader div:nth-child(2) { animation-delay: 0.15s; }
.pulse-loader div:nth-child(3) { animation-delay: 0.3s; }
.pulse-loader div:nth-child(4) { animation-delay: 0.45s; }
.pulse-loader div:nth-child(5) { animation-delay: 0.6s; }
@keyframes pulse-bar {
  0%, 100% { height: 10px; opacity: 0.35; }
  50% { height: 40px; opacity: 1; }
}
.progress-bar-wrap { width: 100%; max-width: 280px; background: rgba(247,240,223,0.12); border-radius: 8px; height: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--amber), var(--amber2)); border-radius: 8px; transition: width 0.15s linear; }

/* ENTRY DETAIL */
#screen-detail { background: var(--bg); }
.detail-header { padding: max(56px, calc(env(safe-area-inset-top) + 20px)) 24px 12px; display: flex; align-items: center; gap: 16px; }
.back-btn { font-size: 24px; cursor: pointer; color: var(--accent); }
.detail-scroll { flex: 1; overflow-y: auto; padding: 20px 24px 60px; }
.detail-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.25; margin-bottom: 8px; -webkit-tap-highlight-color: transparent; }
.detail-title:active { opacity: 0.7; }
.detail-meta { font-size: 13px; color: var(--text2); margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }
.detail-refresh-title-btn { display: inline-flex; align-items: center; gap: 5px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 9px; cursor: pointer; color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: 0.2px; flex-shrink: 0; transition: background 0.15s, transform 0.1s; -webkit-tap-highlight-color: transparent; }
.detail-refresh-title-btn:active { background: var(--surface); transform: scale(0.93); }
.detail-refresh-title-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.detail-refresh-title-btn svg { width: 13px; height: 13px; }
.title-refresh-pill { font-size: 12px; color: var(--accent); background: rgba(124,92,62,0.08); border: 1px solid rgba(124,92,62,0.18); border-radius: 8px; padding: 5px 10px; margin-top: 6px; display: inline-block; transition: opacity 0.3s; }
.title-refresh-pill--done { color: var(--accent2, var(--accent)); }
.title-refresh-pill--error { color: #c0392b; background: rgba(192,57,43,0.07); border-color: rgba(192,57,43,0.2); }
.divider { height: 1px; background: var(--border); margin-bottom: 20px; }
.detail-section { margin-bottom: 20px; }
.detail-section-label { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.detail-section-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.detail-refresh-analysis-btn { background: transparent; border: none; color: var(--accent2); cursor: pointer; padding: 2px 4px; display: flex; align-items: center; opacity: 0.7; transition: opacity 0.15s, transform 0.15s; -webkit-tap-highlight-color: transparent; }
.detail-refresh-analysis-btn::before { content: '↻'; font-size: 16px; line-height: 1; }
.detail-refresh-analysis-btn:active { opacity: 1; transform: scale(0.9); }
.detail-refresh-analysis-btn:disabled { opacity: 0.3; cursor: default; transform: none; }
.detail-refresh-analysis-btn--loading::before { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.detail-section-content { background: var(--surface); border-radius: 14px; padding: 16px; font-size: 15px; line-height: 1.8; border: 1px solid var(--border); }
.mood-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 16px; font-size: 14px; font-weight: 500; }
.themes-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-tag { background: rgba(124,92,62,0.1); border: 1px solid rgba(124,92,62,0.22); border-radius: 20px; padding: 6px 14px; font-size: 13px; color: var(--accent); }
.theme-tag-tap { cursor: pointer; transition: background 0.15s, transform 0.15s; }
.theme-tag-tap:active { background: rgba(124,92,62,0.2); transform: scale(0.95); }

/* THEME SCREEN */
#screen-theme { background: var(--bg); }
#theme-hero { background: linear-gradient(145deg, #3D2510, var(--accent), var(--accent2)); padding: 100px 28px 28px; position: relative; flex-shrink: 0; }
.theme-hero-back { position: absolute; top: 56px; left: 20px; width: 38px; height: 38px; background: rgba(247,240,223,0.18); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; color: var(--dark-text); }
.theme-scroll { flex: 1; overflow-y: auto; padding: 24px 20px 60px; }
.theme-mood-pill { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.theme-entry-card { background: var(--card); border: 1.5px solid var(--border); border-radius: 18px; padding: 16px; margin-bottom: 12px; cursor: pointer; transition: border-color 0.15s; box-shadow: 0 2px 8px rgba(30,20,10,0.06); }
.theme-entry-card:active { border-color: var(--accent); }
.theme-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* INSIGHTS */
#screen-insights { background: var(--bg); }
.insights-scroll { flex: 1; overflow-y: auto; padding: 8px 20px 100px; }

/* ANALYTICS */
.analytics-section { margin-bottom: 4px; }
.analytics-row { display: flex; gap: 10px; margin-bottom: 14px; }
.analytics-stat { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px 12px; text-align: center; }
.analytics-stat-value { font-size: 26px; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: 4px; }
.analytics-stat-label { font-size: 11px; color: var(--text2); font-weight: 500; }
.analytics-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.analytics-card-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.analytics-mood-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.analytics-mood-em { font-size: 13px; color: var(--text); width: 112px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.analytics-mood-bar-wrap { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.analytics-mood-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 3px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.analytics-mood-count { font-size: 12px; color: var(--text2); width: 20px; text-align: right; flex-shrink: 0; }
.analytics-habit-grid { display: flex; gap: 10px; }
.analytics-habit-item { flex: 1; background: var(--surface2); border-radius: 14px; padding: 14px 10px; text-align: center; }
.analytics-habit-icon { font-size: 22px; margin-bottom: 6px; }
.analytics-habit-val { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.analytics-habit-sub { font-size: 11px; color: var(--text2); }
.analytics-ai-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); margin: 8px 0 16px; text-align: center; }
.insights-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 40px; text-align: center; }
.insight-card { border-radius: 20px; padding: 22px; margin-bottom: 14px; position: relative; overflow: hidden; animation: card-fadein 0.4s ease both; }
@keyframes card-fadein { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.insight-card-emoji { font-size: 36px; margin-bottom: 12px; }
.insight-card-label { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.7; margin-bottom: 6px; }
.insight-card-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.insight-card-body { font-size: 14px; line-height: 1.7; opacity: 0.9; }


/* LIGHTBOX — always black */
#photo-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.96); z-index: 999; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#photo-lightbox img { max-width: 100%; max-height: 82dvh; object-fit: contain; border-radius: 6px; user-select: none; -webkit-user-drag: none; }
.lightbox-close { position: absolute; top: max(20px, env(safe-area-inset-top)); right: 24px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; cursor: pointer; }
.lightbox-dots { position: absolute; bottom: max(32px, env(safe-area-inset-bottom)); display: flex; gap: 6px; align-items: center; justify-content: center; }
.lightbox-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.35); transition: background 0.15s, transform 0.15s; }
.lightbox-dot.active { background: white; transform: scale(1.3); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Upload date/time modal ─────────────────────────────────────────────────── */
.upload-datetime-card { background: var(--card); border-radius: 20px; padding: 28px 24px 20px; width: min(340px, calc(100vw - 48px)); display: flex; flex-direction: column; gap: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.upload-datetime-title { font-size: 18px; font-weight: 700; color: var(--text); text-align: center; }
.upload-datetime-body { display: flex; flex-direction: column; gap: 14px; }
.upload-datetime-label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text2); }
.upload-datetime-input { background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-family: inherit; color: var(--text); outline: none; width: 100%; box-sizing: border-box; }
.upload-datetime-input:focus { border-color: var(--accent); }
.upload-datetime-actions { display: flex; gap: 10px; }

/* PHOTO COVER HERO */
#photo-section { position: relative; margin: -20px -24px 20px; overflow: hidden; display: none; }
#photo-section::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 72px; background: linear-gradient(to bottom, transparent, var(--bg)); pointer-events: none; z-index: 1; }
.photo-hero-img { width: 100%; height: 220px; object-fit: cover; display: block; }
.photo-hero-skeleton { width: 100%; height: 220px; background: var(--surface2); }

/* PHOTO SLOTS */
.photo-slots-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.photo-slot { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface2); }
.photo-slot--empty { border: 1.5px dashed var(--border); display: flex; align-items: center; justify-content: center; color: var(--text2); cursor: pointer; background: none; width: 100%; }
.photo-slot--empty:active { opacity: 0.6; }
.photo-slot--empty svg { width: 20px; height: 20px; }
.photo-slot--loading { display: flex; align-items: center; justify-content: center; }
.photo-slot--uploading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; }
.photo-slot-upload-label { font-size: 9px; color: var(--text2); letter-spacing: 0.3px; white-space: nowrap; }
.photo-slot-progress-track { width: 80%; height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.photo-slot-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.18s ease; }
.photo-slot--filled img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.photo-slot--cover { outline: 2px solid var(--accent); outline-offset: 1px; }
.photo-slot-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.photo-slot--error { display: flex; align-items: center; justify-content: center; color: var(--text2); font-size: 13px; }
.photo-slot-btn { position: absolute; width: 22px; height: 22px; border-radius: 5px; background: rgba(0,0,0,0.62); border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.photo-slot-delete { top: 3px; right: 3px; }
.photo-slot-delete svg { width: 10px; height: 10px; }
.photo-slot-cover { top: 3px; left: 3px; font-size: 10px; line-height: 1; }
.photo-slot-cover--active { background: var(--accent); }

/* AUDIO PLAYER */
.audio-player { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; }
.audio-player-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.play-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--dark-text); }
.audio-time-label { font-size: 13px; color: var(--text2); flex: 1; }
.audio-duration { font-size: 12px; color: var(--text2); font-variant-numeric: tabular-nums; }
.audio-scrubber-wrap { position: relative; height: 28px; display: flex; align-items: center; cursor: pointer; }
.audio-scrubber-track { position: absolute; left: 0; right: 0; height: 4px; background: var(--border); border-radius: 2px; }
.audio-scrubber-fill { position: absolute; left: 0; height: 4px; background: var(--accent); border-radius: 2px; width: 0%; }
.audio-scrubber-thumb { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--accent2); left: 0%; transform: translateX(-50%); box-shadow: 0 1px 4px rgba(30,20,10,0.28); }
.audio-time-row { display: flex; justify-content: space-between; margin-top: 4px; }
.audio-time-cur { font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; }
.audio-time-tot { font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; }

/* TRANSCRIPT & POLISHED — generous line-height for readability */
.transcript-block { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; font-size: 15px; line-height: 1.85; margin-bottom: 10px; }
.transcript-divider { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); margin: 4px 0 10px; }
.transcript-divider::before, .transcript-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.polished-section { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 10px; }
.polished-section-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.polished-section-content { font-size: 15px; line-height: 1.85; color: var(--text); }

/* SETTINGS */
#screen-settings, #screen-people, #screen-people-add { background: var(--bg); }
.settings-header { padding: 56px 24px 16px; display: flex; align-items: center; gap: 16px; }
/* .settings-header-nav: use on sub-screens with back+title+action.
   CSS Grid 1fr/auto/1fr guarantees the title is truly centered regardless
   of whether the left (back btn) and right (action/spacer) are the same width.
   space-between alone fails because btn-ghost width:100% and unequal side widths
   push the title off-center. */
.settings-header-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0; }
.settings-header-nav > :last-child { display: flex; justify-content: flex-end; }
.settings-header-nav .btn-ghost { width: auto; padding: 8px 4px; font-size: 15px; justify-self: start; }
.settings-scroll { flex: 1; overflow-y: auto; padding: 16px 24px 100px; }
.settings-section-title { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); margin: 24px 0 10px; }
.settings-row { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.settings-label { font-size: 15px; }
.settings-value { font-size: 15px; color: var(--text2); }
.stats-row { display: flex; gap: 12px; margin-bottom: 8px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; text-align: center; flex: 1; }
.stat-number { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* BOTTOM NAV */
#bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-around; padding: 0 8px max(12px, env(safe-area-inset-bottom)); padding-top: 8px; z-index: 100; min-height: 64px; }
.nav-btn { background: none; border: none; color: var(--text2); display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 10px; font-weight: 600; letter-spacing: 0.3px; padding: 8px 16px; border-radius: 14px; transition: color 0.15s; flex: 1; font-family: inherit; }
.nav-btn.active { color: var(--accent); }
.nav-icon-filled { display: none; }
.nav-btn.active .nav-icon-outline { display: none; }
.nav-btn.active .nav-icon-filled { display: block; }

/* TOAST */
.app-toast { position: fixed; bottom: calc(max(80px, env(safe-area-inset-bottom) + 64px) + 16px); left: 50%; transform: translateX(-50%) translateY(12px); background: var(--text); border: 1px solid var(--accent); border-radius: 24px; padding: 12px 20px; font-size: 14px; color: var(--bg); white-space: nowrap; max-width: min(320px, calc(100vw - 48px)); text-align: center; z-index: 1000; opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease, bottom 0.3s ease; pointer-events: none; }
.app-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* COVER PHOTO */
.entry-card-body-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.entry-card-cover-slot { flex-shrink: 0; width: 52px; height: 52px; }
.entry-card-cover-slot:empty { display: none; }
.entry-card-cover { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); display: block; }
.entry-card-text { flex: 1; min-width: 0; }

.cal-btn { background: none; border: none; color: var(--text2); cursor: pointer; padding: 8px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.cal-btn:active { background: var(--surface2); }
.people-btn { position: relative; }
.people-btn-badge { position: absolute; top: 2px; right: 2px; font-size: 10px; font-weight: 700; color: var(--accent); line-height: 1; pointer-events: none; }

/* CALENDAR MODAL */
.cal-modal-backdrop { position: fixed; inset: 0; background: rgba(30,20,10,0.48); z-index: 500; display: flex; align-items: flex-end; justify-content: center; }
.cal-modal { background: var(--surface); border-radius: 24px 24px 0 0; width: 100%; max-width: 480px; padding: 20px 20px max(28px, env(safe-area-inset-bottom)); }
.cal-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-month-label { font-size: 17px; font-weight: 700; }
.cal-nav-btn { background: var(--surface2); border: none; color: var(--text); width: 36px; height: 36px; border-radius: 50%; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: inherit; }
.cal-legend { display: flex; gap: 16px; margin-bottom: 14px; }
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text2); }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; font-weight: 700; color: var(--text2); letter-spacing: 0.3px; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 20px; }
.cal-day { height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 14px; border-radius: 12px; cursor: default; color: var(--text2); opacity: 0.3; }
.cal-day-num { line-height: 1; }
.cal-day-dot { display: none; }
.cal-day-entry { cursor: pointer; opacity: 1; color: var(--text); font-weight: 600; }
.cal-day-entry .cal-day-dot { display: block; width: 4px; height: 4px; background: var(--accent2); border-radius: 50%; }
.cal-day-entry:active { opacity: 0.6; transform: scale(0.93); }
.cal-day-today { opacity: 1; color: var(--dark-text); background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 12px; font-weight: 700; }
.cal-day-today.cal-day-entry .cal-day-dot { background: rgba(247,240,223,0.7); }
.cal-day-future { opacity: 0.18; }
.cal-day-empty-past { opacity: 0.28; }
.cal-close-btn { width: 100%; padding: 14px; background: var(--surface2); border: none; border-radius: 14px; color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
/* Scroll-wheel picker */
.cal-wheel-wrap { position: relative; display: flex; height: 220px; margin-bottom: 16px; overflow: hidden; border-radius: 14px; }
.cal-wheel { flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; position: relative; z-index: 2; }
.cal-wheel::-webkit-scrollbar { display: none; }
.cal-wheel-item { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 16px; scroll-snap-align: center; color: var(--text); }
/* Central highlight bar — hairline borders only, no background fill so text shows through */
.cal-wheel-highlight { position: absolute; top: 88px; left: 0; right: 0; height: 44px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); pointer-events: none; z-index: 3; }
/* Fade overlays make items above/below the selection recede */
.cal-wheel-overlay { position: absolute; left: 0; right: 0; height: 88px; pointer-events: none; z-index: 4; }
.cal-wheel-overlay--top    { top: 0;    background: linear-gradient(to bottom, var(--surface) 20%, transparent); }
.cal-wheel-overlay--bottom { bottom: 0; background: linear-gradient(to top,   var(--surface) 20%, transparent); }

/* CROP MODAL — always black */
.crop-modal-backdrop { position: fixed; inset: 0; background: #000; z-index: 600; display: flex; flex-direction: column; }
.crop-modal { display: flex; flex-direction: column; width: 100%; height: 100%; }
.crop-header { padding: max(56px, calc(env(safe-area-inset-top) + 16px)) 20px 14px; display: flex; align-items: center; justify-content: space-between; background: #000; gap: 12px; }
.crop-rotate-btn { flex-shrink: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.1); border: none; border-radius: 50%; color: white; cursor: pointer; padding: 0; transition: background 0.15s ease, transform 0.2s ease; }
.crop-rotate-btn:active { background: rgba(255,255,255,0.2); transform: rotate(90deg); }
.crop-header-title { font-size: 17px; font-weight: 700; color: white; }
.crop-header-sub { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 2px; }
.crop-viewport { flex: 1; overflow: hidden; position: relative; background: #111; cursor: grab; touch-action: none; user-select: none; }
.crop-viewport:active { cursor: grabbing; }
#crop-img { position: absolute; user-select: none; -webkit-user-drag: none; pointer-events: none; max-width: none; transform-origin: top left; }
/* Circle dim — only shown in cover mode */
.crop-viewport.crop-mode-cover::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle closest-side at 50% 50%, transparent 49%, rgba(0,0,0,0.55) 50%);
  pointer-events: none;
  z-index: 2;
}
.crop-circle-ring { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); border: 2px solid rgba(255,255,255,0.8); border-radius: 50%; pointer-events: none; z-index: 3; display: none; }
.crop-viewport.crop-mode-cover .crop-circle-ring { display: block; }
/* Rectangle frame — only shown in header mode. box-shadow creates the dim outside-area without needing a separate overlay. */
.crop-rect-frame { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); border: 2px solid rgba(255,255,255,0.8); box-shadow: 0 0 0 9999px rgba(0,0,0,0.55); pointer-events: none; z-index: 3; display: none; }
.crop-viewport.crop-mode-header .crop-rect-frame { display: block; }
.crop-actions { display: flex; gap: 12px; padding: 16px 20px max(24px, env(safe-area-inset-bottom)); background: #000; }
.crop-btn-secondary { flex: 1; padding: 14px; background: rgba(255,255,255,0.1); border: none; border-radius: 14px; color: rgba(255,255,255,0.7); font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.crop-btn-primary { flex: 2; padding: 14px; background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; border-radius: 14px; color: var(--dark-text); font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; }

/* Cover/Header choice modal */
.cover-choice-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 700; display: flex; align-items: flex-end; justify-content: center; padding: 0 16px max(24px, env(safe-area-inset-bottom)); animation: cover-choice-fade 0.18s ease; }
@keyframes cover-choice-fade { from { opacity: 0; } to { opacity: 1; } }
.cover-choice-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; animation: cover-choice-slide 0.22s ease; }
@keyframes cover-choice-slide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.cover-choice-title { font-size: 17px; font-weight: 700; color: var(--text); padding: 4px 4px 8px; }
.cover-choice-btn { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; color: var(--text); cursor: pointer; font-family: inherit; text-align: left; transition: background 0.15s ease; }
.cover-choice-btn:active { background: var(--accent); color: var(--dark-text); }
.cover-choice-icon-wrap { flex-shrink: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.cover-choice-icon-circle { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--accent2); }
.cover-choice-icon-rect { width: 40px; height: 24px; border-radius: 4px; border: 2px solid var(--accent2); }
.cover-choice-text { flex: 1; min-width: 0; }
.cover-choice-label { font-size: 15px; font-weight: 600; }
.cover-choice-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.cover-choice-btn:active .cover-choice-sub { color: var(--dark-text); opacity: 0.85; }
.cover-choice-cancel { padding: 12px; background: transparent; border: none; color: var(--text2); font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit; margin-top: 4px; }

/* AI PERIOD TABS */
.ai-period-tabs { display: flex; gap: 8px; margin-top: 4px; }
.ai-tab { flex: 1; padding: 9px 6px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; color: var(--text2); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.18s; font-family: inherit; }
.ai-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: var(--dark-text); }

/* BUTTONS */
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--dark-text); border: none; padding: 16px 24px; border-radius: 14px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%; font-family: inherit; }
.btn-primary:active { opacity: 0.85; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); padding: 16px 24px; border-radius: 14px; font-size: 16px; font-weight: 500; cursor: pointer; width: 100%; font-family: inherit; }
.btn-ghost { background: transparent; color: var(--text2); border: none; padding: 16px 24px; border-radius: 14px; font-size: 16px; cursor: pointer; width: 100%; font-family: inherit; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); padding: 16px 24px; border-radius: 14px; font-size: 16px; font-weight: 500; cursor: pointer; width: 100%; font-family: inherit; }

/* ── MY CIRCLE (PEOPLE) ───────────────────────────────────────────────────── */
.people-input { width: 100%; box-sizing: border-box; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 14px 16px; font-size: 15px; color: var(--text); font-family: inherit; outline: none; display: block; resize: none; }
.people-input:focus { border-color: var(--accent); }
.people-rel-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.people-rel-tag { padding: 8px 16px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px; font-size: 14px; font-weight: 500; color: var(--text2); cursor: pointer; font-family: inherit; transition: all 0.15s; }
.people-rel-tag.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: var(--dark-text); }
.person-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.person-card-info { flex: 1; cursor: pointer; }
.person-card-name { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.person-card-rel { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); background: rgba(100,180,160,0.12); border-radius: 8px; padding: 2px 8px; margin-bottom: 4px; }
.person-card-notes { font-size: 13px; color: var(--text2); line-height: 1.4; }
.person-card-actions { display: flex; gap: 8px; }
.person-delete-btn { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; font-size: 13px; color: var(--text2); cursor: pointer; font-family: inherit; }
.people-empty { text-align: center; color: var(--text2); font-size: 15px; padding: 48px 24px; line-height: 1.7; }
#people-sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 28px 24px 40px; width: 100%; box-sizing: border-box; }
.new-people-banner { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.new-people-banner-header { display: flex; justify-content: space-between; align-items: center; }
.new-people-banner-title { font-size: 11px; font-weight: 700; color: var(--accent2); letter-spacing: 1px; text-transform: uppercase; }
.new-people-banner-dismiss { background: transparent; border: none; color: var(--text2); cursor: pointer; padding: 4px 6px; display: flex; align-items: center; }
.new-people-banner-dismiss svg { width: 16px; height: 16px; }
.pending-name-row { display: flex; flex-direction: column; gap: 8px; }
.pending-name-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pending-name-chip-wrap { display: flex; align-items: center; flex: 1; min-width: 0; }
.pending-name-chip-wrap::before { content: '"'; color: var(--text2); font-size: 14px; font-weight: 600; }
.pending-name-chip { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; min-width: 60px; max-width: 160px; background: transparent; border: none; border-bottom: 1.5px dashed var(--border); outline: none; font-family: inherit; padding: 0 2px; }
.pending-name-chip:focus { border-bottom-color: var(--accent); }
.pending-name-btns { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.pending-add-btn { background: var(--accent); color: var(--dark-text); border: none; border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.pending-match-btn { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.match-picker { background: var(--bg); border-radius: 8px; padding: 10px 12px; border: 1px solid var(--border); }
.match-picker-label { font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.match-picker-list { display: flex; flex-direction: column; gap: 4px; }
.match-picker-person { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-family: inherit; cursor: pointer; display: flex; align-items: center; gap: 8px; text-align: left; width: 100%; }
.match-picker-person:active { opacity: 0.7; }
.match-picker-person-name { font-size: 14px; font-weight: 600; color: var(--text); }
.match-picker-person-rel { font-size: 12px; color: var(--text2); }
.match-picker-empty { font-size: 13px; color: var(--text2); text-align: center; padding: 4px 0; }

/* PRONUNCIATION RECORD BUTTON */
.pron-record-btn { width: 100%; padding: 14px 16px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; color: var(--text2); font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit; text-align: left; transition: all 0.15s; display: flex; align-items: center; gap: 10px; }
.pron-record-btn svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.pron-record-btn:active { opacity: 0.8; }
.pron-record-btn--recording { border-color: var(--danger); color: var(--danger); background: rgba(220,80,80,0.07); }
.pron-record-btn--saved { border-color: var(--accent); color: var(--accent); background: rgba(100,180,160,0.08); }
/* Inline mic button on person cards in the My Circle list */
.person-pron-btn { background: none; border: none; padding: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text2); transition: color 0.2s, opacity 0.2s; }
.person-pron-btn svg { width: 20px; height: 20px; }
.person-pron-btn--empty { color: var(--text2); }
.person-pron-btn--saved { color: var(--text2); }
.person-pron-btn--recording { color: var(--danger); }
.person-pron-btn:active { opacity: 0.5; }
.person-pron-btn:disabled { opacity: 0.4; cursor: default; }

/* Pronunciation recording popup */
.pron-popup-card { background: var(--surface); border-radius: 20px; padding: 32px 28px; width: 280px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.pron-popup-label { font-size: 13px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.pron-popup-name { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 24px; }
.pron-popup-timer { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text2); }
.pron-popup-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pron-blink 0.9s ease-in-out infinite; }
@keyframes pron-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ── LANDSCAPE / MOBILE HORIZONTAL ───────────────────────────────────────────
   Targets phones rotated sideways (portrait height now ≤ 500px wide viewport).
   Goals:
   1. Reduce all fixed top padding so headers don't eat the viewport.
   2. Compress recording screen to fit without scrolling.
   3. Shrink PIN buttons so the pad fits.
   4. Pad left/right for the iPhone notch (safe-area-inset-left/right).
   5. Let tall content screens scroll instead of clipping.
   ─────────────────────────────────────────────────────────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {

  /* ── Safe area — notch/Dynamic Island moves to the sides in landscape ── */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* ── Home ─────────────────────────────────────────────────────────────── */
  .home-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }
  .home-title { font-size: 22px; }
  .entries-list { padding-bottom: 240px; }
  /* FAB — bottom-center */
  .record-fab {
    bottom: calc(56px + max(8px, env(safe-area-inset-bottom)));
  }
  #screen-home::before { height: 160px; }
  #screen-home::after { height: 100px; }

  /* ── Compact headers (detail, settings, sub-screens) ─────────────────── */
  .detail-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }
  .settings-header { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 8px; }

  /* ── Recording ────────────────────────────────────────────────────────── */
  #screen-recording {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
    padding: max(12px, env(safe-area-inset-top)) 20px max(8px, env(safe-area-inset-bottom));
    align-items: center;
    justify-content: center;
    column-gap: 32px;
    row-gap: 0;
  }
  /* Close button stays top-left, already absolute */
  .rec-close { top: max(12px, env(safe-area-inset-top)); }
  /* Left column: label + timer + dot */
  .rec-label  { order: 1; width: auto; margin: 0; }
  .rec-timer  { order: 2; font-size: 36px; margin: 0; }
  .rec-dot    { order: 3; margin: 4px auto 0; }
  /* Right column: waveform → hint → controls → discard */
  .waveform-wrap { order: 4; }
  .waveform { height: 40px; }
  .rec-hint  { order: 5; display: none; } /* hidden — no room */
  .rec-controls { order: 6; }
  .stop-btn { width: 64px; height: 64px; }
  .pause-btn { width: 44px; height: 44px; }
  #screen-recording .btn-ghost { order: 7; padding: 8px 16px; font-size: 14px; }

  /* ── PIN screens ──────────────────────────────────────────────────────── */
  #screen-pin-setup, #screen-lock, #screen-pin-remove {
    gap: 12px;
    padding: max(16px, env(safe-area-inset-top)) 40px max(8px, env(safe-area-inset-bottom));
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    column-gap: 40px;
  }
  .pin-dots { order: 1; }
  .pin-pad  { order: 2; gap: 8px; }
  .pin-btn  { width: 56px; height: 56px; font-size: 18px; }
  /* Labels + actions sit above the two-column layout */
  #screen-pin-setup > :not(.pin-dots):not(.pin-pad),
  #screen-lock > :not(.pin-dots):not(.pin-pad),
  #screen-pin-remove > :not(.pin-dots):not(.pin-pad) { order: 0; width: 100%; text-align: center; }

  /* ── Welcome, review, merge — scrollable in landscape ────────────────── */
  #screen-welcome, #screen-review, #screen-merge {
    gap: 14px;
    padding: max(16px, env(safe-area-inset-top)) 40px max(12px, env(safe-area-inset-bottom));
    overflow-y: auto;
    justify-content: flex-start;
  }
  .welcome-sub { font-size: 14px; }
  .splash-wordmark { font-size: 48px; }

  /* ── Auth screen ──────────────────────────────────────────────────────── */
  #screen-auth { padding-top: max(16px, env(safe-area-inset-top)); gap: 10px; }

  /* ── Processing screens ───────────────────────────────────────────────── */
  #screen-processing, #screen-processing-error {
    gap: 14px;
    padding: max(16px, env(safe-area-inset-top)) 40px max(8px, env(safe-area-inset-bottom));
  }
  .pulse-loader div { }
  @keyframes pulse-bar-ls { 0%, 100% { height: 8px; } 50% { height: 28px; } }

  /* ── Bottom nav — slightly shorter ───────────────────────────────────── */
  #bottom-nav {
    padding-top: 4px;
    min-height: 52px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
  .nav-btn { padding: 4px 16px; font-size: 9px; }

  /* ── Crop modal ───────────────────────────────────────────────────────── */
  .crop-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }
}
