/* =====================================================
   NXTSTEP — sistema visual
   Ideia: o ginásio grego, onde corpo e filosofia
   treinavam juntos. Pedra escura, pergaminho,
   ouro (o seu amarelo) e louro (vitória).
===================================================== */

/* =========================
   TOKENS — TEMA NOITE (padrão)
========================= */

:root {
    --bg: #17160f;          /* pedra escura, levemente bronze */
    --surface: #211f17;
    --surface-2: #2c2a20;
    --line: #3b382c;

    --text: #ede7d6;        /* pergaminho */
    --muted: #a39c86;
    --faint: #716b59;

    --gold: #ffe14a;        /* seu amarelo, um pouco mais quente */
    --gold-ink: #ffe14a;    /* ouro usado como TEXTO */
    --on-gold: #1c1805;     /* texto em cima do ouro */

    --laurel: #a8c97a;      /* louro: hábito concluído */
    --laurel-ink: #b8d68d;
    --danger: #ff6b5e;

    /* mapa de calor do calendário */
    --h0: var(--surface-2);
    --h1: color-mix(in srgb, var(--gold) 22%, var(--surface-2));
    --h2: color-mix(in srgb, var(--gold) 45%, var(--surface-2));
    --h3: color-mix(in srgb, var(--gold) 72%, var(--surface-2));
    --h4: var(--gold);

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 22px;

    --font-display: "Marcellus", "Times New Roman", serif;
    --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

    --dock-h: 68px;

    color-scheme: dark;
}

/* =========================
   TOKENS — TEMA MÁRMORE (claro)
========================= */

:root.light {
    --bg: #e7e6e1;
    --surface: #f6f5f1;
    --surface-2: #dcdad2;
    --line: #c9c6bb;

    --text: #1d1c17;
    --muted: #5d594c;
    --faint: #8a8679;

    --gold: #f7d22a;
    --gold-ink: #7a6200;    /* amarelo não dá leitura em fundo claro */
    --on-gold: #1c1805;

    --laurel: #6a9a3c;
    --laurel-ink: #3f6b1c;
    --danger: #c3372a;

    color-scheme: light;
}

/* =========================
   BASE
========================= */

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

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    transition: background-color .3s ease, color .3s ease;
}

[hidden] {
    display: none !important;
}

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

button {
    background: none;
    border: 0;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3 {
    font-weight: 400;
}

:focus-visible {
    outline: 2px solid var(--gold-ink);
    outline-offset: 2px;
}

.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* =========================
   CARREGAMENTO — degraus acendendo
========================= */

#loader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 22px;
    background: var(--bg);
    transition: opacity .5s ease, visibility .5s;
}

#loader.is-done {
    opacity: 0;
    visibility: hidden;
}

.loader-steps {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    height: 72px;
}

.loader-steps span {
    width: 16px;
    border-radius: 3px 3px 1px 1px;
    background: var(--line);
    animation: climb 1.6s infinite;
}

.loader-steps span:nth-child(1) { height: 25%; }
.loader-steps span:nth-child(2) { height: 50%; animation-delay: .2s; }
.loader-steps span:nth-child(3) { height: 75%; animation-delay: .4s; }
.loader-steps span:nth-child(4) { height: 100%; animation-delay: .6s; }

@keyframes climb {
    0%, 10%  { background: var(--line); }
    25%, 70% { background: var(--gold); }
    100%     { background: var(--line); }
}

.loader-text {
    color: var(--muted);
    font-size: .9rem;
}

/* tela de diagnóstico (quando o carregamento trava) */
.diag {
    width: min(360px, calc(100vw - 40px));
    display: grid;
    gap: 12px;
}

.diag-titulo {
    font-family: var(--font-display);
    font-size: 1.6rem;
}

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

