/* NightMantra app — built on tokens.css. Dark only. */

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

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body.sheet-open { overflow: hidden; }

[hidden] { display: none !important; }

a { color: var(--accent); }
a:hover { color: #B9C0EC; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.text-muted { color: var(--text-muted); }

/* ---------- layout ---------- */

.app {
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: env(safe-area-inset-bottom);
}

.app-header,
.view-header {
    display: flex;
    align-items: center;
    padding: calc(12px + env(safe-area-inset-top)) var(--space-4) var(--space-1);
}

.app-header { justify-content: space-between; }
.view-header { gap: var(--space-1); padding-left: var(--space-2); }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-height: var(--tap-min);
}

.brand-mark { height: 22px; width: auto; display: block; }
.brand-word { height: 21px; width: auto; display: block; }

.screen-title,
.view-title,
.display-title,
.group-title,
.promo-title,
.premium-title {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

.screen-title { font-size: 26px; }
.view-title { font-size: 22px; }
.display-title { font-size: var(--text-2xl); line-height: 1.15; font-size: 32px; }
.group-title { font-size: 18px; margin: 0 var(--space-1); }

.library,
.account {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-4) var(--space-6);
}

.account { gap: 28px; }

/* ---------- buttons ---------- */

.btn {
    min-height: 52px;
    padding: 0 22px;
    border: none;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: #A9B1E6; }

.btn-premium { background: var(--premium); color: var(--on-premium); }
.btn-premium:hover:not(:disabled) { background: #F6E2B9; }

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(241, 233, 210, 0.22);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    min-height: var(--tap-min);
}

.btn-locked {
    background: rgba(243, 217, 164, 0.1);
    color: var(--premium);
    border: 1px solid rgba(243, 217, 164, 0.35);
}

.btn-recording {
    background: var(--danger);
    color: var(--on-accent);
}

.btn-icon {
    width: 52px;
    height: 52px;
    flex: none;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(241, 233, 210, 0.18);
    background: transparent;
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.btn-icon:hover:not(:disabled) { background: rgba(241, 233, 210, 0.06); }
.btn-icon:disabled { opacity: 0.4; cursor: default; }
.btn-icon svg { display: block; }

.btn-icon-plain {
    width: var(--tap-min);
    height: var(--tap-min);
    border: none;
}

.btn-icon-plain:hover:not(:disabled) { background: transparent; opacity: 0.85; }

.badge-premium {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--premium);
    background: rgba(243, 217, 164, 0.12);
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

/* ---------- library ---------- */

.list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
}

.counter { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }

.cards { display: flex; flex-direction: column; gap: var(--space-3); }

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.affirmation { display: flex; flex-direction: column; gap: var(--space-4); }
.affirmation.is-recording { box-shadow: 0 0 0 2px var(--danger) inset; }

.affirmation-text {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.affirmation-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.affirmation-meta svg { color: var(--accent); }

.affirmation-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.affirmation-actions .btn { flex: 1; }

.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.add-button {
    min-height: 56px;
    border-radius: 16px;
    border: 1.5px dashed rgba(241, 233, 210, 0.22);
    background: transparent;
    color: rgba(241, 233, 210, 0.78);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    flex-wrap: wrap;
}

.add-button:hover { border-color: rgba(241, 233, 210, 0.35); color: var(--text); }

/* composer (new / edit / first affirmation) */
.composer { display: flex; flex-direction: column; gap: var(--space-3); }

.composer-label { font-size: var(--text-sm); font-weight: 500; color: rgba(241, 233, 210, 0.82); }

.composer textarea {
    width: 100%;
    resize: vertical;
    min-height: 96px;
    border-radius: 14px;
    border: 1px solid rgba(241, 233, 210, 0.16);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-md);
    line-height: 1.45;
    padding: 14px;
}

.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:focus { outline: none; border-color: var(--accent); }

.composer-actions { display: flex; flex-direction: column; gap: var(--space-1); }

/* Premium promo */
.promo {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-5);
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(243, 217, 164, 0.16), rgba(243, 217, 164, 0.04) 55%, transparent 80%),
        var(--surface);
}

