:root {
  --color-rupa:     #378ADD;
  --color-vedana:   #BA7517;
  --color-sanna:    #D85A30;
  --color-sankhara: #1D9E75;
  --color-vinnana:  #534AB7;

  --bg:         #F9F7F4;
  --surface:    #FFFFFF;
  --text:       #1A1A1A;
  --text-muted: #6B6B6B;
  --border:     #E0DDD8;
  --radius:     12px;
  --color-phuru: #C9AF7A;
  --color-special: #B5567A;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #12110F;
    --surface:    #1C1B18;
    --text:       #F0EDE8;
    --text-muted: #9B9690;
    --border:     #2E2C28;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 80px;
  min-height: 100vh;
}

.cinzel { font-family: 'Cinzel', Georgia, serif; }
.mono   { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; }

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 24px 0 20px;
}

header h1 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

header p {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.header-gear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.header-gear:hover { color: var(--color-vinnana); }

.header-gear svg { width: 22px; height: 22px; }

.header-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Pre-login / consent-gate language switch (top-right, gap #35) ── */
.lang-text-pair {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  flex-shrink: 0;
}

.lang-text-pair button {
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.lang-text-pair button.active {
  color: var(--color-vinnana);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lang-text-pair button:focus-visible {
  outline: 2px solid var(--color-vinnana);
  outline-offset: 2px;
}

.lang-text-pair .lang-sep { color: var(--border); }

/* ── Sections ── */
section {
  margin-bottom: 24px;
}

section h2, .example-shell h2 {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Date input ── */
#entry-date {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none;
  cursor: pointer;
}

#entry-date:focus { border-color: var(--color-vinnana); }

/* ── Date widget (shared calendar popup) ──
   Custom month-grid picker, replacing native <input type="date"> so day
   cells can carry glyphs — see mountDateWidget() in app.js. Used on the
   entry page (a trigger button + popup layered over the real, visually
   hidden #entry-date) and in Settings' dates section (loss-date row +
   add-a-date form), all sharing this same markup/CSS. Colors/fonts reuse
   existing tokens only — no new palette introduced. */

.date-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
.date-trigger-btn:focus, .date-trigger-btn:hover { border-color: var(--color-vinnana); }
.date-trigger-btn svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.date-trigger-btn.is-open { border-color: var(--color-vinnana); }

.date-milestone-note {
  margin-top: -2px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--color-vinnana);
}
.date-milestone-note .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-vinnana);
  flex-shrink: 0;
}
.date-milestone-note .sep { color: var(--border); margin: 0 1px; }
.date-milestone-note.is-range { color: var(--text-muted); }
.date-milestone-note.is-range .dot {
  background: transparent;
  border: 1px solid var(--text-muted);
  opacity: 0.6;
}
.date-milestone-note.is-range.is-almost { color: var(--color-vinnana); opacity: 0.75; }
.date-milestone-note.is-range.is-almost .dot { border-color: var(--color-vinnana); background: transparent; opacity: 0.75; }

.calendar-popup {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 14px 16px;
  margin-top: 8px;
  margin-bottom: 14px;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}
.cal-nav-btn:hover { border-color: var(--color-vinnana); color: var(--color-vinnana); }

.cal-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--text);
}

.cal-title-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.cal-title-btn:hover { background: var(--border); }

.cal-year-input {
  width: 90px;
  text-align: center;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--color-vinnana);
  border-radius: 8px;
  padding: 4px 6px;
  outline: none;
  /* hide native spinner arrows — this is a compact inline year field, not
     a stepper control (‹ › already cover single-year steps) */
  -moz-appearance: textfield;
}
.cal-year-input::-webkit-outer-spin-button,
.cal-year-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cal-back-row {
  margin-bottom: 8px;
}

.cal-back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 0;
}
.cal-back-btn:hover { color: var(--color-vinnana); }

