:root {
    --paper: #f7f1e7;
    --paper-strong: #fffaf0;
    --ink: #13221d;
    --muted: #64736c;
    --line: #ddd1bf;
    --green: #1f6b4d;
    --green-dark: #114533;
    --berry: #b93d63;
    --teal: #1d7580;
    --gold: #d2932f;
    --danger: #a93434;
    --shadow: 0 10px 30px rgba(28, 38, 31, .10);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body {
    margin: 0;
    min-height: 100%;
}

a {
    color: var(--green);
    font-weight: 750;
    text-decoration: none;
}

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

button {
    cursor: pointer;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fffdf8;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(31, 107, 77, .14);
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 760;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 8vw, 3.8rem);
    line-height: .98;
}

h2 {
    font-size: 1.08rem;
}

h3 {
    font-size: 1rem;
}

p {
    color: var(--muted);
    line-height: 1.45;
}

.app-shell {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 16px 14px 96px;
}

.content-shell {
    display: grid;
    gap: 18px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0 14px;
    background: linear-gradient(180deg, var(--paper) 72%, rgba(247, 241, 231, 0));
}

.logo-lockup,
.topbar-actions,
.action-row,
.split-row,
.quick-actions,
.subsection-heading,
.section-heading {
    display: flex;
    align-items: center;
}

.logo-lockup {
    gap: 9px;
    color: var(--ink);
    font-weight: 900;
}

.topbar-actions {
    gap: 8px;
}

.brand-mark {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 50%;
    background: var(--green-dark);
    color: var(--paper-strong);
    font-weight: 950;
}

.brand-mark.small {
    width: 34px;
    height: 34px;
    font-size: .9rem;
}

.user-chip,
.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 253, 248, .82);
    color: var(--muted);
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 850;
    text-transform: capitalize;
    white-space: nowrap;
}

.pill.green {
    border-color: rgba(31, 107, 77, .35);
    color: var(--green);
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: var(--radius);
    border: 0;
    padding: 10px 14px;
    font-weight: 850;
    line-height: 1;
    white-space: nowrap;
}

.primary-button {
    background: var(--green);
    color: white;
}

.primary-button.berry {
    background: var(--berry);
}

.primary-button.teal {
    background: var(--teal);
}

.secondary-button {
    border: 1px solid var(--line);
    background: var(--paper-strong);
    color: var(--green-dark);
}

.ghost-button,
.icon-button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
}

.ghost-button.danger {
    color: var(--danger);
}

.small {
    min-height: 34px;
    padding: 8px 10px;
    font-size: .8rem;
}

.full {
    width: 100%;
}

.flash {
    margin: 0 0 14px;
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 760;
}

.flash-error {
    background: #ffe9e2;
    color: #78260d;
}

.flash-success {
    background: #e8f5e9;
    color: #195238;
}

.hero-panel {
    display: grid;
    gap: 20px;
    border-radius: var(--radius);
    background:
        radial-gradient(circle at top right, rgba(185, 61, 99, .18), transparent 34%),
        linear-gradient(135deg, #16352a, #1e654c 58%, #b9802e);
    color: var(--paper-strong);
    padding: 24px;
    overflow: hidden;
}

.hero-panel p,
.hero-panel .eyebrow {
    color: rgba(255, 250, 240, .78);
}

.eyebrow {
    margin-bottom: 10px;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.stat-grid,
.metric-grid,
.form-grid,
.card-grid {
    display: grid;
    gap: 12px;
}

.stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-grid div,
.timer-card,
.empty-card,
.form-card,
.bean-card,
.gear-card,
.history-card,
.timeline-card,
.bean-mini-card,
.flavor-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 240, .9);
    box-shadow: var(--shadow);
}

.stat-grid div {
    display: grid;
    gap: 4px;
    padding: 14px;
}

.stat-grid strong {
    color: white;
    font-size: 1.45rem;
}

.stat-grid span {
    color: rgba(255, 250, 240, .7);
    font-size: .76rem;
    font-weight: 800;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.page-section {
    display: grid;
    gap: 12px;
}

.section-heading,
.subsection-heading,
.split-row {
    justify-content: space-between;
    gap: 12px;
}

.section-heading.compact {
    margin-bottom: 6px;
}

.form-card,
.empty-card {
    display: grid;
    gap: 14px;
    padding: 14px;
}

.brew-wizard-form {
    display: grid;
    gap: 14px;
}

.brew-step {
    display: none;
    min-height: calc(100vh - 170px);
}

.brew-step.is-active {
    display: grid;
    align-content: start;
    gap: 14px;
}

.wizard-heading {
    display: grid;
    gap: 10px;
}

.wizard-heading .ghost-button {
    justify-self: start;
    min-height: 34px;
    padding: 6px 0;
}

.wizard-heading h2 {
    font-size: clamp(1.8rem, 8vw, 3.1rem);
    line-height: 1;
}

.wizard-card {
    box-shadow: none;
}

.method-choice-grid {
    display: grid;
    gap: 10px;
}

.method-choice {
    display: grid;
    gap: 8px;
    min-height: 116px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-strong);
    box-shadow: var(--shadow);
    color: var(--ink);
    padding: 16px;
}