.promo-title { font-size: 19px; color: var(--premium); }
.promo-text { margin: 0; font-size: var(--text-sm); color: rgba(241, 233, 210, 0.82); }

.promo-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.promo-price { font-size: 14px; color: var(--text-muted); }
.promo-price strong { color: var(--text); font-weight: 600; }
.promo .btn { min-height: var(--tap-min); padding: 0 18px; font-size: 15px; }

/* first visit */
.first-visit { display: flex; flex-direction: column; gap: var(--space-5); padding-top: var(--space-3); }
.first-visit-intro { display: flex; flex-direction: column; gap: 10px; }
.lead { margin: 0; font-size: 16px; line-height: 1.55; color: rgba(241, 233, 210, 0.75); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }

.step { display: flex; align-items: center; gap: 14px; font-size: var(--text-sm); }
.step strong { font-weight: 600; }

.step-icon {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent);
    display: grid;
    place-items: center;
}

.step-icon.is-warm { color: var(--premium); }

/* ---------- account view ---------- */

#accountSection { display: flex; flex-direction: column; gap: 20px; }

.premium-card {
    border-radius: 24px;
    padding: 22px 18px;
    background:
        radial-gradient(120% 90% at 100% 0%, rgba(243, 217, 164, 0.18), rgba(243, 217, 164, 0.04) 55%, transparent 80%),
        var(--surface);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.premium-card p { margin: 0; }

.premium-title {
    font-size: 22px;
    color: var(--premium);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.premium-sub { margin-top: 6px !important; font-size: var(--text-sm); }

.premium-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: var(--text-sm);
}

.premium-features li { display: flex; gap: 10px; align-items: flex-start; }
.premium-features svg { flex: none; color: var(--premium); }

.plan-form { display: flex; flex-direction: column; gap: var(--space-3); }

.plans {
    border: none;
    margin: 0 0 var(--space-1);
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.plan {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(241, 233, 210, 0.18);
    cursor: pointer;
}

.plan:has(input:checked) {
    border: 2px solid var(--premium);
    background: rgba(243, 217, 164, 0.08);
    padding: 13px 15px;
}

.plan input { accent-color: var(--premium); width: 20px; height: 20px; margin: 0; flex: none; }
.plan-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.plan-name { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: 16px; }
.plan-price { font-size: var(--text-xs); color: var(--text-muted); }

.plan-save {
    font-size: 12px;
    font-weight: 600;
    color: var(--on-premium);
    background: var(--premium);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

.fine-print { text-align: center; font-size: var(--text-xs); color: var(--text-muted); margin: 0; }

.center-note { margin: -8px 0 0; text-align: center; font-size: var(--text-sm); color: rgba(241, 233, 210, 0.75); }
.center-note a { font-weight: 600; }

.ended-note { margin: 0; color: rgba(241, 233, 210, 0.82); }

.signed-in {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    font-size: 14px;
    margin-top: -4px;
    padding: 0 var(--space-1);
}

.signed-in strong { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }

.settings-group { display: flex; flex-direction: column; gap: 10px; }

.settings-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 6px;
}

.settings-row {
    width: 100%;
    min-height: 56px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px;
    text-align: left;
    cursor: pointer;
}

.settings-row:hover { background: rgba(241, 233, 210, 0.05); }
.settings-row > svg { color: var(--accent); flex: none; }
.settings-row.is-busy { opacity: 0.6; }
.settings-row.is-danger, .settings-row.is-danger > svg { color: var(--danger); }
.cloud-status-row { cursor: default; }
.cloud-status-row:hover { background: none; }
#cloudStatus { font-size: var(--text-sm); color: var(--text-muted, inherit); }
#cloudStatus[data-status="error"], #cloudStatus[data-status="paused"] { color: var(--warning, var(--accent)); }
.row-label { flex: 1; }
.row-hint { font-size: var(--text-xs); color: var(--text-faint); }

.settings-separator { height: 1px; background: rgba(241, 233, 210, 0.1); margin: 0 12px; }

.settings-note { margin: 0 var(--space-1); font-size: var(--text-xs); line-height: 1.5; color: var(--text-faint); }

.settings-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 6px 6px 6px 18px;
    font-size: 16px;
    font-weight: 500;
}

.settings-select select {
    min-height: var(--tap-min);
    border-radius: var(--radius-md);
    border: 1px solid rgba(241, 233, 210, 0.16);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: 500;
    padding: 0 12px;
}

.legal {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 14px;
    padding-top: var(--space-1);
}

/* Business details (required by Dutch law for online sellers) */
.business { margin: 0; text-align: center; font-style: normal; font-size: 12px; line-height: 1.7; color: var(--text-faint); }
.business a { color: inherit; }

/* ---------- bottom sheet (sheet.js) ---------- */

.sheet-layer { position: fixed; inset: 0; z-index: 2000; }

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 6, 15, 0.62);
    animation: sheet-fade 0.18s ease-out;
}

