/*
 * Twee — candlelight in a dark room.
 * Dark-only, iPhone-first. Fonts are the ones iOS ships with (Didot, SF), so the
 * app never makes a request to a third party.
 */

:root {
    --bg: #0c0406;
    --bg-2: #1a080d;
    --bg-3: #240c13;
    --wine: #5c0f24;
    --crimson: #c4163f;
    --rose: #ff5c8a;
    --gold: #e6b980;
    --gold-soft: rgba(230, 185, 128, .35);
    --text: #f6e9e4;
    --muted: #a58a90;
    --line: rgba(246, 233, 228, .09);
    --danger: #ff6b6b;
    --success: #e6b980;

    --serif: "Didot", "Bodoni 72", "Bodoni Moda", "Playfair Display", Georgia, serif;
    --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;

    --radius: 22px;
    --radius-sm: 14px;
    --gutter: 20px;
    --tabbar-h: 64px;
    --ease: cubic-bezier(.22, .8, .24, 1);

    color-scheme: dark;
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--sans);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

/* Warm glow + film grain behind everything */
.ambience {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(120% 60% at 50% -10%, rgba(196, 22, 63, .35), transparent 60%),
        radial-gradient(80% 50% at 110% 100%, rgba(92, 15, 36, .55), transparent 70%),
        radial-gradient(60% 40% at -10% 80%, rgba(230, 185, 128, .08), transparent 70%),
        var(--bg);
}
.ambience::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .07;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--gold); text-decoration: none; }
a:active { opacity: .7; }

/* ---------- Layout ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) calc(var(--gutter) + env(safe-area-inset-right)) 10px calc(var(--gutter) + env(safe-area-inset-left));
    background: linear-gradient(var(--bg) 40%, transparent);
}
.topbar__keys { margin-left: auto; margin-right: 0 !important; }
.brand {
    font: italic 400 22px/1 var(--serif);
    letter-spacing: .04em;
    color: var(--gold);
}
.topbar__logout {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    color: var(--muted);
}

.page {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 4px calc(var(--gutter) + env(safe-area-inset-right)) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 32px) calc(var(--gutter) + env(safe-area-inset-left));
}

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: space-around;
    padding: 6px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: rgba(12, 4, 6, .82);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
    border-top: 1px solid var(--line);
}
.tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: var(--tabbar-h);
    padding-top: 8px;
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    transition: color .3s;
}
.tabbar__item svg { width: 26px; height: 26px; }
.tabbar__item.is-active { color: var(--rose); }
.tabbar__item.is-active svg { filter: drop-shadow(0 0 8px rgba(255, 92, 138, .7)); }

/* ---------- Typography ---------- */

.display {
    margin: 0;
    font: italic 400 clamp(34px, 10vw, 46px)/1.05 var(--serif);
    letter-spacing: -.01em;
    background: linear-gradient(180deg, #fff3ee 0%, #f1c7c0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--gold);
}
.lead { color: var(--muted); margin: 8px 0 28px; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }

.hero { padding: 20px 0 26px; }
.hero--compact { padding: 8px 0 20px; }
.hero--row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero--compact .display { font-size: clamp(30px, 8.5vw, 38px); }

.back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--muted);
    font-size: 15px;
}

.section { margin-top: 32px; }
.section__title {
    margin: 0 0 12px;
    font: italic 400 24px/1.2 var(--serif);
    color: var(--text);
}

/* ---------- Cards, lists ---------- */

.card {
    padding: 22px;
    border-radius: var(--radius);
    background: linear-gradient(160deg, rgba(36, 12, 19, .92), rgba(20, 7, 11, .92));
    border: 1px solid var(--line);
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .03);
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(26, 8, 13, .7);
}
.list__item + .list__item { border-top: 1px solid var(--line); }
.list__link, .list__item--static {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 12px 16px;
    color: var(--text);
}
.list__link > span:first-child, .list__item--static > span:first-child {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.list__text { color: var(--text); }
.list__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    color: var(--muted);
    font-size: 13px;
}
.list__chevron { color: var(--muted); font-size: 22px; }
.list__item.is-inactive { opacity: .45; }
.list__item--surprise .list__text { font: italic 17px/1.3 var(--serif); color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chip {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--gold-soft);
    color: var(--gold);
    font-size: 13px;
    letter-spacing: .02em;
}
.chip--category { background: rgba(230, 185, 128, .12); }