.cal-today-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.cal-today-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  cursor: pointer;
  padding: 3px 10px;
}
.cal-today-btn:hover { border-color: var(--color-vinnana); color: var(--color-vinnana); }

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 0 2px;
}

.cal-month-btn {
  padding: 12px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  cursor: pointer;
}
.cal-month-btn:hover { border-color: var(--color-vinnana); }
.cal-month-btn.is-selected {
  background: var(--color-vinnana);
  border-color: var(--color-vinnana);
  color: #fff;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
  background: transparent;
}

.cal-day.other-month { color: var(--border); cursor: default; }
.cal-day:not(.other-month):hover { background: var(--border); }

.cal-day.is-today { font-weight: 700; }
.cal-day.is-today::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}

.cal-day.is-selected {
  background: var(--color-vinnana);
  color: #fff;
}

.cal-day .badge-row {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  gap: 1px;
}
.cal-day .badge {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.cal-day .badge.wanphra { background: var(--color-phuru); }
.cal-day .badge.milestone-exact { background: var(--color-vinnana); }
.cal-day.is-selected .badge.milestone-exact { background: #fff; }
.cal-day .badge.special-date { background: var(--color-special); }
.cal-day.is-selected .badge.special-date { background: #fff; }

/* quiet loss-date marker (entry page only, milestone tally hidden there) —
   a muted hollow ring rather than a filled dot, so it reads as "this date
   is remembered" without implying a countdown/tally like the milestone
   glyphs do */
.cal-day .badge.loss-date {
  background: transparent;
  border: 1px solid var(--color-vinnana);
  opacity: 0.7;
}
.cal-day.is-selected .badge.loss-date { border-color: #fff; }

.cal-day .badge.milestone-near {
  background: transparent;
  border: 1px solid var(--color-vinnana);
  opacity: 0.55;
}
.cal-day.is-selected .badge.milestone-near { border-color: #fff; }

.cal-day.milestone-exact-day:not(.is-selected) {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-vinnana) 45%, transparent);
}

.cal-popup-anchor { margin-top: 8px; }

/* ── Settings: dates section (loss date + special dates list) ── */
.special-dates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.special-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  cursor: pointer;
}

.special-date-row .row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-special);
  flex-shrink: 0;
}

.special-date-row.is-loss-date {
  border-color: var(--color-vinnana);
  background: color-mix(in srgb, var(--color-vinnana) 6%, var(--surface));
}
.special-date-row.is-loss-date .row-dot { background: var(--color-vinnana); }
.special-date-row.is-loss-date .row-label { color: var(--color-vinnana); font-weight: 600; }

.special-date-row.is-loss-date.is-unset {
  border-style: dashed;
  background: transparent;
}
.special-date-row.is-loss-date.is-unset .row-dot {
  background: transparent;
  border: 1px solid var(--color-vinnana);
  opacity: 0.6;
}
.special-date-row.is-loss-date.is-unset .row-label { font-weight: 400; }
.special-date-row.is-loss-date.is-unset .row-date { font-style: italic; }
.special-date-row.is-loss-date.is-unset .pinned-lock { opacity: 0.35; }

