/* Guided Meditation Maker - calm, low-contrast surfaces; light and dark. */
:root {
  --bg: #f4f2ee;
  --bg-2: #ebe7e0;
  --card: #fffdf9;
  --ink: #23262e;
  --ink-2: #4d5260;
  --muted: #747988;
  --line: #ddd7cc;
  --accent: #4f6d8f;
  --accent-ink: #ffffff;
  --accent-soft: #e3eaf2;
  --sage: #6d8b74;
  --sage-soft: #e5ede6;
  --warn: #9a6416;
  --warn-soft: #f8ecd8;
  --err: #a33a3a;
  --err-soft: #f6e1e1;
  --ok: #3f7a52;
  --ok-soft: #e1efe5;
  --now: #fff1c9;
  --shadow: 0 1px 2px rgba(30, 30, 40, .05), 0 6px 22px rgba(30, 30, 40, .06);
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ph-arrive: #9db4cc; --ph-breath: #8fb9b0; --ph-body: #b7a6cf; --ph-scan: #c9a98e; --ph-anchor: #9fb48a;
  --ph-imagery: #d3b77c; --ph-release: #a7b8d8; --ph-drift: #7d86b5; --ph-return: #8eb79b;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #13151c;
  --bg-2: #191c25;
  --card: #1c202a;
  --ink: #e6e7ec;
  --ink-2: #b9bdc9;
  --muted: #8b90a0;
  --line: #2d3240;
  --accent: #8fb0d6;
  --accent-ink: #11151c;
  --accent-soft: #22303f;
  --sage: #9cbca3;
  --sage-soft: #213028;
  --warn: #e5b66a;
  --warn-soft: #3a2f1c;
  --err: #ec9a9a;
  --err-soft: #3b2224;
  --ok: #8fcaa0;
  --ok-soft: #1f3327;
  --now: #3a3622;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 26px rgba(0, 0, 0, .25);
  --ph-arrive: #4f6d8f; --ph-breath: #3f7a70; --ph-body: #6c5a8a; --ph-scan: #8a6a50; --ph-anchor: #5c7448;
  --ph-imagery: #8f7640; --ph-release: #56688e; --ph-drift: #3f4775; --ph-return: #477a58;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9em; }
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 34px; height: 34px; color: var(--accent); flex: none; }
.brand h1 { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.tagline { margin: 0; color: var(--muted); font-size: .88rem; }
.session { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-link {
  font-size: .85rem; text-decoration: none; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2); background: var(--bg);
}
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.credits {
  font-size: .85rem; font-variant-numeric: tabular-nums; padding: 6px 10px; border-radius: 999px;
  background: var(--sage-soft); color: var(--ok);
}

/* buttons */
.btn {
  font: inherit; font-size: .95rem; cursor: pointer; border-radius: 10px; padding: 9px 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); color: var(--accent-ink); }