.diag-erros {
    max-height: 40vh;
    overflow: auto;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: .8rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* =========================
   CAMPOS E BOTÕES
========================= */

.field {
    display: grid;
    gap: 6px;
}

.field span,
.field-label {
    font-size: .86rem;
    font-weight: 500;
    color: var(--muted);
}

.input {
    width: 100%;
    padding: 13px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    outline: none;
    transition: border-color .15s ease;
}

.input::placeholder {
    color: var(--faint);
}

.input:focus {
    border-color: var(--gold-ink);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    border-radius: var(--r-md);
    font-weight: 700;
    transition: transform .1s ease, filter .15s ease;
}

.btn:active {
    transform: scale(.98);
}

.btn[disabled] {
    opacity: .6;
    cursor: progress;
}

.btn-primary {
    background: var(--gold);
    color: var(--on-gold);
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
}

.btn-sm {
    padding: 9px 14px;
    font-size: .9rem;
}

.link-btn {
    justify-self: center;
    padding: 6px;
    color: var(--muted);
    font-size: .9rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    color: var(--muted);
    transition: background .15s ease, color .15s ease;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn[disabled] {
    opacity: .25;
    pointer-events: none;
}

.icon-btn.is-armed {
    width: auto;
    padding: 0 12px;
    background: var(--danger);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
}

/* =========================
   LOGIN
========================= */

.auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 32px 22px;
}

.auth-inner {
    width: 100%;
    max-width: 360px;
}

.wordmark {
    font-family: var(--font-display);
    font-size: clamp(3rem, 15vw, 4.4rem);
    line-height: 1;
    letter-spacing: .03em;
}

.auth-lead {
    margin: 10px 0 34px;
    color: var(--muted);
    font-size: 1.05rem;
}

.auth-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    margin-bottom: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.auth-tab {
    padding: 10px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
}

.auth-tab.is-active {
    background: var(--surface-2);
    color: var(--text);
}

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

.auth-error {
    min-height: 1.4em;
    color: var(--danger);
    font-size: .9rem;
}

.auth-quote {
    margin-top: 44px;
    padding-left: 14px;
    border-left: 2px solid var(--line);
    color: var(--faint);
    font-family: var(--font-display);
    font-size: 1.02rem;
    line-height: 1.55;
}

.auth-quote small {
    display: block;
    margin-top: 6px;
    font-family: var(--font-ui);
    font-size: .8rem;
}

/* =========================
   ESTRUTURA DO APP
========================= */

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 20px calc(var(--dock-h) + 48px + env(safe-area-inset-bottom));
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(16px + env(safe-area-inset-top)) 0 6px;
}

.brand {
    font-family: var(--font-display);
    font-size: 1.3rem;
    letter-spacing: .06em;
}

.avatar {
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--avatar, var(--gold));
    color: #1c1805;
    font-weight: 700;
    flex-shrink: 0;
    user-select: none;
}

.avatar-btn {
    width: 40px;
    height: 40px;
    font-size: .88rem;
}

.page {
    padding-top: 20px;
    animation: pageIn .22s ease;
}

@keyframes pageIn {
    from { opacity: 0; }
}

.page-head h2 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 2.4rem);
    line-height: 1.1;
}

.page-head p {
    margin-top: 6px;
    color: var(--muted);
}

.section-title {
    margin: 34px 0 12px;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

.panel {
    margin-top: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.panel h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    line-height: 1.2;
}

.empty {
    list-style: none;
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: var(--r-md);
    color: var(--muted);
    text-align: center;
}

.empty a,
.empty button {
    color: var(--gold-ink);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* =========================
   HOJE — a escada
========================= */

.greeting {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8.5vw, 2.7rem);
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.date-line {
    margin-top: 4px;
    color: var(--muted);
}

.stairs {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 180px;
    margin: 32px 0 14px;
}

.step {
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
    border-radius: 6px 6px 2px 2px;
    transition: background-color .35s ease;
}

.step.is-on {
    background: var(--gold);
}

/* o PRÓXIMO degrau — o "next step" do nome */
.step.is-next {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--gold-ink);
}

.step.is-ghost {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--line);
}

/* único momento de animação: dia perfeito */
.stairs.celebrate .step {
    animation: rise .6s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: calc(var(--i) * 80ms);
    transform-origin: bottom;
}

@keyframes rise {
    0%   { transform: scaleY(.6); filter: brightness(1); }
    60%  { transform: scaleY(1.04); filter: brightness(1.25); }
    100% { transform: scaleY(1); filter: brightness(1); }
}

.stairs-caption {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
}

#evolution-message {
    color: var(--muted);
}

.is-perfect #evolution-message {
    color: var(--laurel-ink);
    font-weight: 600;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 24px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.quick-stats div {
    padding: 12px 0;
}