.pinned-lock {
  color: var(--color-vinnana);
  opacity: 0.6;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.pinned-lock svg { width: 14px; height: 14px; }

.special-date-row .row-text { flex: 1; min-width: 0; }

.special-date-row .row-label {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.special-date-row .row-date {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.special-date-row .row-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.special-date-row .row-remove:hover { color: #c0392b; }
.special-date-row .row-remove svg { width: 16px; height: 16px; }

.special-dates-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0 2px;
}

/* ── special-date row, expanded for editing (tap row, not just the
   remove icon — see the loss-date row's own tap-to-edit for the pattern
   this mirrors) ── */
.special-date-row.is-editing {
  align-items: flex-start;
  cursor: default;
}

.row-edit-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-edit-fields input[type="text"] {
  margin-top: 0;
  padding: 10px 12px;
  font-size: 14px;
}

.row-edit-fields .date-trigger-btn {
  margin-bottom: 0;
  padding: 10px 12px;
  font-size: 14px;
}

.row-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.row-edit-cancel {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
}
.row-edit-cancel:hover { border-color: var(--text-muted); color: var(--text); }

.row-edit-save.primary-inline {
  flex: 1;
  padding: 10px;
  background: var(--color-vinnana);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
}
.row-edit-save.primary-inline:hover { opacity: 0.88; }

.row-edit-error { margin-top: 0; }

.add-date-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }

.add-date-form .form-row-label {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 12px 0 0;
}
.add-date-form .form-row-label:first-child { margin-top: 0; }

.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  margin-top: 14px;
  background: transparent;
  border: 1px dashed var(--color-special);
  border-radius: var(--radius);
  color: var(--color-special);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
}
.add-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.add-btn svg { width: 14px; height: 14px; }

/* ── Textarea ── */
textarea {
  width: 100%;
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

textarea:focus { border-color: var(--color-vinnana); }

textarea::placeholder { color: var(--text-muted); }

/* ── Text/email/password inputs ── */
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="email"]:focus, input[type="password"]:focus, input[type="text"]:focus {
  border-color: var(--color-vinnana);
}

input[type="email"]::placeholder, input[type="password"]::placeholder, input[type="text"]::placeholder {
  color: var(--text-muted);
}

.password-field {
  position: relative;
}

.password-field input[type="password"], .password-field input[type="text"] {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  bottom: 0;
  height: 48px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 6px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.password-toggle:hover { color: var(--color-vinnana); }

.password-toggle svg { width: 20px; height: 20px; }

.verify-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--color-vedana) 15%, var(--surface));
  border: 1px solid var(--color-vedana);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

.verify-banner span { flex: 1; color: var(--text); }

.verify-banner-resend {
  background: transparent;
  border: 1px solid var(--color-vedana);
  color: var(--color-vedana);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.verify-banner-resend:hover { background: color-mix(in srgb, var(--color-vedana) 12%, transparent); }
.verify-banner-resend:disabled { opacity: 0.6; cursor: default; }

.verify-banner-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}

.verify-banner-dismiss:hover { color: var(--text); }

/* ── Auth pages ── */
.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--color-vinnana);
  text-decoration: none;
}

.auth-switch a:hover { text-decoration: underline; }

/* ── Phase / lens toggle ── */
.phase-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.phase-option {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.phase-option.active {
  border-color: var(--color-vinnana);
  color: var(--color-vinnana);
}

/* ── Language switch ── */
.lang-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.lang-switch-row-label {
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.lang-switch input { display: none; }

.lang-switch-track {
  position: relative;
  width: 60px;
  height: 30px;
  border-radius: 15px;
  background: var(--border);
  transition: background 0.25s;
  flex-shrink: 0;
}

.lang-switch input:checked + .lang-switch-track {
  background: var(--color-vinnana);
}

.lang-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--color-vinnana);
}

.lang-switch input:checked ~ .lang-switch-track .lang-switch-thumb {
  transform: translateX(30px);
}

.lang-switch input:disabled ~ .lang-switch-track {
  opacity: 0.5;
}

.lang-switch input:disabled ~ .lang-switch-track,
.lang-switch:has(input:disabled) {
  cursor: not-allowed;
}

/* ── Buttons ── */
.primary {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: var(--color-vinnana);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: opacity 0.2s;
}

.primary:hover { opacity: 0.88; }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }
.primary:disabled:hover { opacity: 0.4; }

.danger {
  background: transparent;
  color: #c0392b;
  border: 1px solid #c0392b;
}

.danger:hover { opacity: 0.88; background: rgba(192, 57, 43, 0.08); }

/* ── Khandha bars ── */
.khandha-bars { display: flex; flex-direction: column; gap: 10px; }