.btn.quiet { background: transparent; }
.btn.small { font-size: .85rem; padding: 6px 12px; }
.btn.big { width: 100%; padding: 13px 18px; font-size: 1.02rem; }
.btn.icon { padding: 6px 10px; font-size: 1rem; line-height: 1; }
.btn:focus-visible, .chip-link:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.example:focus-visible, .history-open:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* layout */
.layout {
  display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px;
  max-width: 1180px; margin: 0 auto; padding: 20px;
  align-items: start;
}
.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.ask { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; }
.sub { margin: -4px 0 4px; color: var(--muted); font-size: .9rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend, .label { font-size: .85rem; font-weight: 600; color: var(--ink-2); margin: 6px 0 6px; display: block; padding: 0; }
select, textarea, input[type="text"] {
  font: inherit; font-size: .95rem; width: 100%; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
textarea { resize: vertical; min-height: 56px; }
select:disabled { opacity: .6; }
.note { font-size: .85rem; color: var(--muted); margin: 4px 0 0; }
.note:empty { display: none; }

/* goal tiles */
.goals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.goal { position: relative; cursor: pointer; display: block; }
.goal input { position: absolute; opacity: 0; pointer-events: none; }
.goal-card {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  transition: border-color .15s, background .15s;
}
.goal-card strong { font-size: .95rem; }
.goal-blurb { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.goal:hover .goal-card { border-color: var(--accent); }
.goal input:checked + .goal-card { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.goal input:focus-visible + .goal-card { outline: 2px solid var(--accent); outline-offset: 2px; }

/* length pills */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills label { cursor: pointer; position: relative; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills span {
  display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); font-size: .9rem; font-variant-numeric: tabular-nums;
}
.pills input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pills input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.actions { margin-top: 8px; }
.meter { font-size: .85rem; color: var(--ink-2); margin: 2px 0 0; min-height: 1.2em; }
.gate {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: .88rem;
}
.gate span { flex: 1 1 180px; }
.gate a.btn { text-decoration: none; }

/* samples */
.examples { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; }
.examples h3 { font-size: .9rem; margin-bottom: 8px; color: var(--ink-2); }
.example-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.example {
  font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-left: 4px solid var(--accent);
}
.example:hover { border-color: var(--accent); }
.example.ex-sleep { border-left-color: var(--ph-drift); }
.example.ex-stress { border-left-color: var(--ph-release); }
.example.ex-focus { border-left-color: var(--ph-anchor); }
.example.ex-bodyscan { border-left-color: var(--ph-scan); }
.ex-label { font-size: .9rem; }
.ex-sub { font-size: .78rem; color: var(--muted); }

/* intro */
.intro h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin-bottom: 10px; }
.how { margin: 0 0 8px; padding-left: 1.2em; color: var(--ink-2); }
.how li { margin: 6px 0; }

/* progress */
.pg-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.pg-clock { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; }
.pg-steps { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pg-steps li { position: relative; padding-left: 26px; color: var(--muted); font-size: .92rem; }
.pg-steps li::before {
  content: ""; position: absolute; left: 4px; top: .35em; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--line);
}
.pg-steps li.done { color: var(--ink-2); }
.pg-steps li.done::before { background: var(--ok); border-color: var(--ok); }
.pg-steps li.now { color: var(--ink); font-weight: 600; }
.pg-steps li.now::before { border-color: var(--accent); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.85); } 50% { transform: scale(1.2); background: var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .pg-steps li.now::before { animation: none; } }

/* result: player */
.result { display: flex; flex-direction: column; gap: 20px; }
.player-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { margin: 0 0 4px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.player h2 { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.dur {
  font-variant-numeric: tabular-nums; font-size: .9rem; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-2); color: var(--ink-2); white-space: nowrap;
}
.partial { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
.timebar { display: flex; gap: 2px; height: 30px; margin: 16px 0; border-radius: 8px; overflow: hidden; }
.tb-seg { min-width: 4px; display: flex; align-items: center; padding: 0 6px; overflow: hidden; background: var(--ph-arrive); }
.tb-label { font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #1d2230; }
:root[data-theme="dark"] .tb-label { color: #eef0f6; }
.tb-arrive { background: var(--ph-arrive); } .tb-breath { background: var(--ph-breath); } .tb-body { background: var(--ph-body); }
.tb-scan { background: var(--ph-scan); } .tb-anchor { background: var(--ph-anchor); } .tb-imagery { background: var(--ph-imagery); }
.tb-release { background: var(--ph-release); } .tb-drift { background: var(--ph-drift); } .tb-return { background: var(--ph-return); }

.sound-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 14px; align-items: end; }
.vol input { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-2); padding: 8px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
#previewBed { margin-top: 6px; }
.natural-box { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--bg-2); }
.natural-box .note { margin: 0 0 8px; }
.dl-row, .play-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.play-row { margin-top: 16px; }
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.audio { width: 100%; margin-top: 12px; }
.now-line {
  margin: 12px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft);
  font-family: var(--serif); font-size: 1.15rem; line-height: 1.5;
}

/* checks */
.checks-head, .script-head, .history-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.badge { font-size: .78rem; padding: 3px 10px; border-radius: 999px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.flag-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.flag { font-size: .9rem; padding: 8px 12px; border-radius: 8px; background: var(--bg-2); border-left: 3px solid var(--muted); }
.flag.warn { background: var(--warn-soft); border-left-color: var(--warn); }

/* script */
.script .phase { margin-top: 18px; }
.phase-h { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--ink-2); margin-bottom: 8px; }
.phase-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ph-arrive); flex: none; }
.phase-breath .phase-dot { background: var(--ph-breath); } .phase-body .phase-dot { background: var(--ph-body); }
.phase-scan .phase-dot { background: var(--ph-scan); } .phase-anchor .phase-dot { background: var(--ph-anchor); }
.phase-imagery .phase-dot { background: var(--ph-imagery); } .phase-release .phase-dot { background: var(--ph-release); }
.phase-drift .phase-dot { background: var(--ph-drift); } .phase-return .phase-dot { background: var(--ph-return); }
.say {
  font-family: var(--serif); font-size: 1.06rem; line-height: 1.65; margin: 0; padding: 6px 10px;
  border-radius: 8px; position: relative; transition: background .3s;
}
.say[data-at]::before {
  content: attr(data-at); position: absolute; right: 100%; top: 9px; margin-right: 2px;
  font: 400 .7rem/1 var(--font); color: var(--muted); font-variant-numeric: tabular-nums;
}
.script { padding-left: 52px; }
.script .script-head { margin-left: -32px; }
.say.now { background: var(--now); }
.pause {
  margin: 4px 0 4px 10px; font-size: .78rem; color: var(--muted); font-style: italic;
  display: inline-block; padding: 1px 10px; border-radius: 999px; border: 1px dashed var(--line);
}

/* again / export */
.again h3 { margin-bottom: 4px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.export { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 20px; }

/* history */
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history-row { display: flex; align-items: center; gap: 8px; }
.history-open {
  flex: 1; min-width: 0; font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.history-open:hover { border-color: var(--accent); }
.history-open strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* footer, toasts */
.foot { max-width: 1180px; margin: 10px auto 40px; padding: 0 20px; font-size: .82rem; color: var(--muted); }
.foot p { margin: 6px 0; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: .9rem; transition: opacity .5s, transform .5s;
}
.toast a { margin-left: 8px; font-weight: 600; }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.warn { border-left: 4px solid var(--warn); }
.toast.err { border-left: 4px solid var(--err); }
.toast.gone { opacity: 0; transform: translateY(8px); }

/* small screens */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .ask { position: static; }
  .col-main { gap: 16px; }
}
@media (max-width: 520px) {
  .topbar { padding: 12px 16px; }
  .tagline { display: none; }
  .card { padding: 16px; }
  .player h2 { font-size: 1.3rem; }
  .player-head { flex-direction: column; }
  .script { padding-left: 16px; }
  .script .script-head { margin-left: 0; }
  .say[data-at]::before { display: none; }
  .add-row { flex-direction: column; }
  .example-list { grid-template-columns: 1fr; }
}