.quick-stats div + div {
    padding-left: 14px;
    border-left: 1px solid var(--line);
}

.quick-stats dt {
    font-size: .8rem;
    color: var(--muted);
}

.quick-stats dd {
    font-family: var(--font-display);
    font-size: 1.7rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.quote {
    margin: 34px 0 0;
    padding-left: 18px;
    border-left: 3px solid var(--gold);
}

.quote blockquote {
    max-width: 34ch;
    font-family: var(--font-display);
    font-size: 1.32rem;
    line-height: 1.45;
}

.quote figcaption {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 14px;
    margin-top: 12px;
    color: var(--muted);
    font-size: .9rem;
}

.quote-next {
    padding: 4px 0;
    color: var(--gold-ink);
    font-size: .86rem;
    font-weight: 600;
}

.checklist {
    list-style: none;
    display: grid;
    gap: 8px;
}

.check {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    text-align: left;
    transition: border-color .2s ease, background-color .2s ease;
}

.check-icon {
    width: 28px;
    font-size: 1.3rem;
    text-align: center;
}

.check-row {
    display: flex;
    gap: 6px;
}

.check-body {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 3px;
}

.check-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.check-sub {
    color: var(--muted);
    font-size: .84rem;
    font-variant-numeric: tabular-nums;
}

.check-progress {
    height: 4px;
    margin-top: 3px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.check-progress i {
    display: block;
    height: 100%;
    background: var(--gold);
    border-radius: inherit;
    transition: width .25s ease;
}

.check.is-done .check-progress i {
    background: var(--laurel);
}

.qty-minus {
    display: grid;
    place-items: center;
    width: 50px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--muted);
}

.qty-minus svg {
    width: 18px;
    height: 18px;
}

.offday-row {
    list-style: none;
    margin-top: 6px;
}

.offday summary {
    padding: 10px 2px;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
}

.offday .small {
    margin-bottom: 10px;
}

.offday .check {
    background: transparent;
    border-style: dashed;
}

.check-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 2px solid var(--line);
    border-radius: 50%;
    transition: background-color .2s ease, border-color .2s ease;
}

.check-mark svg {
    width: 15px;
    height: 15px;
    color: #12160b;
    opacity: 0;
    transition: opacity .15s ease;
}

.check.is-done {
    border-color: color-mix(in srgb, var(--laurel) 45%, var(--line));
}

.check.is-done .check-name {
    color: var(--muted);
}

.check.is-done .check-mark {
    background: var(--laurel);
    border-color: var(--laurel);
}

.check.is-done .check-mark svg {
    opacity: 1;
}

/* hábito com quantidade: o círculo mostra "+" até bater a meta */
.check.is-qty:not(.is-done) .check-mark svg {
    opacity: .8;
    color: var(--muted);
}

.note-cta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    padding: 16px 18px;
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.note-cta strong {
    display: block;
}

.note-cta small {
    color: var(--muted);
    font-size: .86rem;
}

.note-cta .note-cta-action {
    color: var(--gold-ink);
    font-weight: 700;
    white-space: nowrap;
}

/* =========================
   HÁBITOS
========================= */

/* criar / editar hábito */
.habit-new {
    margin: 22px 0 10px;
}

.new-habit-btn {
    width: 100%;
}