.method-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.method-choice strong {
    font-size: 1.22rem;
}

.method-choice span {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.4;
}

.method-choice.is-active {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(31, 107, 77, .14), var(--shadow);
}

.setup-flash-toggle {
    display: none;
}

.setup-flash-toggle.is-visible {
    display: flex;
}

.ratio-card {
    display: grid;
    gap: 6px;
    border: 1px solid rgba(29, 117, 128, .28);
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(29, 117, 128, .14), rgba(210, 147, 47, .16));
    padding: 14px;
}

.ratio-card strong {
    color: var(--green-dark);
    font-size: 1.16rem;
}

.ratio-card span {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 750;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.beans-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.beans-list-section {
    padding-bottom: 76px;
}

.bean-card {
    overflow: hidden;
}

.bean-card img,
.bean-photo-placeholder,
.current-photo img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #d9c4a5;
}

.current-photo {
    display: grid;
    gap: 8px;
}

.current-photo img {
    border-radius: var(--radius);
}

.floating-add-button {
    position: fixed;
    right: 18px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 12;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    border-radius: 999px;
    background: var(--green);
    color: white;
    box-shadow: 0 12px 28px rgba(17, 69, 51, .26);
    padding: 0 18px;
    font-size: .92rem;
    font-weight: 950;
}

.bean-photo-placeholder {
    display: grid;
    place-items: center;
    color: var(--green-dark);
    font-size: 3rem;
    font-weight: 950;
}

.bean-card-body,
.gear-card,
.history-card,
.timeline-card,
.bean-mini-card,
.flavor-card {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.meta-line,
.note-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.meta-line span,
.note-row span {
    border-radius: 999px;
    background: rgba(31, 107, 77, .09);
    color: var(--green-dark);
    padding: 5px 8px;
    font-size: .75rem;
    font-weight: 800;
}

.note-row.large span {
    background: rgba(255, 255, 255, .55);
}

.quiet {
    color: #7b6f61;
    font-size: .88rem;
}

.action-row {
    flex-wrap: wrap;
    gap: 8px;
}

.action-row.compact {
    justify-content: center;
}

.timeline-list {
    display: grid;
    gap: 10px;
}

.timeline-card {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.metric-stack {
    display: grid;
    gap: 5px;
    justify-items: end;
    color: var(--green-dark);
    font-size: .85rem;
    font-weight: 850;
}

.metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-grid span {
    display: grid;
    gap: 3px;
    min-height: 58px;
    border-radius: var(--radius);
    background: #fffdf8;
    color: var(--muted);
    padding: 9px;
    font-size: .7rem;
    font-weight: 800;
}

.metric-grid strong {
    color: var(--ink);
    font-size: .94rem;
}

.rating-badge {
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 50%;
    background: var(--gold);
    color: white;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    border-radius: var(--radius);
    background: #eadfce;
    padding: 5px;
}

.segmented-control label {
    display: block;
    min-height: 42px;
    border-radius: 6px;
    color: var(--muted);
}

.segmented-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented-control span {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 42px;
    place-items: center;
    border-radius: 6px;
    font-size: .8rem;
}

.segmented-control .is-active span {
    background: var(--paper-strong);
    color: var(--green-dark);
    box-shadow: 0 4px 12px rgba(30, 45, 36, .10);
}

.method-section {
    display: none;
    gap: 14px;
}

.method-section.is-active {
    display: grid;
}

.timer-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    text-align: center;
}

.timer-display {
    color: var(--green-dark);
    font-variant-numeric: tabular-nums;
    font-size: 3.2rem;
    font-weight: 950;
    line-height: 1;
}

.timer-marks {
    display: grid;
    gap: 8px;
    text-align: left;
}

.timer-mark-row {
    display: grid;
    grid-template-columns: minmax(74px, .55fr) minmax(104px, .8fr) minmax(150px, 1.35fr) auto;
    gap: 8px;
    align-items: end;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fffdf8;
    padding: 10px;
}

.timer-mark-row input[readonly] {
    background: #efe5d4;
    color: var(--green-dark);
    font-weight: 900;
}

.timer-mark-row.is-start-brew {
    border-color: rgba(29, 117, 128, .38);
    background: linear-gradient(135deg, rgba(29, 117, 128, .10), #fffdf8);
}

.mark-start-title {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    background: rgba(29, 117, 128, .12);
    color: var(--teal);
    padding: 3px 8px;
    font-size: .72rem;
    font-weight: 950;
}

.mark-note-field {
    min-width: 0;
}

.mark-summary-list {
    display: grid;
    gap: 6px;
}

.mark-summary-list span {
    display: block;
    border-left: 3px solid var(--teal);
    background: #fffdf8;
    border-radius: 6px;
    padding: 7px 9px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 760;
}

.mark-summary-list strong {
    color: var(--green-dark);
    margin-right: 6px;
}

.follow-page {
    gap: 14px;
}

.follow-summary,
.follow-timer-card,
.follow-step {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 240, .92);
    box-shadow: var(--shadow);
}

.follow-summary {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.follow-metrics {
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
}

.follow-timer-card {
    position: sticky;
    top: 54px;
    z-index: 7;
    display: grid;
    gap: 12px;
    padding: 14px;
    text-align: center;
}

.follow-current {
    display: grid;
    gap: 4px;
    min-height: 58px;
    border-radius: var(--radius);
    background: #fffdf8;
    padding: 10px;
}

.follow-current strong {
    color: var(--green-dark);
}

.follow-current span {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 740;
}

.follow-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4d8c7;
}

.follow-progress div {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--teal);
    transition: width .2s ease;
}