.khandha-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.khandha-bar-row .bar-label {
  width: 140px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  padding-bottom: 2px;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.khandha-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.khandha-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.khandha-bar-row .bar-value {
  width: 32px;
  text-align: right;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Mini bars (log cards) */
.khandha-bar-row.mini .bar-label { width: 120px; font-size: 10px; }
.khandha-bar-row.mini .khandha-track { height: 5px; }
.khandha-bar-row.mini .bar-value { font-size: 10px; }

/* ── Insight ── */
#insight-text, .insight-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--color-vinnana);
  border-radius: var(--radius);
  padding: 14px 16px;
  line-height: 1.7;
  font-size: 15px;
  margin-bottom: 14px;
}

/* ── Intensity block ── */
.intensity-readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

#intensity-value, .intensity-value {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 36px;
  font-weight: 600;
  line-height: 1;
  transition: color 0.3s;
}

#intensity-label, .intensity-label {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  margin: 6px 0 10px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--color-vinnana);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--color-vinnana);
  cursor: pointer;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

/* ── Post-save locked entry (gap #38) ── */
.saved-badge {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-sankhara);
  margin-top: 18px;
  margin-bottom: 10px;
}

.edit-entry-link {
  display: block;
  background: none;
  border: none;
  color: var(--color-vinnana);
  cursor: pointer;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.02em;
  padding: 0;
  margin-bottom: 22px;
}

.new-entry-cta {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.new-entry-cta:hover { color: var(--text); border-color: var(--text-muted); }

#journal-section textarea:disabled,
#journal-section input:disabled,
#journal-section .phase-option:disabled {
  opacity: 0.7;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border) 35%, var(--surface));
  border-color: var(--border);
  cursor: not-allowed;
}

/* Disabled phase-toggle must still show which phase was selected before
   locking (gap #38 follow-up) — the generic disabled rule above would
   otherwise flatten both buttons to the same muted look, losing that signal. */
#journal-section .phase-option:disabled.active {
  color: var(--color-vinnana);
  border-color: var(--color-vinnana);
  background: color-mix(in srgb, var(--color-vinnana) 12%, var(--surface));
  opacity: 0.85;
}

#result-section input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#result-section input[type="range"]:disabled::-webkit-slider-thumb { cursor: not-allowed; }
#result-section input[type="range"]:disabled::-moz-range-thumb { cursor: not-allowed; }

.value-display {
  font-size: 17px;
  color: var(--text);
  margin-top: 6px;
}

/* ── Tab bar ── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.tab-bar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  letter-spacing: 0.04em;
  border-top: 2px solid transparent;
  transition: color 0.2s;
}

.tab-bar button svg {
  width: 20px;
  height: 20px;
}

.tab-bar button.active {
  color: var(--color-vinnana);
  border-top-color: var(--color-vinnana);
}

.tab-bar button.active span {
  font-weight: 600;
}

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.stat-card .value {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.stat-card .rate-label {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 12px;
  margin-top: 5px;
}

.stat-card .label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.admin-stats-row-5 {
  grid-template-columns: repeat(2, 1fr);
}

/* ── Admin nav ── */
.admin-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.admin-nav a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.admin-nav a.active {
  color: var(--text);
  border-color: var(--color-sankhara);
}

.admin-table-subtext {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Chart ── */
#chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

/* ── Continuity card ── */
.continuity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}

.continuity-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.continuity-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.continuity-count {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
}

.continuity-chevron {
  font-size: 20px;
  color: var(--text-muted);
}