.badge {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid var(--line);
    color: var(--muted);
}
.history-item { flex-direction: column; align-items: stretch; }
.history-item__actions { display: flex; gap: 8px; }
.history-item__actions .badge.is-selected { opacity: 1; background: rgba(246, 233, 228, .06); color: var(--text); }
.history-item__actions .badge--completed.is-selected { color: var(--rose); border-color: rgba(255, 92, 138, .55); background: rgba(196, 22, 63, .18); box-shadow: 0 0 14px -4px rgba(255, 92, 138, .6); }

.reroll { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 8px; margin-top: 14px; }
.reroll__reason { font: italic 16px/1.3 var(--serif); color: var(--muted); }
.reroll .link { color: var(--gold); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(160deg, rgba(92, 15, 36, .45), rgba(26, 8, 13, .9));
    color: var(--text);
}
.tile:first-child { grid-column: 1 / -1; }
.tile__count { font: italic 400 44px/1 var(--serif); color: var(--gold); }
.tile__count small { font-size: 22px; color: var(--muted); }
.tile__label { font-weight: 600; }
.tile__hint { font-size: 12px; color: var(--muted); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: 600 16px/1 var(--sans);
    letter-spacing: .04em;
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .15s var(--ease), box-shadow .3s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn--block { width: 100%; }
.btn--small { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn--primary {
    background: linear-gradient(135deg, var(--rose) -20%, var(--crimson) 45%, var(--wine) 120%);
    box-shadow: 0 10px 30px -8px rgba(196, 22, 63, .75), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn--ghost {
    background: rgba(246, 233, 228, .04);
    border: 1px solid var(--gold-soft);
    color: var(--gold);
}
.btn--danger {
    background: transparent;
    border: 1px solid rgba(255, 107, 107, .35);
    color: var(--danger);
}
.link {
    background: none;
    border: 0;
    padding: 10px 0;
    color: var(--muted);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.icon-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

/* ---------- Forms ---------- */

.stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field legend {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold);
}
input[type="text"], input[type="password"], input[type="date"], input[type="number"], textarea, select {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: rgba(12, 4, 6, .7);
    color: var(--text);
    font: 16px/1.4 var(--sans); /* 16px keeps iOS from zooming in */
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 120px; }
select {
    background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
    background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--rose);
    box-shadow: 0 0 0 3px rgba(255, 92, 138, .18);
}
.datetime { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.datetime input[type="date"] { min-width: 0; padding-left: 12px; padding-right: 8px; }
.time { display: flex; align-items: center; gap: 3px; color: var(--muted); }
.time select { width: 62px; padding: 14px 22px 14px 12px; background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%; font-variant-numeric: tabular-nums; }
.field__help { margin: 0; font-size: 13px; color: var(--muted); }
.field__errors { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: 14px; }
.field--error input, .field--error textarea { border-color: var(--danger); }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    transition: all .2s;
}
.choice input:checked + span {
    border-color: var(--rose);
    color: var(--text);
    background: rgba(196, 22, 63, .25);
    box-shadow: 0 0 18px -4px rgba(255, 92, 138, .6);
}
.choice input:focus-visible + span { outline: 2px solid var(--rose); outline-offset: 2px; }

.range { display: flex; align-items: center; gap: 16px; }
.range__output { min-width: 2ch; font: italic 400 30px/1 var(--serif); color: var(--gold); text-align: right; }
input[type="range"] {
    flex: 1;
    height: 44px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--wine), var(--rose));
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    margin-top: -12px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff 0%, var(--gold) 45%, #a8783f 100%);
    box-shadow: 0 0 16px rgba(230, 185, 128, .6);
}

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--text); }
.switch input { position: absolute; opacity: 0; }
.switch__track {
    position: relative;
    flex-shrink: 0;
    width: 50px;
    height: 30px;
    border-radius: 999px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    transition: background .25s;
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .25s var(--ease), background .25s;
}
.switch input:checked + .switch__track { background: var(--crimson); }
.switch input:checked + .switch__track::after { transform: translateX(20px); background: #fff; }

.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.inline-form .field__errors { grid-column: 1 / -1; }

.flash {
    margin: 0 0 16px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gold-soft);
    background: rgba(230, 185, 128, .08);
    color: var(--gold);
    animation: rise .6s var(--ease) both;
}
.flash--error { border-color: rgba(255, 107, 107, .4); background: rgba(255, 107, 107, .08); color: var(--danger); }

/* ---------- Timers ---------- */

