/* Stoei Habits layout. Colors, fonts, sizes and components come from the Stoei Core kit and public/css/theme.css (--st-* settings). */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.habit-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-4);
    padding-block: var(--st-space-3);
    padding-left: max(var(--st-space-4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--st-space-4), env(safe-area-inset-right, 0px));
    border-bottom: var(--st-line-width) solid var(--st-color-line);
    background: var(--st-color-surface);
}

.habit-wordmark {
    font-weight: 800;
    color: var(--st-color-text);
    text-decoration: none;
}

.habit-wordmark small {
    font-weight: 500;
    color: var(--st-color-accent);
    font-size: inherit;
}

.habit-topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
}

.habit-main {
    flex: 1;
    width: 100%;
    max-width: 30rem;
    margin-inline: auto;
    padding-block: var(--st-space-6);
    padding-left: max(var(--st-space-4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--st-space-4), env(safe-area-inset-right, 0px));
}

.habit-auth {
    display: flex;
    justify-content: center;
    padding-top: var(--st-space-7);
}

.habit-auth-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--st-space-4);
}

.habit-auth-title,
.habit-page-title {
    margin: 0;
    color: var(--st-color-text);
}

.habit-form,
.habit-grow-fields {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
}

.habit-form .st-btn {
    margin-top: var(--st-space-3);
}

.habit-msg {
    margin: 0;
    padding: var(--st-space-2) var(--st-space-3);
    border-radius: var(--st-radius-1);
    background: var(--st-color-bad-tint);
    color: var(--st-color-bad);
}

.habit-link,
.habit-tab[aria-current="page"] {
    color: var(--st-color-accent);
}

.habit-today,
.habit-history,
.habit-template,
.habit-workout {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-3);
}

[x-cloak] {
    display: none !important;
}

.habit-today-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--st-space-4);
}

.habit-today-head .st-eyebrow,
.habit-loading,
.habit-empty p,
.habit-timer .st-eyebrow,
.habit-own-time .st-label,
.habit-history .st-eyebrow,
.habit-template .habit-section-title,
.habit-template-about,
.habit-workout .st-eyebrow {
    margin: 0;
}

.habit-progress-text {
    margin: 0;
    font-weight: 700;
    color: var(--st-color-accent);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.habit-progress {
    appearance: none;
    width: 100%;
    height: 0.4rem;
    border: 0;
    border-radius: var(--st-radius-full);
    background: var(--st-color-line);
    overflow: hidden;
}

.habit-progress::-webkit-progress-bar {
    background: var(--st-color-line);
}

.habit-progress::-webkit-progress-value {
    background: var(--st-color-accent);
    transition: width var(--st-motion);
}

.habit-progress::-moz-progress-bar {
    background: var(--st-color-accent);
}

.habit-list,
.habit-picks,
.habit-workout-plan {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
}

.habit-row {
    display: flex;
    align-items: center;
    gap: var(--st-space-3);
    padding: var(--st-space-3);
    background: var(--st-color-surface);
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-5);
}

.habit-check {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: calc(var(--st-line-width) * 2) solid var(--st-color-line-strong);
    background: transparent;
    color: transparent;
    cursor: pointer;
    transition: background var(--st-motion), border-color var(--st-motion);
}

.habit-row.is-done .habit-check {
    background: var(--st-color-accent-fill);
    border-color: var(--st-color-accent-fill);
    color: var(--st-color-on-accent);
}

.habit-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.habit-name {
    font-weight: 600;
    color: var(--st-color-text);
    overflow-wrap: anywhere;
}

.habit-row.is-done .habit-name,
.habit-pick:has(input:not(:checked)) .habit-name {
    color: var(--st-color-text-faint);
    text-decoration: line-through;
}

.habit-target {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    overflow-wrap: anywhere;
}

.habit-streak {
    font-weight: 700;
    font-size: var(--st-text-3);
    color: var(--st-color-warn);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.habit-streak.is-zero,
.habit-dial.is-ringing,
.habit-big.is-zero {
    color: var(--st-color-bad);
}

.habit-edit {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: var(--st-radius-3);
    background: transparent;
    color: var(--st-color-text-muted);
    cursor: pointer;
}

.habit-edit:hover {
    background: var(--st-color-sunk);
    color: var(--st-color-text);
}


.habit-add {
    margin-top: var(--st-space-2);
    width: 100%;
}

.habit-reset-note {
    margin: 0;
    text-align: center;
    font-size: var(--st-text-3);
}

.habit-sheet {
    margin: auto;
    width: min(30rem, calc(100% - 2 * var(--st-space-4)));
    padding: var(--st-space-6);
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-6);
    background: var(--st-color-raised);
    color: var(--st-color-text-soft);
    box-shadow: var(--st-shadow-3);
}