/* ── Entry cards ── */
.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ── Admin user status ── */
.status-active           { color: var(--color-sankhara); }
.status-invited          { color: var(--color-vedana); }
.status-disabled         { color: #A32D2D; }
.status-pending_deletion { color: #A32D2D; }

/* ── Admin table ── */
#admin-users-status-filter,
#admin-waitlist-status-filter {
  width: 100%;
  padding: 12px 14px;
  margin-top: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.admin-table-wrap {
  overflow-x: auto;
  margin-bottom: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.admin-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.admin-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 600px) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
  }
  .admin-table tbody tr:last-child { border-bottom: none; }
  .admin-table td {
    border-bottom: none;
    padding: 3px 0;
  }
  .admin-table td:before {
    content: attr(data-label);
    display: inline-block;
    min-width: 80px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-right: 8px;
  }
}

.khandha-tap-label {
  cursor: pointer;
  border-bottom: 1px dotted var(--text-muted);
}

.khandha-tap-label:hover,
.khandha-tap-label:focus-visible {
  border-bottom-color: var(--text);
  outline: none;
}

.khandha-reveal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 6px 0 12px;
  font-size: 13px;
  /* app.js's nearestBlockAncestor() picks a sane insertion point across
     varied tap-site layouts; width:100% just makes sure the panel fills
     whatever block container it actually lands in. flex-basis:100% is a
     defensive fallback in case a future tap site's container structure
     slips past that logic. */
  width: 100%;
  flex-basis: 100%;
  /* On coaching.html, this panel can land as the last element right
     before #coaching-input-row, a `position: sticky; bottom: 76px`
     footer that visually paints over whatever content ends up in that
     same bottom slice of the viewport — the panel was rendering fully
     "open" but invisible underneath it. scroll-margin-bottom makes
     openRevealPanel()'s scrollIntoView() leave enough room to actually
     clear the sticky bar instead of stopping right behind it. */
  scroll-margin-bottom: 170px;
}

.khandha-reveal-text {
  margin: 0 0 8px;
  color: var(--text);
}

