:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef3fa;
    --text: #1d2430;
    --muted: #687386;
    --line: #dfe7f1;
    --accent: #b6ff3b;
    --accent-dark: #5e8200;
    --blue: #2f80ed;
    --green: #19c37d;
    --warning: #ffb020;
    --danger: #ff4d4f;
    --shadow: 0 18px 46px rgba(34, 45, 65, 0.1);
    --shadow-soft: 0 10px 24px rgba(34, 45, 65, 0.08);
    --radius: 8px;
    --content: 1120px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(182, 255, 59, 0.13), transparent 32%),
        linear-gradient(315deg, rgba(47, 128, 237, 0.11), transparent 36%),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

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

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(47, 128, 237, 0.28);
    outline-offset: 2px;
}

.noscript {
    margin: 24px auto;
    max-width: 520px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}

.app {
    min-height: 100vh;
}

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

.content {
    width: min(100%, var(--content));
    margin: 0 auto;
    padding: 28px 20px 34px;
    flex: 1;
}

.screen.with-nav .content {
    padding-bottom: 24px;
}

.auth-screen .content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 34px;
    padding-bottom: 34px;
}

.auth-layout {
    width: min(100%, 440px);
}

.brand-lockup {
    margin-bottom: 22px;
    text-align: center;
}

.logo-mark {
    width: 92px;
    height: 92px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.5), transparent),
        var(--accent);
    color: var(--text);
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: var(--shadow-soft);
}

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

h1,
.page-title {
    font-size: 2rem;
    line-height: 1.08;
    letter-spacing: 0;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.18;
    letter-spacing: 0;
}

h3 {
    font-size: 1rem;
    line-height: 1.25;
    letter-spacing: 0;
}

.muted,
.subtitle,
.meta,
.eyebrow {
    color: var(--muted);
}

.subtitle {
    margin-top: 8px;
    font-size: 0.98rem;
}