.habit-new-box {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.editor {
    display: grid;
    gap: 18px;
}

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

.icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.icon-opt {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: var(--r-sm);
}

.icon-opt[aria-checked="true"] {
    border-color: var(--gold-ink);
}

.day-picker {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.day-chip {
    padding: 10px 0;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--muted);
    font-size: .84rem;
    font-weight: 600;
}

.day-chip[aria-pressed="true"] {
    background: var(--gold);
    color: var(--on-gold);
}

.day-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.day-presets button {
    padding: 2px 0;
    color: var(--gold-ink);
    font-size: .84rem;
    font-weight: 600;
}

.ed-target {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stepper {
    display: grid;
    place-items: center;
    width: 44px;
    height: 46px;
    flex-shrink: 0;
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.stepper svg {
    width: 18px;
    height: 18px;
}

.ed-target-input {
    width: 60px;
    flex-shrink: 0;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
    font-weight: 700;
    -moz-appearance: textfield;
}

.ed-target-input::-webkit-outer-spin-button,
.ed-target-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ed-unit {
    flex: 1;
    min-width: 0;
}

.ed-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ed-actions .btn-primary:only-child {
    width: 100%;
}

.habit-list {
    list-style: none;
}

.habit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.habit-row-icon {
    width: 32px;
    font-size: 1.35rem;
    text-align: center;
    flex-shrink: 0;
}

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

.habit-row-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.habit-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    color: var(--muted);
    font-size: .85rem;
}

.habit-row-actions {
    display: flex;
    gap: 2px;
}

.habit-row.is-editing {
    display: block;
    padding: 18px 0 20px;
}

/* =========================
   EVOLUÇÃO
========================= */

.rank {
    margin-top: 22px;
    padding: 26px 22px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.rank-name {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 7.5vw, 2.5rem);
    line-height: 1.1;
    color: var(--gold-ink);
}

.rank-line {
    margin-top: 8px;
    color: var(--muted);
}

.meter {
    height: 8px;
    margin-top: 22px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.meter-fill {
    width: 0;
    height: 100%;
    background: var(--gold);
    border-radius: inherit;
    transition: width .6s ease;
}

.rank-next {
    margin-top: 8px;
    color: var(--muted);
    font-size: .86rem;
}

.stat-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 18px 0 6px;
}

.stat-list div {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.stat-list div:nth-child(odd) {
    padding-right: 14px;
}

.stat-list div:nth-child(even) {
    padding-left: 16px;
    border-left: 1px solid var(--line);
}

.stat-list dt {
    color: var(--muted);
    font-size: .85rem;
}

.stat-list dd {
    font-family: var(--font-display);
    font-size: 1.65rem;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    margin-top: 18px;
}

.bar {
    flex: 1;
    min-height: 3px;
    background: var(--h2);
    border-radius: 3px 3px 1px 1px;
}

.bar.is-perfect { background: var(--gold); }
.bar.is-zero    { background: var(--surface-2); }
.bar.is-before  { background: transparent; box-shadow: inset 0 -2px 0 var(--line); }
.bar.is-today   { outline: 1px solid var(--text); outline-offset: 1px; }
.bar.is-rest    { background: repeating-linear-gradient(-45deg, transparent 0 3px, var(--surface-2) 3px 5px); }

.bars-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    color: var(--faint);
    font-size: .78rem;
}

.habit-bars {
    list-style: none;
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.hb-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: .92rem;
}

.hb-top span:first-child {
    overflow-wrap: anywhere;
}

.hb-top span:last-child {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.hb-track {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.hb-fill {
    height: 100%;
    background: var(--laurel);
    border-radius: inherit;
}

.weekday-bars {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    height: 120px;
    margin-top: 16px;
}

.wd {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.wd-track {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
}

.wd-bar {
    width: 100%;
    min-height: 3px;
    background: var(--h2);
    border-radius: 4px 4px 1px 1px;
}

.wd.is-best .wd-bar {
    background: var(--gold);
}

.wd.is-off .wd-bar {
    background: transparent;
    box-shadow: inset 0 -2px 0 var(--line);
}

.wd span {
    color: var(--muted);
    font-size: .76rem;
}

/* =========================
   MENSAL
========================= */

.month-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: center;
}

.month-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 20px 0 22px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.month-summary div {
    padding: 12px 0;
}

.month-summary div + div {
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.month-summary dt {
    color: var(--muted);
    font-size: .78rem;
}

.month-summary dd {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-variant-numeric: tabular-nums;
}

.cal-week,
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-week span {
    padding-bottom: 6px;
    color: var(--faint);
    font-size: .78rem;
    text-align: center;
}

.cal-day {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    font-size: .92rem;
    font-variant-numeric: tabular-nums;
}

.h0 { background: var(--h0); }
.h1 { background: var(--h1); }
.h2 { background: var(--h2); }
.h3 { background: var(--h3); color: var(--on-gold); }
.h4 { background: var(--h4); color: var(--on-gold); font-weight: 700; }

/* dia de descanso: listrado, nem conta a favor nem contra */
.cal-day.is-rest {
    background: repeating-linear-gradient(-45deg, var(--surface) 0 4px, var(--surface-2) 4px 7px);
    color: var(--muted);
}

.cal-day.is-today {
    box-shadow: inset 0 0 0 2px var(--text);
}

.cal-day.is-selected {
    outline: 2px solid var(--gold-ink);
    outline-offset: 2px;
}

.cal-day.is-future {
    opacity: .35;
    cursor: default;
}

.cal-day .dot {
    position: absolute;
    bottom: 5px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: .75;
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    margin-top: 12px;
    color: var(--faint);
    font-size: .78rem;
}

.cal-legend .cal-rest-key {
    background: repeating-linear-gradient(-45deg, var(--surface) 0 2px, var(--surface-2) 2px 4px);
    box-shadow: inset 0 0 0 1px var(--line);
}

.cal-legend-gap {
    flex: 1;
}

.cal-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.day-detail {
    margin-top: 22px;
}

.day-detail .muted {
    margin-top: 4px;
}

.chips {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.chips li {
    padding: 6px 11px;
    background: var(--surface-2);
    border-radius: 999px;
    font-size: .88rem;
}

.chips li.is-partial {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--muted);
}

.detail-note {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.day-detail .btn {
    margin-top: 16px;
}

/* =========================
   NOTAS
========================= */

.note-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.note-prompt {
    margin: 24px 0 18px;
    font-family: var(--font-display);
    font-size: 1.25rem;
    line-height: 1.45;
}

.mood {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.mood-opt {
    flex: 1;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 9px 0 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    font-size: 1.35rem;
    line-height: 1.2;
}

.mood-opt small {
    color: var(--muted);
    font-size: .7rem;
}

.mood-opt[aria-checked="true"] {
    background: var(--surface-2);
    border-color: var(--gold-ink);
}

.note-text {
    min-height: 230px;
    resize: vertical;
    line-height: 1.65;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    color: var(--faint);
    font-size: .82rem;
}

.note-list {
    list-style: none;
    display: grid;
    gap: 10px;
}

.note-item {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    text-align: left;
}

.note-item-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .85rem;
}

.note-item-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

.note-item.is-open .note-item-text {
    display: block;
}

.more-notes {
    width: 100%;
}

/* =========================
   PERFIL
========================= */

.profile-head {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 6px;
}

.profile-head h2 {
    font-family: var(--font-display);
    font-size: 1.95rem;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.profile-head p {
    margin-top: 2px;
    color: var(--gold-ink);
}

.avatar-lg {
    width: 76px;
    height: 76px;
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 400;
}

.panel .field {
    margin-top: 16px;
}

.panel .field-label {
    margin-top: 16px;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0 18px;
}

.swatch {
    width: 36px;
    height: 36px;
    background: var(--c);
    border: 3px solid var(--surface);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--line);
}

.swatch[aria-checked="true"] {
    box-shadow: 0 0 0 2px var(--text);
}

.info-list {
    margin: 18px 0 0;
}

.info-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.info-list dt {
    color: var(--muted);
}

.info-list dd {
    text-align: right;
    overflow-wrap: anywhere;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.setting-row p {
    color: var(--muted);
    font-size: .86rem;
}

.switch {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: background-color .2s ease;
}

.switch span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: var(--text);
    border-radius: 50%;
    transition: transform .2s ease, background-color .2s ease;
}

.switch[aria-checked="true"] {
    background: var(--gold);
    border-color: var(--gold);
}

.switch[aria-checked="true"] span {
    transform: translateX(22px);
    background: var(--on-gold);
}

.row-btn {
    display: block;
    width: 100%;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    text-align: left;
}

.row-btn:last-child {
    border-bottom: 0;
    padding-bottom: 2px;
}

.row-btn.danger {
    color: var(--danger);
}

/* =========================
   DIA DE PAUSA
========================= */

.pause-box:empty {
    display: none;
}

.pause-box {
    margin-top: 10px;
}

.pause-open {
    display: block;
    margin: 2px auto 0;
}

.pause-banner,
.pause-picker {
    display: grid;
    gap: 10px;
    padding: 18px;
    border: 1px dashed var(--muted);
    border-radius: var(--r-md);
}

.pause-title {
    font-weight: 700;
}

.pause-title span {
    margin-left: 6px;
    color: var(--muted);
    font-weight: 500;
}

.pause-quote {
    font-family: var(--font-display);
    font-size: 1.05rem;
    line-height: 1.5;
}

.pause-quote small {
    display: block;
    margin-top: 4px;
    font-family: var(--font-ui);
    color: var(--muted);
    font-size: .8rem;
}

.pause-banner .btn {
    justify-self: start;
}

.pause-picker .link-btn {
    justify-self: start;
    padding-left: 0;
}

.pause-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pause-chip {
    padding: 9px 13px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
}

.pause-chip:hover {
    border-color: var(--gold-ink);
}

.stairs.is-paused .step {
    opacity: .4;
}

.cal-day.is-pause {
    background: var(--surface);
    border: 1.5px dashed var(--muted);
    color: var(--muted);
}

.cal-legend .cal-pause-key {
    background: transparent;
    border: 1.5px dashed var(--muted);
}

.pause-tag {
    margin-top: 6px;
    font-weight: 600;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.day-detail .detail-actions .btn {
    margin-top: 0;
}

.detail-pause {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

/* =========================
   REVISÃO DA SEMANA
========================= */

.review-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    padding: 16px 18px;
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.review-link strong {
    display: block;
}

.review-link small {
    color: var(--muted);
    font-size: .86rem;
}

#review-cta:empty {
    display: none;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 600;
}

.back-link::before {
    content: "‹";
    font-size: 1.3rem;
    line-height: 1;
}

#page-revisao .month-summary {
    margin-bottom: 10px;
}

.week-compare {
    min-height: 1.5em;
    color: var(--muted);
    font-size: .92rem;
}

.week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin: 18px 0 6px;
}

.ws-day {
    display: grid;
    justify-items: center;
    gap: 5px;
}

.ws-track {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: flex-end;
    background: var(--surface);
    border-radius: 6px;
    overflow: hidden;
}

.ws-bar {
    width: 100%;
    background: var(--h2);
    border-radius: 6px 6px 0 0;
}

.ws-bar.is-perfect { background: var(--gold); }
.ws-bar.is-rest    { background: repeating-linear-gradient(-45deg, transparent 0 3px, var(--surface-2) 3px 5px); }
.ws-bar.is-pause   { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); border-radius: 6px; }

.ws-label {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 600;
}

.ws-day.is-today .ws-label {
    color: var(--text);
}

.ws-mood {
    min-height: 1.3em;
    font-size: .95rem;
}

.week-insight {
    margin-top: 14px;
    font-size: .92rem;
}

.week-insight:empty {
    display: none;
}

.review-q {
    margin-top: 18px;
}

.review-q span {
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 400;
}

.review-text {
    resize: vertical;
    line-height: 1.6;
}

/* =========================
   NAVEGAÇÃO (dock)
========================= */

.dock {
    position: fixed;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 20;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 24px));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: 22px;
}

.dock a {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 8px 0 6px;
    border-radius: 16px;
    color: var(--faint);
    font-size: .72rem;
    font-weight: 600;
    transition: color .15s ease, background-color .15s ease;
}

.dock svg {
    width: 22px;
    height: 22px;
}

.dock a.is-active {
    color: var(--text);
    background: var(--surface-2);
}

.dock a.is-active svg {
    color: var(--gold-ink);
}

/* =========================
   AVISOS (toasts)
========================= */

.toasts {
    position: fixed;
    left: 50%;
    bottom: calc(var(--dock-h) + 32px + env(safe-area-inset-bottom));
    z-index: 50;
    transform: translateX(-50%);
    width: min(420px, calc(100% - 32px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--r-md);
    font-size: .92rem;
    font-weight: 600;
    animation: toastIn .25s ease;
}

.toast.is-error {
    background: var(--danger);
    color: #fff;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
}

/* =========================
   TELAS PEQUENAS
========================= */

@media (max-width: 420px) {

    .app {
        padding-left: 16px;
        padding-right: 16px;
    }

    .month-summary {
        grid-template-columns: 1fr 1fr;
    }

    .month-summary div:nth-child(3) {
        padding-left: 0;
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .month-summary div:nth-child(4) {
        border-top: 1px solid var(--line);
    }

    .cal-week,
    .cal-grid {
        gap: 4px;
    }

    .mood-opt small {
        display: none;
    }

    .habit-row-actions .icon-btn:not(.is-armed) {
        width: 34px;
    }
}

/* =========================
   MOVIMENTO REDUZIDO
========================= */

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