.khandha-reveal-htw-link {
  background: none;
  border: none;
  color: var(--color-vinnana);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-date {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 13px;
  color: var(--text-muted);
}

.card-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.intensity-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #fff;
  letter-spacing: 0.04em;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

.delete-btn:hover { color: #A32D2D; }

.tri-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tri-toggle-option {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.tri-toggle-option.active {
  border-color: var(--color-vinnana);
  color: var(--color-vinnana);
  background: color-mix(in srgb, var(--color-vinnana) 8%, var(--surface));
}

.card-raw-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 10px;
}

.card-view-raw,
.card-view-analysed,
.card-view-expanded {
  opacity: 1;
  transition: opacity 0.18s ease;
}

.card-view-raw.fading-out,
.card-view-analysed.fading-out,
.card-view-expanded.fading-out {
  opacity: 0;
}

.card-meta {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.phase-tag {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.card-insight {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 12px;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.card-practice, .practice-box {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
  border-left: 2px solid var(--color-sankhara);
  padding-left: 10px;
}

.crisis-caveat {
  font-size: 13px;
  line-height: 1.6;
  color: #A32D2D;
  margin-bottom: 12px;
  border-left: 2px solid #A32D2D;
  padding-left: 10px;
}

.crisis-caveat .crisis-link {
  display: inline-block;
  margin-left: 6px;
  color: #A32D2D;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

.off-topic-caveat {
  font-size: 13px;
  line-height: 1.6;
  color: #BA7517;
  margin-bottom: 12px;
  border-left: 2px solid #BA7517;
  padding-left: 10px;
}

.off-topic-caveat::before {
  content: 'ⓘ ';
}

.card-bars { margin-top: 4px; }

.card-expanded-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  border-left: 2px solid var(--color-vinnana);
  padding-left: 10px;
  white-space: pre-wrap;
}

.card-expanded-source-label {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-expanded-source {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
}

/* Metadata row about the generated Details text itself (currently just the
   stale-display-mode notice; a natural home for other per-generation
   metadata later — token usage, generation date, etc. — if that's ever
   added, per user discussion). Deliberately placed after .card-expanded-
   body, not before it: read the content first, see the caveat after,
   rather than leading with a caveat about content not yet seen. */
.card-expanded-footnote {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.card-expanded-footnote svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.card-expanded-stale-badge {
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Per-call token/duration readout, only shown when Settings' debug mode is
   on (see renderCallStats() in app.js). Deliberately plain — no border, no
   background — just a small muted line beside whatever the call generated. */
.call-stats-badge {
  display: block;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
.call-stats-badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  margin-right: 5px;
}
.call-stats-truncated { color: #D85A30; }

.quota-exhausted { color: #BA7517; }

/* ── Utility ── */
.hidden { display: none !important; }
.loading { opacity: 0.55; pointer-events: none; }
.error-msg {
  color: #A32D2D;
  font-size: 13px;
  margin-top: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.expand-quota-retry-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-vinnana);
  text-decoration: none;
}
.expand-quota-retry-link:hover { text-decoration: underline; }
.success-msg {
  color: var(--color-sankhara);
  font-size: 13px;
  margin-top: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ── Wizard ── */
.wizard-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 16px;
}

.wizard-prompt textarea {
  min-height: 140px;
  margin-top: 10px;
}

.wizard-nav-row {
  display: flex;
  gap: 8px;
  margin-top: 26px;
}

.wizard-nav-row .primary { margin-top: 0; flex: 1; }

.wizard-prev-btn {
  padding: 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.wizard-prev-btn:hover { color: var(--text); border-color: var(--text-muted); }

.spinner-row {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--color-vinnana);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Resource directory ── */
.resource-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resource-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.resource-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.resource-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.resource-contact {
  font-size: 12px;
  color: var(--color-vinnana);
  margin-top: 6px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
}

.chart-range-note {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 12px;
}

/* ── Coaching ── */
.card-coaching-link {
  display: block;
  background: none;
  border: none;
  color: var(--color-vinnana);
  cursor: pointer;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.04em;
  padding: 0;
  margin-top: 12px;
  text-decoration: underline;
}

.coaching-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.coaching-bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
}

.coaching-bubble.user {
  align-self: flex-end;
  background: var(--color-vinnana);
  color: #fff;
}

.coaching-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.coaching-bubble.crisis {
  border-left: 3px solid #A32D2D;
}

.coaching-bubble .crisis-link {
  display: inline-block;
  margin-top: 8px;
  color: #A32D2D;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

.coaching-bubble.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.coaching-bubble.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.coaching-bubble.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.coaching-bubble.typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

#coaching-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: sticky;
  bottom: 76px;
  background: var(--bg);
  padding-top: 8px;
}

#coaching-input-row textarea {
  min-height: 48px;
  max-height: 120px;
}

#coaching-input-row .primary {
  width: auto;
  margin-top: 0;
  padding: 12px 18px;
  flex-shrink: 0;
}

#coaching-readonly-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ── Pieces board ── */
.pieces-intro {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pieces-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
}

.pieces-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pieces-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.pieces-row {
  margin-bottom: 20px;
}

.pieces-row-label {
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.pieces-tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pieces-tile {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.pieces-tile svg {
  width: 18px;
  height: 18px;
  opacity: 0;
}

.pieces-tile.new {
  border-style: solid;
  background: color-mix(in srgb, var(--tile-color) 14%, transparent);
  border-color: var(--tile-color);
}

.pieces-tile.new svg { opacity: 0.45; color: var(--tile-color); }

.pieces-tile.returned {
  border-style: solid;
  background: color-mix(in srgb, var(--tile-color) 24%, transparent);
  border-color: var(--tile-color);
}

.pieces-tile.returned svg {
  opacity: 1;
  color: var(--tile-color);
  filter: drop-shadow(0 0 2px var(--tile-color)) drop-shadow(0 0 5px color-mix(in srgb, var(--tile-color) 70%, transparent));
}

.pieces-tile-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--tile-color);
  color: #fff;
  font-size: 9px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.pieces-tile-add {
  border-style: dashed;
}

.pieces-tile-add svg { opacity: 0.6; }

/* ── Compose flow ── */
.compose-context {
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.compose-context .tile-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.piece-nudge-link {
  display: block;
  background: none;
  border: none;
  color: var(--color-vinnana);
  cursor: pointer;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.04em;
  padding: 0;
  margin-top: 10px;
  text-decoration: underline;
}

.translate-offer-row {
  margin-top: 14px;
}

.translate-offer-link {
  display: block;
  background: none;
  border: none;
  color: var(--color-vinnana);
  cursor: pointer;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 0;
  text-decoration: underline;
}

/* ── Piece view (read-only) ── */
.view-lang-label {
  font-size: 10px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.view-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  line-height: 1.7;
  font-size: 15px;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.view-delete-btn {
  display: block;
  background: none;
  border: none;
  color: #A32D2D;
  cursor: pointer;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 0;
  margin-bottom: 20px;
  text-decoration: underline;
}

/* ── Consent gate (known gap #14) ── */
#consent-section {
  padding-top: 8px;
}

#consent-section p {
  line-height: 1.6;
  margin-bottom: 16px;
}

#consent-section a {
  color: var(--color-vinnana);
  text-decoration: none;
}

#consent-section a:hover { text-decoration: underline; }

/* ── Onboarding walkthrough (gap #25.2) ── */
.welcome-panel {
  border: 1.5px solid color-mix(in srgb, var(--color-vinnana) 38%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-vinnana) 5%, var(--surface));
  padding: 20px 18px;
  margin-bottom: 20px;
  text-align: center;
}

.welcome-panel-icon { font-size: 26px; margin-bottom: 10px; }
.welcome-panel h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.welcome-panel p { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; margin: 0 0 16px; }

.welcome-cta {
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-vinnana);
  color: white;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.welcome-skip {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11.5px;
  cursor: pointer;
  padding: 4px;
}

.example-shell {
  border: 1.5px solid color-mix(in srgb, var(--color-vinnana) 38%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-vinnana) 4%, var(--surface));
  padding: 13px 15px 11px;
  margin-bottom: 20px;
  position: relative;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-vinnana) 6%, transparent);
  transition: opacity 0.6s ease, filter 0.6s ease;
}

.example-shell.dimmed { opacity: 0.45; filter: saturate(0.7); pointer-events: none; }

.example-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  cursor: pointer;
  position: absolute;
  top: 11px;
  right: 12px;
  padding: 3px 5px;
}

.example-dismiss:hover { color: var(--text); }

.mock-date, .mock-input {
  width: 100%;
}

.mock-input {
  min-height: 180px;
  resize: none;
}

.mock-phase-toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.mock-phase-toggle button {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
}
.mock-phase-toggle button.active { color: var(--color-vinnana); border-color: var(--color-vinnana); }
.mock-phase-toggle button:disabled.active {
  color: var(--color-vinnana);
  border-color: var(--color-vinnana);
  background: color-mix(in srgb, var(--color-vinnana) 12%, var(--surface));
  opacity: 0.85;
}

.example-shell textarea:disabled,
.example-shell input:disabled,
.mock-phase-toggle button:disabled {
  opacity: 0.7;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border) 35%, var(--surface));
  border-color: var(--border);
  cursor: not-allowed;
}