.timers { display: flex; flex-direction: column; gap: 16px; }
.timer {
    position: relative;
    overflow: hidden;
    padding: 22px 22px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(165deg, rgba(40, 12, 20, .95), rgba(16, 5, 8, .95));
    box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .9);
}
.timer--running::before {
    content: "";
    position: absolute;
    inset: -40% -20% auto auto;
    width: 70%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 92, 138, .28), transparent 65%);
    animation: breathe 5s ease-in-out infinite;
    pointer-events: none;
}
.timer__label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--gold);
}
.timer__value {
    position: relative;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0 10px;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.timer__days {
    font: italic 400 clamp(64px, 22vw, 88px)/1 var(--serif);
    background: linear-gradient(180deg, #fff 10%, #ffb3c4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.timer--running .timer__days { filter: drop-shadow(0 0 22px rgba(255, 92, 138, .35)); }
.timer__hours { font: italic 400 38px/1 var(--serif); color: var(--text); }
.timer__unit { font-size: 15px; color: var(--muted); margin-right: 6px; }
.timer__value--idle .timer__days { opacity: .25; filter: none; }
.timer__fine { position: relative; margin: 2px 0 0; font: 14px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: .12em; color: var(--rose); opacity: .8; }
.timer__since { position: relative; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.timer__record {
    position: relative;
    margin: 14px 0 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 15px;
    color: var(--text);
}
.timer__record-label {
    margin-right: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--gold);
}
.timer__record.is-record {
    background: linear-gradient(90deg, var(--gold) 0%, #fff4dc 50%, var(--gold) 100%) 0 0 / 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 3s linear infinite;
}
.timer__record.is-record .timer__record-label { color: inherit; }

.record-card__value { margin: 0; font: italic 400 40px/1.1 var(--serif); color: var(--gold); }
.record-card p { margin-top: 6px; margin-bottom: 0; }

/* ---------- The big button ---------- */

.press {
    display: grid;
    place-items: center;
    padding: 12px 0 8px;
}
.orb {
    position: relative;
    display: grid;
    place-content: center;
    gap: 6px;
    width: min(72vw, 320px);
    aspect-ratio: 1;
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    background:
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .45) 0%, transparent 22%),
        radial-gradient(circle at 50% 55%, var(--rose) 0%, var(--crimson) 40%, var(--wine) 78%, #2a0610 100%);
    box-shadow:
        0 0 0 1px rgba(255, 180, 200, .25),
        0 0 60px 10px rgba(196, 22, 63, .55),
        0 0 140px 30px rgba(196, 22, 63, .25),
        inset 0 -18px 40px rgba(0, 0, 0, .45),
        inset 0 10px 30px rgba(255, 255, 255, .12);
    animation: heartbeat 4s ease-in-out infinite;
    transition: transform .3s var(--ease);
}
.orb__halo {
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 1px solid rgba(230, 185, 128, .4);
    animation: halo 4s ease-out infinite;
    pointer-events: none;
}
.orb__label { font: italic 400 42px/1 var(--serif); letter-spacing: .02em; text-shadow: 0 2px 20px rgba(0, 0, 0, .4); }
.orb__sub { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; opacity: .75; }
.orb:active { transform: scale(.94); }

.press.is-pressed .orb {
    animation: ignite 1.1s var(--ease) forwards;
}
.press.is-pressed .orb__halo { animation: burst 1.1s var(--ease) forwards; }

.orb--small {
    width: 96px;
    margin: 0 auto 28px;
    cursor: default;
}

.hint { margin: 22px 0 0; text-align: center; font: italic 17px/1.4 var(--serif); color: var(--muted); }
.hint strong { font-family: var(--sans); font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--gold); }

/* ---------- Challenge card ---------- */

.challenge {
    position: relative;
    padding: 28px 24px 24px;
    border-radius: 28px;
    border: 1px solid rgba(230, 185, 128, .25);
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(196, 22, 63, .35), transparent 70%),
        linear-gradient(170deg, #2a0b14, #12050a);
    box-shadow: 0 30px 80px -30px rgba(196, 22, 63, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.challenge--reveal { animation: unveil 1.4s var(--ease) both; }
.challenge--reveal .challenge__text { animation: focus-in 1.6s .3s var(--ease) both; }
.challenge__meta { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.challenge__text {
    margin: 22px 0;
    font: italic 400 clamp(26px, 7.4vw, 32px)/1.3 var(--serif);
    color: #fff4f0;
    overflow-wrap: anywhere;
}
.challenge .chips { margin-bottom: 24px; }
.challenge__actions { display: grid; gap: 10px; }
.outcome { text-align: center; }
.outcome__label { margin: 0; font: italic 400 28px/1.2 var(--serif); color: var(--gold); }
.outcome--completed .outcome__label { color: var(--rose); text-shadow: 0 0 24px rgba(255, 92, 138, .6); }

.flames { display: inline-flex; gap: 2px; }
.flame { width: 18px; height: 18px; fill: rgba(246, 233, 228, .15); }
.flame.is-lit { fill: var(--rose); filter: drop-shadow(0 0 4px rgba(255, 92, 138, .7)); }
.list__meta .flame { width: 13px; height: 13px; }

/* ---------- Autocomplete (Tom Select, own theme: no default CSS is loaded) ---------- */

.ts-wrapper { position: relative; width: 100%; }
.ts-hidden-accessible, select.tomselected {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    padding: 0 !important;
}
.ts-control {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 52px;
    padding: 12px 44px 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: rgba(12, 4, 6, .7);
    color: var(--text);
    font: 16px/1.4 var(--sans); /* 16px: no iOS zoom */
    cursor: pointer;
    transition: border-color .2s, box-shadow .3s, background .3s;
}
/* The gold chevron, same as the native selects */
.ts-wrapper.single .ts-control::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 50%;
    width: 7px;
    height: 7px;
    margin-top: -6px;
    border-right: 2px solid var(--gold);
    border-bottom: 2px solid var(--gold);
    transform: rotate(45deg);
    transition: transform .3s var(--ease), margin .3s var(--ease);
}
.ts-wrapper.dropdown-active .ts-control::after { transform: rotate(-135deg); margin-top: -2px; }
.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
    border-color: var(--rose);
    box-shadow: 0 0 0 3px rgba(255, 92, 138, .18), 0 0 30px -8px rgba(196, 22, 63, .8);
    background: rgba(26, 8, 13, .9);
}
.ts-wrapper.invalid .ts-control { border-color: var(--danger); }
.ts-control > input {
    flex: 1 1 60px;
    min-width: 60px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    color: var(--text);
    font: inherit;
    min-height: 0;
}
.ts-control > input::placeholder { color: var(--muted); opacity: 1; }
.ts-control > input:focus { outline: none; }
/* Single select: show the chosen item, swap it for the search input only while typing is possible */
.ts-wrapper.single.has-items:not(.input-active) .ts-control > input,
.ts-wrapper.input-hidden .ts-control > input { position: absolute; left: -10000px; opacity: 0; }
.ts-wrapper.single.input-active.has-items .ts-control:has(> input) > .item { display: none; }
.ts-control > .item { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-wrapper.single .ts-control > .item { color: var(--text); }

/* Multi-select chips, like the challenge chips */
.ts-wrapper.multi .ts-control > .item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--gold-soft);
    background: rgba(230, 185, 128, .1);
    color: var(--gold);
    font-size: 14px;
}
.ts-wrapper .remove {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--gold);
    text-decoration: none;
}

.ts-wrapper .clear-button {
    position: absolute;
    right: 40px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-top: -14px;
    border-radius: 50%;
    color: var(--muted);
    font-size: 18px;
    opacity: 0;
    cursor: pointer;
    transition: opacity .2s;
}
.ts-wrapper.has-items .clear-button { opacity: 1; }
.ts-wrapper.required .clear-button,
.ts-wrapper.ts-no-clear .clear-button { display: none; }

.ts-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(230, 185, 128, .25);
    background: rgba(26, 8, 13, .92);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .95), 0 0 40px -12px rgba(196, 22, 63, .55);
    animation: dropdown-in .22s var(--ease) both;
}
.ts-dropdown-content { max-height: min(50vh, 320px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 6px; }
.ts-dropdown .option,
.ts-dropdown .no-results,
.ts-dropdown .optgroup-header {
    padding: 13px 14px;
    border-radius: 10px;
    color: var(--text);
    font-size: 16px;
    line-height: 1.35;
}
.ts-dropdown .option { cursor: pointer; transition: background .15s, color .15s; }
.ts-dropdown .option + .option { margin-top: 2px; }
.ts-dropdown .option.active {
    background: linear-gradient(90deg, rgba(196, 22, 63, .45), rgba(92, 15, 36, .25));
    color: #fff;
    box-shadow: inset 2px 0 0 var(--rose);
}
.ts-dropdown .option.selected { color: var(--gold); }
.ts-dropdown .option.selected::after { content: " ♥"; color: var(--rose); }
.ts-dropdown .no-results { color: var(--muted); font-family: var(--serif); font-style: italic; }
.ts-dropdown .highlight { background: none; color: var(--rose); font-weight: 600; }
.ts-dropdown [data-selectable].option:empty { display: none; }

/* Compact pill variant for the filter row */
.search__filters .ts-control { min-height: 44px; padding: 8px 34px 8px 14px; border-radius: 999px; font-size: 14px; }
.search__filters .ts-control > input { font-size: 16px; }
.search__filters .ts-wrapper.single .ts-control::after { right: 15px; width: 6px; height: 6px; }
/* "Alle …" is a normal option here, so no clear button is needed */
.search__filters .clear-button { display: none; }
.search__filters .ts-control > .item { font-size: 14px; }
.search__filters .ts-dropdown .option,
.search__filters .ts-dropdown .no-results { padding: 11px 12px; font-size: 15px; }

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
}