.follow-step-list {
    display: grid;
    gap: 10px;
}

.follow-step {
    display: grid;
    grid-template-columns: 66px 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px;
    opacity: .74;
}

.follow-step.is-active {
    border-color: var(--green);
    background: #fffdf8;
    box-shadow: 0 0 0 3px rgba(31, 107, 77, .12), var(--shadow);
    opacity: 1;
}

.follow-step.is-complete {
    opacity: .5;
}

.follow-step-time {
    display: grid;
    min-height: 42px;
    place-items: center;
    border-radius: var(--radius);
    background: rgba(29, 117, 128, .12);
    color: var(--teal);
    font-size: .82rem;
    font-weight: 950;
    font-variant-numeric: tabular-nums;
}

.toggle-row {
    display: flex;
    align-items: center;
    flex-direction: row;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fffdf8;
    padding: 10px 12px;
}

.toggle-row input {
    width: 22px;
    min-height: 22px;
}

[data-flash-field] {
    display: none;
}

[data-flash-field].is-visible {
    display: grid;
}

.pour-steps {
    display: grid;
    gap: 10px;
}

.pour-step {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 8px;
    align-items: end;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 253, 248, .72);
    padding: 10px;
}

.flavor-chip-cloud {
    display: grid;
    gap: 12px;
}

.flavor-chip-cloud.compact {
    max-height: 330px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: #fffdf8;
}

.flavor-group {
    display: grid;
    gap: 8px;
}

.flavor-group > div {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.flavor-label {
    color: var(--flavor-color);
    font-size: .78rem;
    font-weight: 900;
}

.flavor-chip {
    min-height: 34px;
    border: 1px solid color-mix(in srgb, var(--flavor-color) 34%, white);
    border-radius: 999px;
    background: color-mix(in srgb, var(--flavor-color) 10%, white);
    color: color-mix(in srgb, var(--flavor-color) 72%, black);
    padding: 7px 10px;
    font-size: .78rem;
    font-weight: 850;
}

.flavor-chip.is-selected {
    background: var(--flavor-color);
    color: white;
}

.flavor-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.flavor-card {
    border-top: 5px solid var(--flavor-color);
    background: color-mix(in srgb, var(--flavor-color) 8%, #fffaf0);
}

.legal-note {
    font-size: .82rem;
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 18px;
    background:
        linear-gradient(150deg, rgba(17, 69, 51, .94), rgba(31, 107, 77, .86)),
        var(--paper);
}

.auth-shell {
    display: grid;
    width: min(100%, 420px);
    gap: 14px;
}

.brand-panel {
    display: grid;
    justify-items: center;
    gap: 10px;
    color: white;
    text-align: center;
}

.brand-panel p {
    color: rgba(255, 250, 240, .78);
}

.auth-card {
    display: grid;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: var(--radius);
    background: var(--paper-strong);
    padding: 16px;
    box-shadow: var(--shadow);
}

.hidden-field {
    position: absolute;
    left: -9999px;
}

.bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
    border-top: 1px solid var(--line);
    background: rgba(255, 250, 240, .96);
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    backdrop-filter: blur(16px);
}

.bottom-nav a {
    display: grid;
    min-width: 0;
    min-height: 46px;
    place-items: center;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: clamp(.62rem, 2.6vw, .78rem);
    font-weight: 900;
}

.bottom-nav a.is-active {
    background: var(--green-dark);
    color: white;
}

@media (min-width: 720px) {
    .app-shell {
        padding-bottom: 26px;
    }

    .hero-panel {
        grid-template-columns: 1.2fr .8fr;
        align-items: end;
    }

    .bottom-nav {
        right: auto;
        bottom: 20px;
        left: 50%;
        width: min(760px, calc(100% - 32px));
        transform: translateX(-50%);
        border: 1px solid var(--line);
        border-radius: 14px;
        box-shadow: var(--shadow);
    }

    .floating-add-button {
        right: max(18px, calc((100vw - 980px) / 2 + 18px));
        bottom: 92px;
    }
}

@media (max-width: 620px) {
    .form-grid.two,
    .metric-grid,
    .timer-mark-row,
    .pour-step {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .topbar-actions .user-chip {
        display: none;
    }

    .timer-display {
        font-size: 2.7rem;
    }
}