.example-shell .primary.hidden { display: none; }
.example-shell .primary.trigger-highlight {
  transform: scale(0.97);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--color-vinnana) 30%, transparent);
}

.drag-ghost {
  position: absolute;
  top: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-vinnana);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-vinnana) 25%, transparent);
  transition: left 0.9s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}
.drag-ghost.showing { opacity: 1; }
.intensity-slider-wrap { position: relative; }
.example-shell input[type="range"]:disabled { opacity: 1; cursor: default; }

.result-block {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}
.result-block.revealed { max-height: 2000px; opacity: 1; }

.pop-item {
  opacity: 0;
  transform: scale(0.92) translateY(8px);
}
.pop-item.pop-in {
  animation: walkthrough-pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.wizard-nav-row.pop-in-ready .primary,
.wizard-nav-row.pop-in-ready .wizard-prev-btn,
.new-entry-cta.pop-in-ready {
  opacity: 0;
  transform: scale(0.85) translateY(6px);
}
.pop-in { animation: walkthrough-pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes walkthrough-pop-in { to { opacity: 1; transform: scale(1) translateY(0); } }

.focus-badge {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-vinnana);
  color: white;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--color-vinnana) 35%, transparent);
  transition: top 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease-in-out;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
}
[lang="th"] .focus-badge { font-family: inherit; font-size: 11px; }
.focus-badge.no-slide { transition: opacity 0.4s ease-in-out; }
.focus-badge.showing {
  opacity: 1;
  transition: top 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.75s ease-in-out;
}
.focus-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: white; flex-shrink: 0; }

