/* ── Reset & base ─────────────────────────────────────────────────────────── */

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

:root {
    --bg:        #f5f4f0;
    --surface:   #ffffff;
    --border:    #e0ddd6;
    --text:      #1a1a1a;
    --muted:     #6b6860;
    --accent:    #4a7fc1;
    --accent-lt: #7db4e6;
    --danger:    #c0392b;
    --warn:      #e67e22;
    --radius:    12px;
    --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utilities ────────────────────────────────────────────────────────────── */

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

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.65rem 1.4rem;
    border: none; border-radius: 999px;
    font-family: var(--font); font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { opacity: 0.88; }

.btn--ghost {
    background: transparent; color: var(--muted);
    border: 1.5px solid var(--border);
}
.btn--ghost:hover { border-color: var(--muted); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { opacity: 0.88; }

.btn-icon {
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: var(--muted); padding: 4px;
    line-height: 1;
}
.btn-icon:hover { color: var(--text); }

/* ── Login ────────────────────────────────────────────────────────────────── */

.login-screen {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 360px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-logo {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    margin-bottom: 1.8rem;
}
.login-logo img { border-radius: 8px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }

.login-form { display: flex; flex-direction: column; gap: 0.75rem; }

.input-email {
    width: 100%; padding: 0.7rem 1rem;
    border: 1.5px solid var(--border); border-radius: 999px;
    font-family: var(--font); font-size: 1rem; background: var(--bg);
    outline: none; transition: border-color 0.15s;
    text-align: center;
}
.input-email:focus { border-color: var(--accent); }

.login-msg {
    color: var(--muted); margin-bottom: 1rem; line-height: 1.6;
}
.login-msg--error { color: var(--warn); }

.login-back { font-size: 0.9rem; color: var(--muted); }

.dev-link {
    margin-top: 1.2rem; font-size: 0.8rem;
    color: var(--muted); word-break: break-all;
}

/* ── App shell ────────────────────────────────────────────────────────────── */

.app {
    min-height: 100dvh;
    display: flex; flex-direction: column;
    max-width: 480px; margin: 0 auto;
}


.app-main {
    flex: 1;
    display: flex; flex-direction: column;
    gap: 0;
}


/* ── Sections ─────────────────────────────────────────────────────────────── */

section {
    padding: 1.2rem 1.4rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.section-title {
    font-size: 0.8rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--muted); margin-bottom: 0.9rem;
}

/* ── Hours display ────────────────────────────────────────────────────────── */

.section-hours {
    text-align: center;
    padding-top: 1.2rem; padding-bottom: 1rem;
    background: var(--bg);
}


.hours-display {
    font-size: 6rem; font-weight: 800;
    letter-spacing: -0.03em; line-height: 1;
    color: var(--accent);
    margin-bottom: 0.3rem;
}
.hours-display.overdue { color: var(--danger); }

.progress-bar {
    height: 5px; background: var(--border);
    border-radius: 999px; overflow: hidden;
    margin: 0 auto 0.4rem;
    max-width: 240px;
}
.progress-bar__fill {
    height: 100%; background: var(--accent-lt);
    border-radius: 999px;
    transition: width 0.4s ease;
}
.progress-bar__fill.warn { background: var(--warn); }
.progress-bar__fill.danger { background: var(--danger); }

.hours-label {
    font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem;
}

.percent-label {
    font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem;
}

/* ── Slider ───────────────────────────────────────────────────────────────── */

.slider-wrap {
    display: flex; align-items: center; gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.slider-bound {
    font-size: 0.75rem; color: var(--muted); white-space: nowrap;
}

.slider {
    flex: 1;
    -webkit-appearance: none; appearance: none;
    height: 4px; border-radius: 999px;
    background: var(--border);
    outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%; background: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: grab;
}
.slider::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%; background: var(--accent);
    border: none; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-label {
    display: flex;
    gap: 0.2rem;
    font-size: 1.4rem; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', monospace;
    margin-bottom: 1rem;
}
.slider-label .slider-h { flex: 1; text-align: right; }
.slider-label .slider-m { flex: 1; text-align: left; }

.section-log { display: flex; flex-direction: column; }
.section-log .btn { align-self: center; width: 160px; }

.btn--logging, .btn--done { background: var(--muted); cursor: not-allowed; }

/* ── Last session ─────────────────────────────────────────────────────────── */

.section-last { padding: 0.9rem 1.4rem; min-height: 2.8rem; }

.last-display {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.9rem; color: var(--muted);
}
.last-display .undo-btn {
    font-size: 0.8rem; color: var(--muted);
    background: none; border: none; cursor: pointer; padding: 2px 6px;
    border-radius: 4px; transition: background 0.15s;
}
.last-display .undo-btn:hover { background: var(--border); color: var(--text); }

/* ── Stats ────────────────────────────────────────────────────────────────── */

.section-stats {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.stat {
    display: flex; flex-direction: column; gap: 0.15rem;
}
.stat__label { font-size: 0.72rem; color: var(--muted); }
.stat__value { font-size: 1.1rem; font-weight: 700; }

/* ── Reset ────────────────────────────────────────────────────────────────── */

.section-reset { background: var(--bg); border-bottom: none; }

.needle-age {
    font-size: 0.8rem; color: var(--muted); margin-bottom: 0.8rem;
}

.reset-confirm p {
    font-size: 0.9rem; color: var(--muted); margin-bottom: 0.8rem;
}
.reset-confirm__actions { display: flex; gap: 0.6rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 360px) {
    .hours-display { font-size: 2.6rem; }
    .slider-label  { font-size: 1.2rem; }
}

@media (min-width: 481px) {
    html, body { background: var(--border); }
    .app {
        margin-top: 2rem; margin-bottom: 2rem;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        overflow: hidden;
        box-shadow: 0 8px 32px rgba(0,0,0,0.08);
        background: var(--bg);
        min-height: auto;
    }
}
