:root {
    --bg: #f4efe8;
    --bg-glow: #fffaf3;
    --card: #fffdf9;
    --ink: #2b211c;
    --muted: #7a6d64;
    --line: rgb(43 33 28 / 0.1);
    --well: rgb(43 33 28 / 0.05);
    --shadow: 0 1px 2px rgb(43 33 28 / 0.06), 0 6px 20px rgb(43 33 28 / 0.08);
    --accent: #8a5a2b;
    --on-accent: #fff;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #15110f;
        --bg-glow: #241c18;
        --card: #211b18;
        --ink: #f2e9e1;
        --muted: #a39588;
        --line: rgb(255 255 255 / 0.09);
        --well: rgb(255 255 255 / 0.05);
        --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
        --accent: #d5a06a;
        --on-accent: #1a120d;
    }
}

/* Each brew has its own accent. */
.r-hot { --accent: #b4532a; }
.r-iced { --accent: #2f6f94; }
.r-moka { --accent: #8a5a2b; }
.r-mocha { --accent: #6e4431; }
@media (prefers-color-scheme: dark) {
    .r-hot { --accent: #ec9063; }
    .r-iced { --accent: #82bddd; }
    .r-moka { --accent: #d5a06a; }
    .r-mocha { --accent: #cf9a7c; }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: radial-gradient(120% 60% at 50% 0%, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
    color: var(--ink);
    font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
        max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

body.has-timer {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

main {
    max-width: 560px;
    margin: 0 auto;
}

h1,
h2 {
    margin: 0;
    letter-spacing: -0.02em;
}

b {
    font-weight: 650;
}

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

.small {
    font-size: 14px;
}

button {
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.link {
    border: 0;
    background: none;
    padding: 6px 0;
    color: var(--accent);
    font-size: 15px;
    font-weight: 550;
    cursor: pointer;
}

.card {
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow), 0 0 0 1px var(--line);
    padding: 16px;
}

.glyph {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    flex: none;
}

.glyph svg {
    width: 30px;
    height: 30px;
}

/* ---------- home ---------- */

.home-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: clamp(16px, 5vh, 48px) 0 clamp(20px, 4vh, 36px);
}

.mark {
    width: 40px;
    height: 40px;
    border-radius: 22.5%;
    box-shadow: 0 0 0 1px var(--line);
}

.home-head h1 {
    font-size: 28px;
}

.brews {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.brew {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px;
    min-height: 168px;
    border-radius: 20px;
    background: var(--card);
    box-shadow: var(--shadow), 0 0 0 1px var(--line);
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 160ms ease;
}

.brew:active {
    transform: scale(0.97);
}

.brew .glyph {
    margin-bottom: auto;
}

.brew-name {
    margin-top: 14px;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brew-note {
    font-size: 14px;
    color: var(--muted);
}

.brew-amts {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.aside-card h2 {
    font-size: 17px;
}

.aside-card p {
    margin: 6px 0 0;
}

.idea {
    margin: 20px 4px 0;
    font-size: 14px;
    text-align: center;
}

/* ---------- recipe ---------- */

.back {
    display: inline-block;
    padding: 6px 0;
    color: var(--accent);
    text-decoration: none;
    font-weight: 550;
}

.recipe-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 10px 0 12px;
}

.recipe-head h1 {
    font-size: 30px;
    line-height: 1.1;
}

.recipe-head p {
    margin: 2px 0 0;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tag {
    padding: 6px 11px;
    border-radius: 99px;
    background: var(--well);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: 14px;
}

.tag b {
    color: var(--accent);
    margin-right: 3px;
}

/* Preset segmented control */
.seg {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 12px;
    border-radius: 14px;
    background: var(--well);
    box-shadow: inset 0 0 0 1px var(--line);
}

.seg button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    border: 0;
    border-radius: 10px;
    background: none;
    font-weight: 600;
    cursor: pointer;
}

.seg small {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.seg button[aria-pressed="true"] {
    background: var(--card);
    box-shadow: var(--shadow), 0 0 0 1px var(--line);
    color: var(--accent);
}

/* Amount rows: label on the left, stepper on the right, a note underneath. */
.row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 12px;
    padding: 8px 0;
}

.row + .row {
    border-top: 1px solid var(--line);
}

.row label {
    font-weight: 600;
}

.row-aside {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--muted);
    text-align: right;
}

.row-aside:empty {
    display: none;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stepper button {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--well);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: 22px;
    line-height: 1;
    color: var(--accent);
    cursor: pointer;
    touch-action: manipulation;
}

.stepper button:active {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.stepper button:disabled {
    opacity: 0.35;
}

.value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    min-width: 108px;
}

.value input {
    width: 3.6ch;
    padding: 2px 0;
    border: 0;
    border-bottom: 1.5px dashed transparent;
    background: none;
    color: var(--ink);
    font-family: inherit;
    font-size: 22px;
    font-weight: 650;
    line-height: 1.2;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.value input:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

.unit {
    font-size: 14px;
    color: var(--muted);
}

.yield {
    margin: 8px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-weight: 600;
    color: var(--accent);
    text-align: right;
}

.amounts .muted.small {
    margin: 4px 0 0;
    text-align: right;
}

h2.sub {
    margin: 18px 0 2px;
    font-size: 13px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.amounts .reset {
    display: block;
    margin: 8px 0 -4px auto;
}

.amounts .reset[hidden] {
    display: none;
}

/* Steps: tap a row to check it off. */
.steps {
    margin-top: 24px;
}

.steps-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 4px 8px;
}

.steps-head h2 {
    font-size: 20px;
}

.steps ol {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: step;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow), 0 0 0 1px var(--line);
}

.steps li {
    counter-increment: step;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    min-height: 56px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.steps li + li {
    border-top: 1px solid var(--line);
}

.check {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.check::before {
    content: counter(step);
}

.step-text {
    flex: 1;
}

.step-text b {
    color: var(--accent);
}

.step-aside {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.steps li.done .check {
    background: var(--accent);
    box-shadow: none;
    color: var(--on-accent);
}

.steps li.done .check::before {
    content: "✓";
}

.steps li.done .step-text {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.steps li.done .step-text b {
    color: inherit;
}

.after {
    margin: 12px 4px 0;
    font-size: 14px;
}

/* Timer button inside a step */
.timer {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 84px;
    height: 40px;
    padding: 0 12px;
    justify-content: center;
    border: 0;
    border-radius: 99px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    touch-action: manipulation;
}

.t-icon {
    font-size: 11px;
}

.timer.is-running {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}

.timer.is-paused .t-clock {
    opacity: 0.6;
}

.timer.is-done {
    background: var(--well);
    color: var(--muted);
}

/* Sticky timer bar */
.timer-bar {
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: 536px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 16px;
    border-radius: 20px;
    background: var(--ink);
    color: var(--bg);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
}

.timer-bar[hidden] {
    display: none;
}

.tb-label {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.tb-recipe {
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.65;
}

.tb-step {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.tb-clock {
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.tb-btn {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgb(128 128 128 / 0.25);
    color: inherit;
    font-size: 14px;
    cursor: pointer;
}

.timer-bar.is-done {
    background: var(--accent);
    color: var(--on-accent);
    animation: pulse 1.2s ease-in-out 4;
}

@keyframes pulse {
    50% {
        transform: scale(1.03);
    }
}

@media (prefers-reduced-motion: reduce) {
    .brew,
    .timer-bar.is-done {
        transition: none;
        animation: none;
    }
}

@media (max-width: 360px) {
    .brews {
        gap: 10px;
    }
    .value {
        min-width: 92px;
    }
    .stepper button {
        width: 40px;
    }
}