.ready-gate {
  text-align: center;
  padding: 16px 14px;
  margin-bottom: 20px;
  border: 1.5px solid var(--color-vinnana);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 20px color-mix(in srgb, var(--color-vinnana) 18%, transparent);
}
.ready-gate p { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.ready-gate-actions { display: flex; gap: 8px; }
.ready-btn {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-vinnana);
  color: white;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.replay-btn-inline {
  flex: 0 0 auto;
  width: 90px;
  padding: 11px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
}
[lang="th"] .replay-btn-inline { font-family: inherit; width: 84px; }

@keyframes walkthrough-focus-pulse {
  0%   { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-vinnana) 6%, transparent); }
  50%  { box-shadow: 0 0 0 5px color-mix(in srgb, var(--color-vinnana) 14%, transparent); }
  100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-vinnana) 6%, transparent); }
}
.example-shell.focus-pulse { animation: walkthrough-focus-pulse 1.1s ease-in-out 1; }

@media (prefers-reduced-motion: reduce) {
  .wizard-nav-row.pop-in-ready .primary,
  .wizard-nav-row.pop-in-ready .wizard-prev-btn,
  .new-entry-cta.pop-in-ready { opacity: 1; transform: none; }
  .pop-in { animation: none; }
  .pop-item { opacity: 1; transform: none; }
  .example-shell.focus-pulse { animation: none; }
  .focus-badge { transition: opacity 0.3s ease; }
  .drag-ghost { transition: opacity 0.25s ease; }
}

/* ── Replay-walkthrough link + draft confirm dialog (gap #25.2 follow-up) ── */
.footer-link-row {
  text-align: center;
  margin-top: 18px;
}

.footer-link-row button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11.5px;
  cursor: pointer;
  padding: 6px 4px;
}

.footer-link-row button:hover { color: var(--color-vinnana); }

.confirm-dialog {
  margin-top: 14px;
  border: 1.5px solid var(--color-sanna);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-sanna) 6%, var(--surface));
  padding: 14px 15px;
}

.confirm-dialog p {
  font-size: 12.5px;
  line-height: 1.55;
  margin: 0 0 12px;
  color: var(--text);
}

.confirm-actions { display: flex; gap: 8px; }

.confirm-actions button {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
}

.confirm-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.confirm-proceed {
  background: var(--color-sanna);
  border: none;
  color: white;
}

/* Every control inside the example-shell (Analyse, Save, Edit entry, the
   post-save CTAs) is scripted, non-interactive demo content — none of them
   have real click handlers — so none should ever look/feel clickable,
   not just once the shell visually dims a few seconds after save. The ✕
   dismiss button is the one real, intentional click target throughout. */
#walkthrough-shell * {
  pointer-events: none;
}
#walkthrough-dismiss-btn {
  pointer-events: auto;
}