.habit-sheet::backdrop {
    background: color-mix(in srgb, var(--st-color-bg) 80%, transparent);
}

.habit-sheet-title {
    margin: 0 0 var(--st-space-2);
    color: var(--st-color-text);
}

.habit-hint {
    display: block;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--st-color-text-muted);
}

.habit-sheet-buttons {
    display: flex;
    gap: var(--st-space-2);
    margin-top: var(--st-space-3);
}

.habit-sheet-buttons .st-btn {
    flex: 1;
    margin-top: 0;
}

.habit-remove-link {
    align-self: center;
    margin-top: var(--st-space-2);
    border: 0;
    background: none;
    color: var(--st-color-bad);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.habit-footer {
    text-align: center;
    color: var(--st-color-text-faint);
    font-size: var(--st-text-1);
    padding-block: var(--st-space-4) calc(var(--st-space-4) + env(safe-area-inset-bottom, 0px));
}


/* Settings */
.habit-settings,
.habit-templates {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-4);
}

.habit-section-title {
    margin: 0 0 var(--st-space-2);
    font-size: var(--st-text-5);
    color: var(--st-color-text);
}

.habit-form .habit-hint {
    margin: 0;
    font-size: var(--st-text-3);
}

.habit-form .habit-hint:empty {
    display: none;
}

.habit-link-button {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: none;
    color: var(--st-color-accent);
    font: inherit;
    font-size: var(--st-text-3);
    text-decoration: underline;
    cursor: pointer;
}

.habit-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-4);
}

.habit-account-email {
    margin: 0;
    overflow-wrap: anywhere;
}

.habit-saved {
    margin: 0;
    padding: var(--st-space-2) var(--st-space-3);
    border-radius: var(--st-radius-1);
    background: var(--st-color-ok-tint);
    color: var(--st-color-ok);
}

/* Bottom tab bar (signed-in pages) */
.habit-has-tabs {
    padding-bottom: calc(var(--st-size-tabbar) + env(safe-area-inset-bottom, 0px));
}

.habit-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: center;
    background: var(--st-color-surface);
    border-top: var(--st-line-width) solid var(--st-color-line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.habit-tabs-inner {
    display: flex;
    width: 100%;
    max-width: 30rem;
}

.habit-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--st-space-1);
    padding: var(--st-space-3) var(--st-space-1);
    font-size: var(--st-text-1);
    font-weight: 600;
    color: var(--st-color-text-muted);
    text-decoration: none;
}

.habit-tab:hover {
    color: var(--st-color-text);
}

.habit-tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.habit-tab:focus-visible {
    outline-offset: calc(var(--st-space-1) * -1);
    border-radius: var(--st-radius-3);
}

.habit-has-tabs .habit-footer {
    padding-bottom: var(--st-space-4);
}

/* Timer */
.habit-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--st-space-2);
    margin-block: var(--st-space-6) var(--st-space-4);
}

.habit-chip {
    font: inherit;
    font-size: var(--st-text-3);
    color: var(--st-color-text);
    background: var(--st-color-surface);
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-full);
    padding: var(--st-space-2) var(--st-space-4);
    cursor: pointer;
}

.habit-chip.is-on {
    background: var(--st-color-accent-tint);
    border-color: var(--st-color-accent);
    color: var(--st-color-accent);
    font-weight: 600;
}


.habit-own-time {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--st-space-2);
}

.habit-own-time .st-input {
    width: 7rem;
    text-align: center;
}

.habit-timer .habit-msg {
    margin-top: var(--st-space-3);
    text-align: center;
}

.habit-dial {
    font-size: var(--st-text-timer);
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--st-color-text);
    margin-block: var(--st-space-6) var(--st-space-2);
}

.habit-wake {
    text-align: center;
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: 0;
}

.habit-timer-buttons {
    display: flex;
    justify-content: center;
    gap: var(--st-space-3);
    margin-top: var(--st-space-6);
}

.habit-timer-buttons .st-btn {
    min-width: 8rem;
}

/* History */
.habit-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--st-space-4);
    margin: 0;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}

.habit-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: var(--st-space-2);
    vertical-align: -1px;
}

.habit-hcard {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-3);
    padding: var(--st-space-3);
    background: var(--st-color-surface);
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-5);
}

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

.habit-hhead .habit-name {
    margin: 0;
    font-size: var(--st-text-5);
}

.habit-big {
    margin: 0;
    flex: none;
    font-size: var(--st-text-12);
    font-weight: 700;
    line-height: 1;
    color: var(--st-color-warn);
    font-variant-numeric: tabular-nums;
}

