@font-face {
    font-family: "Libre Baskerville";
    src: url("/assets/libre-baskerville-regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Libre Baskerville";
    src: url("/assets/libre-baskerville-bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root {
    color-scheme: light;
    --primary: #587548;
    --primary-strong: #466038;
    --primary-soft: #b7c4a8;
    --background: #e7dfd1;
    --surface: #f7f3ec;
    --surface-raised: #fbf8f3;
    --surface-muted: #efeadf;
    --text: #2d2f33;
    --text-muted: #62655f;
    --line: #d8d1c4;
    --on-primary: #fff;
    --shadow: 0 18px 48px rgba(75, 67, 50, 0.08);
    --font-display: "Libre Baskerville", Georgia, serif;
    --font-body: Avenir, "Avenir Next", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --primary: #7fa36b;
    --primary-strong: #9dbc8b;
    --primary-soft: #617655;
    --background: #1d1f1c;
    --surface: #272a26;
    --surface-raised: #2d302c;
    --surface-muted: #32352f;
    --text: #f0ece3;
    --text-muted: #bcbdb6;
    --line: #42463f;
    --on-primary: #1d1f1c;
    --shadow: 0 22px 56px rgba(0, 0, 0, 0.22);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--background);
    scrollbar-color: var(--primary-soft) var(--background);
    scrollbar-width: thin;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    transition: background-color 240ms ease, color 240ms ease;
}

body.dialog-open {
    overflow: hidden;
}

body::selection,
::selection {
    background: var(--primary);
    color: var(--on-primary);
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

a {
    color: inherit;
    text-underline-offset: 0.2em;
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 72%, white);
    outline-offset: 3px;
}

.site-main {
    min-height: 100svh;
}

.site-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    padding: 32px clamp(24px, 5vw, 72px) 40px;
    border-top: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 0.84rem;
}

.site-footer > :last-child {
    justify-self: end;
}

.build-version {
    justify-self: center;
    font-variant-numeric: tabular-nums;
}

.brand-mark {
    display: inline-flex;
    width: max-content;
    align-items: center;
    line-height: 0;
    text-decoration: none;
}

.logo-pair {
    display: block;
    width: 112px;
}

.logo-pair img {
    display: block;
    width: 100%;
    height: auto;
}

.logo-dark {
    display: none !important;
}

:root[data-theme="dark"] .logo-light {
    display: none;
}

:root[data-theme="dark"] .logo-dark {
    display: block !important;
}

.app-frame {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    min-height: 100svh;
    background: var(--surface);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100svh;
    padding: 38px 28px 28px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, var(--background));
    z-index: 30;
}

.sidebar .brand-mark {
    margin: 0 10px 40px;
}

.main-nav,
.account-nav {
    display: grid;
    gap: 8px;
}

.main-nav a,
.account-nav a,
.main-nav .nav-disabled,
.account-nav .nav-disabled {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--text);
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.main-nav a:hover,
.account-nav a:hover {
    background: var(--surface-muted);
    transform: translateX(2px);
}

.main-nav a.active {
    background: var(--primary);
    color: var(--on-primary);
}

.main-nav .nav-disabled,
.account-nav .nav-disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.55;
}

.main-nav svg,
.account-nav svg,
.icon-button svg,
.mobile-menu svg,
.theme-toggle svg,
.section-toggle svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.65;
}

.sidebar-spacer {
    flex: 1;
    min-height: 40px;
}

.account-nav {
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.sidebar-motto {
    margin: 28px 10px 0;
    color: var(--primary);
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.7;
    z-index: 1;
}

.sidebar-botanical {
    position: absolute;
    top: 49%;
    left: -20px;
    width: 82px;
    height: 178px;
    object-fit: cover;
    object-position: 42% 100%;
    opacity: 0.24;
    pointer-events: none;
    mix-blend-mode: multiply;
}

:root[data-theme="dark"] .sidebar-botanical {
    opacity: 0.18;
    mix-blend-mode: screen;
}

.dashboard-surface {
    min-width: 0;
    background: var(--surface);
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 40px;
    padding: 54px clamp(32px, 6vw, 90px) 28px;
}

.dashboard-header p {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.83rem;
    font-weight: 600;
}

.dashboard-header h1 {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4.7rem);
    font-weight: 500;
    letter-spacing: -0.04em;
    line-height: 1;
}