/* ---------- Search ---------- */

.search { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search__field { position: relative; display: block; }
.search__field svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search__field input {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px 14px 44px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(12, 4, 6, .7);
    color: var(--text);
    font: 16px/1.4 var(--sans);
    -webkit-appearance: none;
    appearance: none;
}
.search__field input:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px rgba(255, 92, 138, .18); }
.search__filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.search__filters select { min-height: 44px; padding: 10px 30px 10px 14px; border-radius: 999px; font-size: 14px; background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; }
.search-count { margin: 0 0 10px; font-size: 13px; }
turbo-frame { display: block; }
turbo-frame[aria-busy="true"] .list { opacity: .5; transition: opacity .2s; }

/* ---------- Ratings & extras ---------- */

.rating { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.history-item .rating { margin-top: 4px; padding-top: 10px; }
.rating__form { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rating__label { font: italic 17px/1.2 var(--serif); color: var(--muted); }
.rating__hearts { display: inline-flex; }
.heart {
    display: grid;
    place-items: center;
    width: 40px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: rgba(246, 233, 228, .16);
    cursor: pointer;
    touch-action: manipulation;
    transition: color .2s, transform .15s var(--ease), text-shadow .3s;
}
.heart.is-on { color: var(--rose); text-shadow: 0 0 12px rgba(255, 92, 138, .65); }
.heart:active { transform: scale(1.25); }
/* Preview the score under your finger/cursor: light up to the hovered heart. */
@media (hover: hover) {
    .rating__hearts:hover .heart { color: var(--rose); }
    .rating__hearts .heart:hover ~ .heart { color: rgba(246, 233, 228, .16); text-shadow: none; }
}
.history-item .heart { width: 30px; height: 36px; font-size: 19px; }
.history-item .rating__label { font-size: 15px; }
.rating__other { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.rating__other-hearts { color: var(--rose); letter-spacing: 2px; }

.day-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 0 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--gold);
}
.day-heading:first-of-type { margin-top: 0; }
.day-heading__add {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    color: var(--muted);
    font: 400 20px/1 var(--sans);
}
.history-item__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.history-item--extra .icon-btn { flex-shrink: 0; margin-top: -10px; }
.tag {
    display: inline-block;
    margin-right: 4px;
    padding: 1px 7px;
    border-radius: 6px;
    background: rgba(230, 185, 128, .14);
    color: var(--gold);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    vertical-align: 2px;
}
.extras .list { margin-bottom: 4px; }
.extras .hint { margin-top: 14px; }

/* ---------- Agreements ---------- */

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav .display { text-align: center; }
.month-nav .display small { font-size: .5em; color: var(--muted); -webkit-text-fill-color: var(--muted); }
.month-nav__arrow {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--line);
    color: var(--gold);
    font: 400 26px/1 var(--serif);
}
.month-stats { margin: 10px 0 0; text-align: center; font-size: 14px; }