.habit-big small {
    margin-left: var(--st-space-1);
    font-size: var(--st-text-3);
    font-weight: 500;
    color: var(--st-color-text-muted);
}

.habit-days {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: var(--st-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.habit-day {
    aspect-ratio: 1;
    border-radius: var(--st-radius-1);
    background: var(--st-color-line);
}

.habit-day.is-done {
    background: var(--st-color-accent);
}

.habit-day.is-missed {
    background: var(--st-color-bad);
}

.habit-day.is-today {
    background: transparent;
    border: var(--st-line-width) solid var(--st-color-line-strong);
}

.habit-hmeta {
    display: flex;
    justify-content: space-between;
    gap: var(--st-space-2);
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}

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

/* Templates */
.habit-add-template {
    width: 100%;
    text-align: center;
}

.habit-templates header p,
.habit-workout-step {
    margin: var(--st-space-2) 0 0;
}

.habit-back {
    display: inline-block;
    margin-bottom: var(--st-space-2);
    text-decoration: none;
}

.habit-pick {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: var(--st-space-3);
    align-items: center;
    padding: var(--st-space-2) var(--st-space-3);
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    cursor: pointer;
}

.habit-pick input {
    grid-row: span 2;
    width: 20px;
    height: 20px;
    accent-color: var(--st-color-accent);
}

/* Weekly growth: note under a habit on Today, and the switch and fields in the edit sheet. */
.habit-growth-note {
    font-size: var(--st-text-3);
    color: var(--st-color-accent);
}

.habit-grow-switch {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    margin-top: var(--st-space-3);
    font-weight: 600;
    color: var(--st-color-text);
    cursor: pointer;
}

.habit-grow-switch input {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--st-color-accent);
}

.habit-grow-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--st-space-3);
}

/* Certain days: day buttons in the sheet, the days under a habit, and the "Not today" list. */
.habit-when {
    margin: var(--st-space-3) 0 0;
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
}

.habit-when .habit-grow-switch {
    margin-top: 0;
}

.habit-weekdays {
    display: flex;
    flex-wrap: wrap;
    gap: var(--st-space-2);
}

.habit-weekdays .habit-chip {
    padding: var(--st-space-2) var(--st-space-3);
}

.habit-days-note,
.habit-workout-note {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.habit-not-today {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
    margin-top: var(--st-space-3);
}

.habit-not-today .habit-section-title {
    margin: 0;
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.habit-row.is-resting {
    opacity: 0.6;
}

.habit-day.is-rest {
    background: radial-gradient(circle, var(--st-color-line-strong) 0 30%, transparent 34%);
}

/* Workouts: the Start button on Today, the plan field in the sheet, and the workout screen. */
.habit-start {
    align-self: flex-start;
    margin-top: var(--st-space-2);
    padding-block: var(--st-space-1);
    min-height: 0;
}

.habit-plan {
    font-family: inherit;
    width: 100%;
}

.habit-rest {
    width: 6rem;
}

.habit-workout-stage {
    text-align: center;
    padding-block: var(--st-space-4);
}

.habit-workout-exercise {
    font-size: var(--st-text-10);
    font-weight: 700;
    color: var(--st-color-text);
    margin: 0;
}

.habit-workout-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--st-space-4);
}

.habit-workout-count .habit-dial {
    min-width: 3ch;
}

.habit-round {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: var(--st-line-width) solid var(--st-color-line-strong);
    background: var(--st-color-surface);
    color: var(--st-color-text);
    font: inherit;
    font-size: var(--st-text-10);
    line-height: 1;
    cursor: pointer;
}


.habit-workout-extras {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--st-space-2);
    margin-top: var(--st-space-3);
}

.habit-workout-plan li {
    display: flex;
    justify-content: space-between;
    gap: var(--st-space-3);
    padding: var(--st-space-2) var(--st-space-3);
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    background: var(--st-color-surface);
}

.habit-workout-plan li.is-current {
    border-color: var(--st-color-accent);
    background: var(--st-color-accent-tint);
}

.habit-workout-plan li.is-past {
    opacity: 0.55;
}

.habit-workout-finish {
    align-self: center;
}

/* Reorder mode on Today: one list with up and down buttons. */
.habit-reorder-bar {
    display: flex;
    justify-content: flex-end;
}

.habit-reorder-toggle[aria-pressed="true"] {
    color: var(--st-color-accent);
    font-weight: 700;
}

.habit-reorder-row .habit-name {
    flex: 1;
    min-width: 0;
}

.habit-move {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: var(--st-line-width) solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    background: transparent;
    color: var(--st-color-text);
    cursor: pointer;
}

.habit-move:hover:not(:disabled) {
    background: var(--st-color-sunk);
}

.habit-move:disabled {
    opacity: 0.3;
    cursor: default;
}