.dashboard-header span:not(.avatar) {
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.icon-button,
.mobile-menu {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.icon-button:hover,
.mobile-menu:hover {
    background: var(--surface-muted);
}

.avatar {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
    color: var(--primary-strong);
    font-family: var(--font-display);
    font-size: 1.15rem;
}

.mobile-menu {
    display: none;
}

.dashboard-content {
    width: min(100%, 1000px);
    padding: 18px clamp(32px, 6vw, 90px) 80px;
}

.habit-section {
    padding-top: 12px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 14px;
}

.section-heading h2,
.week-card h2 {
    margin: 0;
    color: var(--primary);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
}

.section-heading > span {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.habit-list {
    display: grid;
}

.empty-state {
    max-width: 470px;
    padding: 48px 0 34px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 22px;
    fill: none;
    stroke: var(--primary);
    stroke-linecap: round;
    stroke-width: 1.35;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 400;
}

.empty-state p {
    max-width: 42ch;
    margin: 0;
    color: var(--text-muted);
}

.habit-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 20px;
    min-height: 88px;
    border-bottom: 1px solid transparent;
}

.habit-item:hover {
    border-color: var(--line);
}

.habit-check {
    display: grid;
    width: 29px;
    height: 29px;
    place-items: center;
    padding: 0;
    border: 1.5px solid color-mix(in srgb, var(--primary) 70%, var(--line));
    border-radius: 50%;
    background: transparent;
    color: var(--on-primary);
    cursor: pointer;
    position: relative;
    overflow: visible;
    isolation: isolate;
    transition: none;
}

.habit-check:hover {
    border-color: var(--primary);
}

.habit-check svg,
.habit-open svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.habit-item.completed .habit-check {
    border-color: var(--primary);
    background: var(--primary);
}

.habit-item.completed h3 {
    color: var(--text-muted);
}

.habit-item h3 {
    margin: 0 0 2px;
    font-family: var(--font-display);
    font-size: 1.38rem;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.habit-item > div {
    min-width: 0;
}

.habit-item p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.habit-item p span {
    padding: 0 4px;
}

.habit-open {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--surface-muted);
    color: var(--primary);
    font-size: 1.35rem;
    cursor: not-allowed;
    transition: background-color 180ms ease, transform 180ms ease;
}

.habit-open:disabled {
    color: color-mix(in srgb, var(--primary) 72%, var(--text-muted));
    opacity: 0.72;
}

.quick-add {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px auto 12px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-family: var(--font-display);
    font-weight: 700;
    cursor: pointer;
}

.quick-add svg,
.primary-action svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.later {
    margin-top: 16px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.section-empty {
    margin: 0;
    padding: 20px 0 28px 54px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.section-toggle {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.section-toggle svg {
    transition: transform 180ms ease;
}

.section-toggle[aria-expanded="false"] svg {
    transform: rotate(-90deg);
}

.week-card {
    margin-top: 50px;
    padding: 28px 30px;
    border-radius: 16px;
    background: var(--surface-muted);
    box-shadow: var(--shadow);
}

.week-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.week-empty h2 {
    margin-bottom: 8px;
}

.newly-added {
    animation: habit-arrive 420ms cubic-bezier(.16,1,.3,1) both;
}

.habit-dialog {
    width: min(620px, calc(100% - 32px));
    max-height: min(760px, calc(100svh - 32px));
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: var(--surface-raised);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(35, 31, 25, 0.2);
    overflow: hidden;
}

.habit-dialog::backdrop {
    background: rgba(29, 31, 28, 0.55);
}

.habit-dialog[open] {
    animation: dialog-arrive 260ms cubic-bezier(.16,1,.3,1) both;
}

.dialog-shell {
    display: flex;
    height: min(680px, calc(100svh - 32px));
    max-height: min(760px, calc(100svh - 32px));
    flex-direction: column;
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 28px 32px 18px;
}

.dialog-header h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.38rem;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.dialog-close {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.dialog-close:hover {
    background: var(--surface-muted);
}

.dialog-close svg,
.details-toggle svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.wizard-progress {
    padding: 0 32px;
}

.wizard-progress span {
    display: block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
}

.wizard-progress > div {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.wizard-progress i {
    height: 3px;
    border-radius: 9px;
    background: var(--line);
    transition: background-color 180ms ease;
}

.wizard-progress i.active {
    background: var(--primary);
}

.habit-wizard {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.wizard-step {
    min-height: 0;
    flex: 1;
    padding: 30px 32px 34px;
    overflow-y: auto;
}

.step-intro {
    margin-bottom: 28px;
}

.step-intro h3 {
    max-width: 20ch;
    margin: 0 0 7px;
    font-family: var(--font-display);
    font-size: clamp(1.65rem, 4vw, 2.15rem);
    font-weight: 400;
    letter-spacing: -0.03em;
    line-height: 1.22;
}

.step-intro p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.83rem;
}

.field-label {
    display: flex;
    justify-content: space-between;
    margin: 0 0 7px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.field-label span {
    font-weight: 400;
}

.optional-label {
    margin-top: 22px;
}

.text-input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    caret-color: var(--primary);
    resize: vertical;
}

.title-input {
    padding: 14px 15px;
    font-family: var(--font-display);
    font-size: 1rem;
}

.text-input::placeholder,
.frequency-sentence input::placeholder {
    color: color-mix(in srgb, var(--text-muted) 78%, transparent);
}

.text-input[aria-invalid="true"],
.frequency-sentence input[aria-invalid="true"] {
    border-color: var(--primary-strong);
}

.field-error {
    margin: 7px 0 0;
    color: var(--primary-strong);
    font-size: 0.8rem;
    font-weight: 700;
}

.frequency-sentence {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 22px;
    border-radius: 14px;
    background: var(--surface-muted);
    font-family: var(--font-display);
    font-size: 1.38rem;
    white-space: nowrap;
}

.frequency-sentence input,
.frequency-sentence select {
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-raised);
    color: var(--text);
}

.frequency-sentence input {
    width: 82px;
    padding: 0 12px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.frequency-sentence select {
    min-width: 140px;
    padding: 0 36px 0 13px;
    cursor: pointer;
}

.frequency-details {
    margin-top: 18px;
}

.details-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.details-toggle svg {
    transition: transform 180ms ease;
}

.details-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.weekday-panel {
    padding-top: 14px;
}

.weekday-panel > p {
    margin: 0 0 2px;
    font-weight: 700;
}

.weekday-panel > span {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.weekday-options {
    display: flex;
    gap: 7px;
    margin-top: 15px;
}

.weekday-options label,
.cue-types label {
    cursor: pointer;
}

.weekday-options input,
.cue-types input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.weekday-options span {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.weekday-options input:checked + span,
.cue-types input:checked + span {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--on-primary);
}

.weekday-options input:focus-visible + span,
.cue-types input:focus-visible + span {
    outline: 3px solid color-mix(in srgb, var(--primary) 72%, white);
    outline-offset: 3px;
}

.cue-types {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: 0;
    padding: 0;
    border: 0;
}

.cue-types legend {
    width: 100%;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.cue-types span {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 600;
}

.cue-types label:hover span,
.weekday-options label:hover span {
    border-color: color-mix(in srgb, var(--primary) 60%, var(--line));
    color: var(--text);
}

.cue-detail {
    margin-top: 24px;
}

.wizard-actions {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 18px 32px 24px;
    border-top: 1px solid var(--line);
}

.form-error {
    grid-column: 1 / -1;
    margin: 0 0 4px;
    color: var(--primary-strong);
    font-size: 0.8rem;
    font-weight: 700;
}

.button-primary,
.button-quiet,
.button-skip {
    min-height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.button-primary {
    min-width: 116px;
    background: var(--primary);
    color: var(--on-primary);
    font-family: var(--font-display);
    font-weight: 700;
}

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

.button-quiet,
.button-skip {
    background: transparent;
    color: var(--text-muted);
}

.button-quiet:hover,
.button-skip:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.skip-short {
    display: none;
}

@keyframes dialog-arrive {
    from { opacity: 0; filter: blur(5px); transform: translateY(12px) scale(0.985); }
    to { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}

@keyframes habit-arrive {
    from { opacity: 0; filter: blur(6px); transform: translateY(10px); }
    to { opacity: 1; filter: blur(0); transform: translateY(0); }
}

.error-shell {
    position: relative;
    display: flex;
    min-height: 100svh;
    flex-direction: column;
    padding: clamp(28px, 5vw, 70px);
    overflow: hidden;
    background: var(--surface);
}

.error-shell > div {
    position: relative;
    width: min(680px, 100%);
    margin: auto;
    padding: 60px 0 90px;
    z-index: 2;
}

.error-shell > div > p:first-child {
    margin: 0 0 18px;
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 700;
}

.error-shell h1 {
    max-width: 620px;
    margin: 0 0 24px;
    font-family: var(--font-display);
    font-size: clamp(3.2rem, 9vw, 6rem);
    font-weight: 500;
    letter-spacing: -0.04em;
    line-height: 0.95;
}

.error-shell h1 + p {
    max-width: 55ch;
    margin: 0 0 32px;
    color: var(--text-muted);
    font-size: clamp(1rem, 2vw, 1.16rem);
}

.primary-action {
    display: inline-flex;
    align-items: center;
    gap: 28px;
    min-height: 50px;
    padding: 0 20px;
    border-radius: 10px;
    background: var(--primary);
    color: var(--on-primary);
    font-family: var(--font-display);
    font-weight: 700;
    text-decoration: none;
    transition: background-color 180ms ease, transform 180ms ease;
}

.primary-action:hover {
    background: var(--primary-strong);
    transform: translateY(-2px);
}

.notice {
    max-width: 55ch;
    margin: -12px 0 28px;
    padding: 13px 16px;
    border-radius: 10px;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 0.88rem;
}

.coming-shell {
    display: grid;
    min-height: 100svh;
    place-items: center;
    padding: clamp(28px, 5vw, 70px);
    background: var(--surface);
}

.coming-brand {
    display: grid;
    justify-items: center;
    gap: clamp(22px, 3vw, 34px);
    text-align: center;
}

.coming-brand .logo-pair {
    width: clamp(230px, 32vw, 440px);
}

.coming-brand p {
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(0.82rem, 1.4vw, 1rem);
    font-weight: 600;
    letter-spacing: 0.24em;
    line-height: 1;
    text-transform: uppercase;
}

.error-shell > div > p:first-child {
    font-size: 1.4rem;
}

.menu-backdrop {
    display: none;
}

@media (max-width: 880px) {
    .app-frame {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        width: min(300px, 86vw);
        transform: translateX(-102%);
        transition: transform 260ms cubic-bezier(.16,1,.3,1), box-shadow 260ms ease;
    }

    .sidebar.open {
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.18);
        transform: translateX(0);
    }

    body.menu-open {
        overflow: hidden;
    }

    .menu-backdrop.visible {
        position: fixed;
        inset: 0;
        display: block;
        background: rgba(18, 20, 18, 0.42);
        z-index: 20;
    }

    .mobile-menu {
        display: grid;
        flex: 0 0 auto;
        margin-left: -10px;
    }

    .dashboard-header {
        padding-top: 28px;
    }

    .sidebar-botanical {
        display: none;
    }

}

@media (max-width: 620px) {
    .site-footer {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: center;
    }

    .site-footer > :last-child,
    .build-version {
        justify-self: center;
    }

    .dashboard-header {
        gap: 14px;
        padding: 22px 20px 18px;
    }

    .dashboard-header h1 {
        font-size: 2.7rem;
    }

    .dashboard-header span:not(.avatar) {
        display: none;
    }

    .header-actions {
        margin-left: auto;
    }

    .avatar {
        width: 40px;
        height: 40px;
    }

    .dashboard-content {
        padding: 18px 20px 58px;
    }

    .habit-item {
        grid-template-columns: 30px minmax(0, 1fr) 40px;
        gap: 13px;
        min-height: 78px;
    }

    .habit-item h3 {
        font-size: 1.18rem;
    }

    .habit-item p {
        font-size: 0.76rem;
    }

    .habit-open {
        width: 40px;
        height: 40px;
    }

    .section-empty {
        padding-left: 43px;
    }

    .week-card {
        margin-top: 34px;
        padding: 24px 20px;
    }

    .habit-dialog {
        width: 100%;
        max-width: none;
        max-height: calc(100svh - 16px);
        margin: auto 0 0;
        border-radius: 16px 16px 0 0;
    }

    .dialog-shell {
        height: min(680px, calc(100svh - 16px));
        max-height: calc(100svh - 16px);
    }

    .dialog-header {
        padding: 22px 20px 16px;
    }

    .wizard-progress {
        padding: 0 20px;
    }

    .wizard-step {
        padding: 26px 20px 30px;
    }

    .step-intro {
        margin-bottom: 24px;
    }

    .frequency-sentence {
        gap: 8px;
        padding: 16px;
        font-size: 1rem;
    }

    .frequency-sentence input {
        width: 64px;
    }

    .frequency-sentence select {
        min-width: 0;
        flex: 1;
    }

    .weekday-options {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .weekday-options span {
        width: 100%;
        height: 44px;
        font-size: 0.75rem;
    }

    .wizard-actions {
        grid-template-columns: auto 1fr auto;
        padding: 14px 20px max(18px, env(safe-area-inset-bottom));
    }

    .wizard-actions > span {
        display: none;
    }

    .button-skip {
        grid-column: 2;
        justify-self: end;
        padding: 0 10px;
        font-size: 0.8rem;
    }

    .skip-full {
        display: none;
    }

    .skip-short {
        display: inline;
    }

    .button-primary {
        grid-column: 3;
        min-width: 126px;
        padding-inline: 12px;
        font-size: 0.83rem;
        white-space: nowrap;
    }
}

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

/* Feedback is positioned outside the circle without changing row geometry. */
.habit-check[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); }
.habit-check[aria-pressed="false"] > svg { visibility: hidden; }
.habit-check::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
}
.habit-check::after {
    content: "";
    position: absolute;
    inset: -6px;
    border: 1px solid var(--primary);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}
.completion-ha {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    color: var(--primary-strong);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}
.completion-enter { animation: completion-fill 280ms cubic-bezier(.16, 1, .3, 1); }
.completion-enter > svg { animation: completion-check 320ms cubic-bezier(.16, 1, .3, 1); }
.completion-feedback::after { animation: completion-pulse 360ms ease-out; }
.completion-feedback .completion-ha { animation: completion-ha 560ms cubic-bezier(.16, 1, .3, 1); }
.completion-bucket .completion-ha { font-size: 0.83rem; animation-duration: 660ms; }
@keyframes completion-fill {
    from { background-color: transparent; }
    to { background-color: var(--primary); }
}
@keyframes completion-check {
    0% { opacity: 0; transform: scale(.7); }
    65% { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes completion-pulse {
    0% { opacity: .24; transform: scale(.9); }
    100% { opacity: 0; transform: scale(1.22); }
}
@keyframes completion-ha {
    0% { opacity: 0; transform: translate(-50%, 3px) scale(.94); }
    20%, 50% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -7px) scale(1); }
}
.check-in-error { margin: 12px 0; }
@media (prefers-reduced-motion: reduce) {
    .habit-check, .habit-check > svg, .habit-check::after, .completion-ha {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
    .completion-ha, .habit-check::after { display: none; }
}
.detail-back { color: var(--primary); text-underline-offset: 4px; }
.detail-heading { margin: 30px 0 36px; }
.detail-heading h2 { font: 400 clamp(1.8rem, 4vw, 2.8rem)/1.25 var(--font-display); overflow-wrap: anywhere; }
.detail-heading p { color: var(--text-muted); margin: 12px 0; }
.detail-cue { padding: 16px 20px; background: var(--surface-muted); border-radius: 14px; }
.detail-section { padding: 28px 0; border-top: 1px solid var(--line); }
.detail-section h3 { font: 700 1.2rem/1.4 var(--font-display); margin: 0 0 16px; }
.detail-actions, .detail-section-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.detail-section-heading { justify-content: space-between; }
.detail-actions { margin: 18px 0; }
.detail-note { color: var(--text-muted); font-size: .88rem; max-width: 70ch; }
[data-detail-progress] { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; }
.opportunity-slots { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.opportunity-slots .glyph { font-size: 18px; color: var(--text-muted); }
.opportunity-slots .glyph-check-circle { color: var(--primary); }
.history-bucket { display: flex; align-items: center; gap: 20px; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.history-bucket > span:first-child { min-width: 150px; }
.history-bucket.current { background: var(--surface-muted); }
.history-bucket.unavailable { color: var(--text-muted); }

.detail-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.detail-calendar .history-bucket { min-height: 74px; flex-direction: column; gap: 6px; justify-content: center; border: 1px solid var(--line); border-radius: 9px; padding: 8px 2px; font-size: .8rem; }
.detail-calendar .history-bucket > span:first-child { min-width: 0; }
.detail-calendar .opportunity-slots { justify-content: center; gap: 3px; }
.detail-calendar .opportunity-slots .glyph { font-size: 16px; }
.detail-calendar .unavailable { border-style: dashed; }
.calendar-label { text-align: center; color: var(--text-muted); padding: 8px 0; font-size: .8rem; }
.automaticity-prompt { padding: 20px; border-radius: 14px; background: var(--surface-muted); }
.automaticity-form fieldset { border: 0; padding: 12px 0 20px; margin: 0; }
.automaticity-form legend { padding: 0; }
.automaticity-form fieldset label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px; cursor: pointer; }
.automaticity-form input { accent-color: var(--primary); }
.assessment-entry { padding: 18px 0; border-bottom: 1px solid var(--line); }
.assessment-entry summary { cursor: pointer; }
@media (max-width: 620px) {
.detail-actions .button-primary, .detail-actions .button-secondary { height: auto; min-height: 44px; white-space: normal; }
.history-bucket { gap: 10px; }
.history-bucket > span:first-child { min-width: 105px; font-size: .8rem; }
.detail-calendar { gap: 3px; }
.detail-calendar .history-bucket > span:first-child { min-width: 0; }
.opportunity-slots { gap: 5px; }
}
.button-secondary { min-height: 46px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.button-secondary:hover { background: var(--surface-muted); }
.detail-actions button:disabled { opacity: .6; cursor: default; }
.habit-detail .detail-heading h2 { margin: 0 0 20px; }
@media (max-width: 620px) { body:has([data-habit-detail]) .dashboard-header { gap: 10px; } body:has([data-habit-detail]) .dashboard-header > div:first-of-type { min-width: 0; } body:has([data-habit-detail]) .dashboard-header h1 { font-size: 2rem; } }

/* Sorkos Glyph icons: shared app sizing; icon elements need only the two CDN classes. */
.glyph { flex-shrink: 0; vertical-align: middle; }
.main-nav .glyph, .account-menu .glyph { font-size: 19px; }
.account-nav { position: relative; }
.account-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 0; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.account-toggle .avatar { width: 38px; height: 38px; flex-shrink: 0; }
.account-name { flex: 1; min-width: 0; font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }
.account-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.65; }
.account-menu { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; z-index: 40; padding: 8px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 10px; }
.account-menu a, .account-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; font-size: .83rem; text-align: left; text-decoration: none; }
.account-menu a:hover { background: var(--surface-muted); transform: none; }
.account-menu button:disabled { color: var(--text-muted); cursor: not-allowed; }
.account-menu hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--line); }
.dashboard-header > div:first-of-type { flex: 1; min-width: 0; }
.dashboard-header h1 { font-size: clamp(2rem, 4.4vw, 3.5rem); line-height: 1.12; text-wrap: balance; }
.header-actions { flex-shrink: 0; }
@media (max-width: 620px) { .dashboard-header h1 { font-size: 2rem; } }