.agreements { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.agreement {
    position: relative;
    padding: 18px 20px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(165deg, rgba(40, 12, 20, .95), rgba(16, 5, 8, .95));
}
.agreement--sealed {
    border-color: rgba(230, 185, 128, .35);
    box-shadow: 0 20px 50px -24px rgba(230, 185, 128, .35), inset 0 1px 0 rgba(255, 244, 220, .05);
}
.agreement--kept { background: radial-gradient(120% 90% at 100% 0%, rgba(196, 22, 63, .28), transparent 60%), linear-gradient(165deg, rgba(40, 12, 20, .95), rgba(16, 5, 8, .95)); }
.agreement--broken .agreement__text { opacity: .55; }
.agreement__head { display: flex; align-items: center; gap: 10px; }
.agreement__number { font: italic 400 28px/1 var(--serif); color: var(--gold); }
.agreement__edit { margin-left: auto; }
.seal {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #2a0b14;
    background: linear-gradient(135deg, #f6dcb0, var(--gold) 50%, #a8783f);
    box-shadow: 0 0 16px -2px rgba(230, 185, 128, .6);
}
.agreement__text { margin: 10px 0 16px; font: italic 400 22px/1.35 var(--serif); color: #fff4f0; overflow-wrap: anywhere; }
.signatures { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.signature {
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px dashed var(--line);
    font-size: 13px;
    color: var(--muted);
}
.signature.is-signed { border-style: solid; border-color: var(--gold-soft); color: var(--gold); font-style: italic; }
.signatures__action { margin-left: auto; }
.signatures__action .link { padding: 6px 0; font-size: 14px; }
.agreement__outcome { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.agreement__outcome .badge,
.history-item__actions .badge {
    min-height: 36px;
    padding: 0 14px;
    background: transparent;
    font: 500 13px/1 var(--sans);
    cursor: pointer;
    touch-action: manipulation;
    opacity: .55;
    transition: all .2s;
}
.agreement__outcome .badge.is-selected { opacity: 1; background: rgba(246, 233, 228, .06); color: var(--text); }
.badge--kept { color: var(--rose); border-color: rgba(255, 92, 138, .4); }
.agreement__outcome .badge--kept.is-selected { color: var(--rose); border-color: rgba(255, 92, 138, .55); background: rgba(196, 22, 63, .18); box-shadow: 0 0 14px -4px rgba(255, 92, 138, .6); }

.empty { text-align: center; }
.empty__text { margin: 0 0 6px; font: italic 400 22px/1.3 var(--serif); }
.empty .muted { margin: 0; }

/* ---------- Login ---------- */

.page-login .page { padding-top: calc(env(safe-area-inset-top) + 12vh); }
.login { text-align: center; }
.login form { text-align: left; }

.btn--passkey { gap: 10px; min-height: 58px; font-size: 17px; }
.btn.is-busy { opacity: .6; }
.login .hint { margin-top: 26px; }

/* ---------- Ownership & counters ---------- */

.owner-tag {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    vertical-align: 1px;
}
.timer--counter .timer__days { font-variant-numeric: tabular-nums; }
.counter__actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 18px; }
.counter__undo { min-width: 64px; }
.counter__undo:disabled { opacity: .35; }
.counter__plus-form .btn { font-size: 22px; letter-spacing: .06em; }
/* The start value only matters for counters */
form:has(input[name="timer[kind]"][value="duration"]:checked) .field--start-value { display: none; }

/* ---------- Motion ---------- */

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    12% { transform: scale(1.035); }
    22% { transform: scale(1); }
    32% { transform: scale(1.025); }
    45% { transform: scale(1); }
}
@keyframes halo {
    0% { transform: scale(.95); opacity: .9; }
    100% { transform: scale(1.25); opacity: 0; }
}
@keyframes ignite {
    0% { transform: scale(1); filter: brightness(1); }
    25% { transform: scale(.9); filter: brightness(1.2); }
    100% { transform: scale(2.4); filter: brightness(2.2) blur(12px); opacity: 0; }
}
@keyframes burst {
    0% { transform: scale(1); opacity: 1; border-width: 1px; }
    100% { transform: scale(3); opacity: 0; border-width: 8px; }
}
@keyframes unveil {
    0% { opacity: 0; transform: translateY(24px) scale(.96); filter: blur(14px) brightness(2); }
    100% { opacity: 1; transform: none; filter: none; }
}
@keyframes focus-in {
    0% { opacity: 0; filter: blur(10px); letter-spacing: .08em; }
    100% { opacity: 1; filter: none; letter-spacing: normal; }
}
@keyframes breathe {
    0%, 100% { opacity: .6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.12); }
}
@keyframes shimmer {
    to { background-position: -200% 0; }
}
@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

@media (min-width: 700px) {
    .timers { display: grid; grid-template-columns: 1fr 1fr; }
}