.eyebrow {
    margin-bottom: 5px;
    font-size: 0.79rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.page-header,
.topbar {
    margin-bottom: 22px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar > div {
    min-width: 0;
}

.page-header {
    max-width: 760px;
}

.section-title {
    margin: 2px 0 12px;
}

.card {
    padding: 18px;
    border: 1px solid rgba(223, 231, 241, 0.92);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
}

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

.choice-list,
.challenge-list {
    display: grid;
    gap: 12px;
}

.stack-top {
    margin-top: 18px;
}

.choice-card {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border: 1px solid rgba(223, 231, 241, 0.92);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    text-align: left;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.choice-card:hover {
    transform: translateY(-2px);
    border-color: rgba(47, 128, 237, 0.34);
    box-shadow: var(--shadow);
}

.choice-card strong,
.entry-main strong {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.choice-card .arrow {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 1.3rem;
    font-weight: 800;
}

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

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

.field label {
    color: var(--muted);
    font-size: 0.83rem;
    font-weight: 800;
}

.input {
    width: 100%;
    min-height: 54px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
}

.input::placeholder {
    color: #8793a5;
}

.input:focus {
    border-color: rgba(47, 128, 237, 0.52);
    background: #ffffff;
}

.btn,
.chip,
.icon-button,
.nav-item,
.link-button {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.btn {
    min-height: 52px;
    width: 100%;
    padding: 0 16px;
    font-weight: 850;
    text-align: center;
    overflow-wrap: anywhere;
}

.btn:hover,
.chip:hover,
.icon-button:hover,
.nav-item:hover,
.link-button:hover {
    transform: translateY(-1px);
}

.btn.primary {
    background: var(--accent);
    box-shadow: 0 12px 22px rgba(117, 160, 10, 0.18);
}

.btn.secondary {
    background: var(--surface-2);
}

.btn.danger {
    background: #fff0f0;
    color: var(--danger);
}

.chip {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 800;
}

.chip-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.chip.active,
.chip[data-status="active"] {
    border-color: rgba(25, 195, 125, 0.35);
    background: rgba(25, 195, 125, 0.12);
    color: #086f45;
}

.chip[data-status="completed"] {
    border-color: rgba(47, 128, 237, 0.35);
    background: rgba(47, 128, 237, 0.1);
    color: #1c5aa4;
}

.chip[data-status="archived"] {
    background: var(--surface-2);
    color: var(--muted);
}

.back-button {
    margin-bottom: 18px;
}

.icon-button {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    font-weight: 900;
}

.hero-card {
    display: grid;
    gap: 16px;
    padding: 22px;
    background:
        linear-gradient(135deg, rgba(182, 255, 59, 0.23), transparent 44%),
        rgba(255, 255, 255, 0.94);
}

.hero-value {
    text-align: center;
}

.hero-value strong {
    display: block;
    font-size: 3rem;
    line-height: 1;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.progress-track {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7edf5;
}

.progress-track span {
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    border-radius: inherit;
    background: var(--fill, var(--blue));
    transition: width 220ms ease;
}

.totals-row,
.period-head,
.entry-row,
.challenge-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.metric-block,
.metric-tile {
    min-width: 0;
    text-align: center;
}

.metric-block strong,
.metric-tile strong {
    display: block;
    overflow-wrap: anywhere;
}

.metric-block span,
.metric-tile span {
    color: var(--muted);
    font-size: 0.82rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
    gap: 16px;
    align-items: start;
}

.main-column,
.side-column {
    display: grid;
    gap: 16px;
}

.period-list,
.metric-grid {
    display: grid;
    gap: 12px;
}

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

.period-card {
    display: grid;
    gap: 12px;
}

.period-value {
    flex: 0 0 auto;
    font-weight: 900;
    text-align: right;
}

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

.entries-list.recent-list {
    margin-top: 12px;
}

.entry-row {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.entry-row:first-child {
    border-top: 0;
    padding-top: 0;
}

.entry-main {
    min-width: 0;
}

.delete-button {
    width: auto;
    min-height: 38px;
    padding: 0 12px;
    background: #fff0f0;
    color: var(--danger);
}

.empty-state {
    display: grid;
    gap: 8px;
}

.chart-card {
    display: grid;
    gap: 14px;
}

.bar-chart {
    position: relative;
    height: 190px;
    display: flex;
    align-items: flex-end;
    gap: 7px;
    padding: 18px 6px 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(to top, rgba(223, 231, 241, 0.72) 1px, transparent 1px),
        #fbfdff;
    background-size: 100% 25%;
}

.bar {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
    height: var(--bar-height, 0%);
    min-height: 4px;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, #2f80ed, #1f64bf);
}

.bar.empty {
    background: #d6dfeb;
}

.target-line {
    position: absolute;
    left: 6px;
    right: 6px;
    top: var(--target-top, 50%);
    height: 2px;
    border-radius: 999px;
    background: var(--muted);
    opacity: 0.75;
}

.bottom-nav-wrap {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(245, 247, 251, 0.88);
    backdrop-filter: blur(18px);
    border-top: 1px solid rgba(223, 231, 241, 0.9);
}

.bottom-nav {
    width: min(100%, var(--content));
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.nav-item {
    min-height: 52px;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--surface);
    color: var(--muted);
    box-shadow: 0 8px 20px rgba(34, 45, 65, 0.07);
    font-size: 0.72rem;
    font-weight: 850;
}

.nav-item .nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.nav-item.is-active {
    background: var(--accent);
    color: var(--text);
}

.nav-item.add {
    background: var(--text);
    color: #ffffff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    background: rgba(20, 29, 43, 0.38);
}

.modal {
    width: min(100%, 480px);
    display: grid;
    gap: 14px;
    padding: 20px;
    border: 1px solid rgba(223, 231, 241, 0.96);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 28px 70px rgba(20, 29, 43, 0.24);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.link-button {
    width: auto;
    min-height: 38px;
    padding: 0 12px;
    background: transparent;
    color: var(--blue);
    font-weight: 850;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 30;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--text);
    color: #ffffff;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (min-width: 720px) {
    .content {
        padding: 42px 28px 36px;
    }

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

    .choice-list.categories {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

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

    .modal-backdrop {
        align-items: center;
    }
}

@media (max-width: 860px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 560px) {
    .content {
        padding-left: 14px;
        padding-right: 14px;
    }

    h1,
    .page-title {
        font-size: 1.68rem;
    }

    .hero-value strong {
        font-size: 2.5rem;
    }

    .card,
    .choice-card,
    .hero-card {
        padding: 16px;
    }

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

    .totals-row .metric-block:last-child {
        grid-column: 1 / -1;
    }

    .period-head,
    .entry-row,
    .challenge-head {
        align-items: flex-start;
    }

    .entry-row {
        flex-direction: column;
    }

    .delete-button {
        width: 100%;
    }

    .bottom-nav-wrap {
        padding-left: 8px;
        padding-right: 8px;
    }

    .bottom-nav {
        gap: 5px;
    }

    .nav-item {
        min-height: 50px;
        font-size: 0.66rem;
    }
}