.sheet {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(100%, 480px);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface);
    color: var(--text);
    border-radius: 24px 24px 0 0;
    padding: 10px var(--space-4) calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    animation: sheet-in 0.2s ease-out;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: var(--radius-pill);
    background: rgba(241, 233, 210, 0.25);
    align-self: center;
    margin-bottom: var(--space-2);
}

.sheet-title {
    margin: 0 var(--space-1);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 20px;
}

.sheet-message {
    margin: 0 var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-muted);
    white-space: pre-line;
}

.sheet.is-menu .sheet-message { font-size: 14px; }

.sheet-items { display: flex; flex-direction: column; }

.sheet-item {
    min-height: 56px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px;
    text-align: left;
    cursor: pointer;
}

.sheet-item:hover { background: rgba(241, 233, 210, 0.05); }
.sheet-item svg { color: var(--accent); flex: none; }
.sheet-item.is-danger, .sheet-item.is-danger svg { color: var(--danger); }

.sheet-separator { height: 1px; background: rgba(241, 233, 210, 0.1); margin: 6px 12px; }

.sheet-actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }

.sheet-action {
    min-height: 52px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(241, 233, 210, 0.18);
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.sheet-action.is-primary { border: none; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.sheet-action.is-primary.is-danger { background: var(--danger); }
.sheet-action.is-primary.is-premium { background: var(--premium); color: var(--on-premium); }

@keyframes sheet-in { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .sheet, .sheet-backdrop, .rec-dot { animation: none; }
}

/* ---------- install to home screen ---------- */
.install-card { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 18px 44px 18px 18px; }
.install-card-icon img { display: block; border-radius: 11px; box-shadow: 0 0 0 1px var(--border); }
.install-card-body { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.install-card-title { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 600; line-height: 1.3; }
.install-card-text { margin: 0; font-size: var(--text-sm); line-height: 1.45; color: rgba(241, 233, 210, 0.8); }
.install-card-add { min-height: 44px; padding: 0 22px; font-size: 15px; margin-top: 6px; }
.install-card-close {
    position: absolute; top: 6px; right: 6px; width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: 50%; color: var(--text-muted); cursor: pointer;
}
.install-card-close:hover { color: var(--text); }
.first-visit .install-card { margin-bottom: 4px; }

.sheet-body { margin: 4px 0 8px; }
.install-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; counter-reset: step; }
.install-steps li { display: flex; align-items: center; gap: 14px; font-size: var(--text-sm); line-height: 1.45; }
.install-step-icon {
    flex: none; width: 40px; height: 40px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-raised); color: var(--accent);
}
.install-note { margin: 16px 0 0; padding: 12px 14px; border-radius: 14px; background: rgba(243, 217, 164, 0.1); color: var(--premium); font-size: 14px; line-height: 1.45; }

/* ---------- limits: character counter, recording clock, local-only label ---------- */
.char-counter { align-self: flex-end; margin-top: -4px; font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-counter.is-full { color: var(--premium); }
.rec-timer { font-variant-numeric: tabular-nums; color: var(--text); margin-left: 4px; }
.local-only { color: var(--premium); }
