:root {
    color-scheme: light;

    --bg: #f4f3ef;
    --surface: #ffffff;
    --surface-soft: #ebe9e2;
    --text: #1e2521;
    --muted: #6c756f;
    --border: #dcded9;

    --accent: #37624a;
    --accent-strong: #254c37;
    --accent-soft: #dce9e0;

    --warm: #8a6545;
    --warm-soft: #efe4d8;

    --shadow:
        0 12px 36px rgba(22, 31, 25, 0.07);

    --radius: 20px;
    --radius-small: 13px;
}

html[data-theme="dark"] {
    color-scheme: dark;

    --bg: #161a18;
    --surface: #202522;
    --surface-soft: #292f2b;
    --text: #eef2ef;
    --muted: #a7b0aa;
    --border: #363d38;

    --accent: #8dc39f;
    --accent-strong: #a8d6b6;
    --accent-soft: #263c2e;

    --warm: #d1a67d;
    --warm-soft: #3c3026;

    --shadow:
        0 12px 36px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;

    background:
        radial-gradient(
            circle at 15% 0%,
            var(--accent-soft),
            transparent 30rem
        ),
        var(--bg);

    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.page-shell {
    width: min(100% - 28px, 960px);
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    padding: 30px 0 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    color: var(--text);
    text-decoration: none;

    font-size: clamp(1.8rem, 6vw, 2.5rem);
    font-weight: 850;
    letter-spacing: -0.045em;
}

.brand-icon {
    font-size: 0.92em;
}

.tagline {
    margin: 2px 0 0;
    color: var(--muted);
}

.icon-button {
    width: 44px;
    height: 44px;

    border: 1px solid var(--border);
    border-radius: 50%;

    background: var(--surface);
    color: var(--text);

    box-shadow: var(--shadow);

    font-size: 1.2rem;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface);

    box-shadow: var(--shadow);
}

.hero-card,
.start-card,
.chart-card,
.category-card {
    padding: 22px;
}

.section {
    margin-top: 34px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 16px;
}

.section-heading h1,
.section-heading h2,
.chart-title h3 {
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.section-heading h1 {
    font-size: 1.6rem;
}

.section-heading h2 {
    font-size: 1.45rem;
}

.chart-title h3 {
    font-size: 1.15rem;
}

.chart-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.eyebrow {
    display: block;
    margin-bottom: 5px;

    color: var(--accent);

    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.muted {
    margin: -4px 0 17px;
    color: var(--muted);
}

.people-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.person-button {
    min-height: 43px;
    padding: 9px 15px;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: var(--surface-soft);
    color: var(--text);

    font-weight: 700;

    transition:
        transform 120ms ease,
        border-color 120ms ease,
        background 120ms ease;
}

.person-button:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--accent);
}

.person-button.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

html[data-theme="dark"] .person-button.selected {
    color: #142018;
}

.person-button.active-person::before {
    content: "🚽 ";
}

.add-person {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;

    margin-top: 20px;
}

input {
    width: 100%;
    min-height: 47px;
    padding: 10px 13px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface);
    color: var(--text);

    outline: none;
}

input:focus {
    border-color: var(--accent);

    box-shadow:
        0 0 0 3px var(--accent-soft);
}

.button {
    min-height: 47px;
    padding: 10px 17px;

    border: 0;
    border-radius: var(--radius-small);

    font-weight: 800;
}

.button.primary {
    background: var(--accent);
    color: #ffffff;
}

html[data-theme="dark"] .button.primary {
    color: #142018;
}

.button.secondary {
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
}

.button.stop {
    background: var(--warm-soft);
    color: var(--warm);
}

.giant {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    width: 100%;
    min-height: 64px;
    margin-top: 18px;

    font-size: 1.2rem;
}

.start-card {
    margin-top: 16px;
}

.field-label {
    display: block;
    margin-bottom: 7px;

    font-weight: 700;
}

.field-label span {
    margin-left: 4px;
    color: var(--muted);

    font-size: 0.82rem;
    font-weight: 500;
}

.active-list {
    display: grid;
    gap: 12px;
}

.active-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 16px;

    padding: 18px;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface);

    box-shadow: var(--shadow);
}

.active-name {
    margin: 0 0 3px;

    font-size: 1.1rem;
    font-weight: 800;
}

.active-meta {
    margin: 0;
    color: var(--muted);

    font-size: 0.88rem;
}

.active-timer {
    display: block;
    margin-top: 5px;

    font-variant-numeric: tabular-nums;

    font-size: clamp(1.45rem, 5vw, 2rem);
    font-weight: 850;
    letter-spacing: -0.04em;
}

.active-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 135px;
}

.stats-heading {
    align-items: flex-start;
}

.range-picker {
    display: flex;
    padding: 3px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface-soft);
}

.range-button {
    min-height: 34px;
    padding: 5px 10px;

    border: 0;
    border-radius: 9px;

    background: transparent;
    color: var(--muted);

    font-size: 0.82rem;
    font-weight: 750;
}

.range-button.active {
    background: var(--surface);
    color: var(--text);

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stat-card {
    min-width: 0;
    padding: 17px;

    border: 1px solid var(--border);
    border-radius: 16px;

    background: var(--surface);
}

.stat-value {
    display: block;

    overflow-wrap: anywhere;

    font-size: clamp(1.25rem, 4vw, 1.8rem);
    font-weight: 850;
    letter-spacing: -0.045em;
}

.stat-label {
    display: block;
    margin-top: 2px;

    color: var(--muted);

    font-size: 0.78rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;

    margin-top: 14px;
}

.chart-card {
    min-width: 0;
}

.bar-chart {
    display: grid;
    gap: 13px;

    margin-top: 20px;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(76px, 0.9fr) minmax(110px, 2fr) auto;
    align-items: center;
    gap: 10px;

    min-width: 0;
}

.bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 0.87rem;
    font-weight: 700;
}

.bar-track {
    height: 11px;

    overflow: hidden;

    border-radius: 999px;

    background: var(--surface-soft);
}

.bar-fill {
    height: 100%;
    min-width: 0;

    border-radius: inherit;

    background:
        linear-gradient(
            90deg,
            var(--accent),
            var(--accent-strong)
        );
}

.bar-value {
    min-width: 42px;

    color: var(--muted);

    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.category-card {
    margin-top: 14px;
}

.category-list {
    display: grid;
    gap: 15px;

    margin-top: 20px;
}

.category-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(100px, 1.5fr) auto;
    align-items: center;
    gap: 12px;
}

.category-label {
    min-width: 0;

    font-size: 0.88rem;
    font-weight: 700;
}

.category-track {
    height: 10px;

    overflow: hidden;

    border-radius: 999px;

    background: var(--surface-soft);
}

.category-fill {
    height: 100%;

    border-radius: inherit;

    background: var(--warm);
}

.category-value {
    min-width: 58px;

    color: var(--muted);

    font-size: 0.8rem;
    text-align: right;
}

.recent-list {
    display: grid;
    gap: 8px;
}

.recent-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;

    padding: 14px 16px;

    border: 1px solid var(--border);
    border-radius: 15px;

    background: var(--surface);
}

.recent-name {
    margin: 0;

    font-weight: 800;
}

.recent-meta {
    margin: 3px 0 0;

    color: var(--muted);
    font-size: 0.82rem;
}

.recent-duration {
    align-self: center;

    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.empty {
    margin: 8px 0 0;
    padding: 18px;

    border: 1px dashed var(--border);
    border-radius: 14px;

    color: var(--muted);

    text-align: center;
}

.site-footer {
    padding: 40px 10px 34px;

    color: var(--muted);

    font-size: 0.82rem;
    text-align: center;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 100;

    max-width: min(380px, calc(100vw - 36px));

    padding: 11px 15px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--text);
    color: var(--bg);

    box-shadow: var(--shadow);

    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);

    transition:
        opacity 150ms ease,
        transform 150ms ease;
}

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

.hidden {
    display: none !important;
}

.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;
}

@media (max-width: 700px) {
    .site-header {
        padding-top: 22px;
    }

    .stats-heading {
        display: block;
    }

    .range-picker {
        width: fit-content;
        margin-top: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .category-row {
        grid-template-columns: minmax(130px, 1.3fr) minmax(80px, 1fr) auto;
    }
}

@media (max-width: 480px) {
    .page-shell {
        width: min(100% - 20px, 960px);
    }

    .hero-card,
    .start-card,
    .chart-card,
    .category-card {
        padding: 18px;
    }

    .add-person {
        grid-template-columns: 1fr;
    }

    .active-card {
        grid-template-columns: 1fr;
    }

    .active-actions {
        min-width: 0;
    }

    .bar-row {
        grid-template-columns: 80px 1fr auto;
        gap: 7px;
    }

    .category-row {
        grid-template-columns: 1fr auto;
    }

    .category-track {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .category-value {
        grid-column: 2;
        grid-row: 1;
    }
}


/* ==========================================================
   POOTIMER V0.1.1
   MOBILE-FIRST POLISH
   ========================================================== */

button,
input {
    touch-action: manipulation;
}

button,
.person-button,
.range-button,
.icon-button {
    -webkit-tap-highlight-color: transparent;
}


/* ----------------------------------------------------------
   TABLET / SMALL DESKTOP
   ---------------------------------------------------------- */

@media (max-width: 760px) {

    .page-shell {
        width: min(100% - 24px, 960px);
    }

    .site-header {
        padding-top: 20px;
        padding-bottom: 20px;
    }

    .brand {
        font-size: 2rem;
    }

    .section {
        margin-top: 28px;
    }

    .stats-heading {
        display: block;
    }

    .range-picker {
        width: 100%;
        margin-top: 14px;
    }

    .range-button {
        flex: 1;
        min-height: 42px;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }
}


/* ----------------------------------------------------------
   PHONE
   ---------------------------------------------------------- */

@media (max-width: 560px) {

    body {
        background:
            radial-gradient(
                circle at 20% 0%,
                var(--accent-soft),
                transparent 22rem
            ),
            var(--bg);
    }

    .page-shell {
        width: calc(100% - 16px);
    }

    .site-header {
        align-items: center;
        padding: 16px 2px 16px;
    }

    .brand {
        gap: 8px;
        font-size: 1.75rem;
    }

    .tagline {
        margin-top: 0;
        font-size: 0.92rem;
    }

    .icon-button {
        flex: 0 0 auto;
        width: 46px;
        height: 46px;
    }


    /* Cards */

    .hero-card,
    .start-card,
    .chart-card,
    .category-card {
        padding: 17px;
        border-radius: 18px;
    }

    .section {
        margin-top: 25px;
    }

    .section-heading {
        margin-bottom: 13px;
    }

    .section-heading h1 {
        font-size: 1.45rem;
    }

    .section-heading h2 {
        font-size: 1.35rem;
    }

    .eyebrow {
        font-size: 0.68rem;
    }


    /* People */

    .people-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .person-button {
        width: 100%;
        min-width: 0;
        min-height: 50px;
        padding: 10px 12px;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }


    /* Add person */

    .add-person {
        grid-template-columns: 1fr;
        gap: 9px;
        margin-top: 17px;
    }

    input {
        min-height: 50px;
        font-size: 16px;
    }

    .add-person .button {
        width: 100%;
        min-height: 50px;
    }


    /* Start panel */

    .start-card {
        margin-top: 12px;
    }

    .giant {
        min-height: 62px;
        margin-top: 14px;
        font-size: 1.12rem;
    }


    /* Active visits */

    .active-list {
        gap: 10px;
    }

    .active-card {
        grid-template-columns: 1fr;
        gap: 13px;

        padding: 17px;
        border-radius: 18px;
    }

    .active-name {
        font-size: 1.05rem;
    }

    .active-timer {
        margin-top: 4px;
        font-size: 2rem;
    }

    .active-actions {
        width: 100%;
        min-width: 0;
    }

    .active-actions .button {
        width: 100%;
        min-height: 52px;
    }


    /* Stats heading */

    .stats-heading {
        display: block;
    }

    .range-picker {
        display: grid;
        grid-template-columns: repeat(3, 1fr);

        width: 100%;
        margin-top: 13px;
    }

    .range-button {
        width: 100%;
        min-height: 42px;
        padding: 6px 4px;
        white-space: nowrap;
    }


    /* Stats 2 x 2 */

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stat-card {
        padding: 14px;
        border-radius: 15px;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .stat-label {
        margin-top: 3px;
        font-size: 0.75rem;
        line-height: 1.25;
    }


    /* Charts */

    .chart-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 10px;
    }

    .bar-chart {
        gap: 12px;
        margin-top: 17px;
    }

    .bar-row {
        grid-template-columns:
            minmax(70px, 0.9fr)
            minmax(80px, 1.8fr)
            auto;

        gap: 7px;
    }

    .bar-label {
        font-size: 0.82rem;
    }

    .bar-value {
        min-width: 38px;
        font-size: 0.76rem;
    }


    /* Categories */

    .category-card {
        margin-top: 10px;
    }

    .category-list {
        gap: 15px;
        margin-top: 17px;
    }

    .category-row {
        grid-template-columns: 1fr auto;
        gap: 7px 10px;
    }

    .category-label {
        font-size: 0.83rem;
        line-height: 1.25;
    }

    .category-value {
        grid-column: 2;
        grid-row: 1;

        min-width: auto;
        font-size: 0.76rem;
    }

    .category-track {
        grid-column: 1 / -1;
        grid-row: 2;
        height: 9px;
    }


    /* Recent visits */

    .recent-list {
        gap: 8px;
    }

    .recent-card {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;

        gap: 10px;
        padding: 13px 14px;
    }

    .recent-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .recent-meta {
        line-height: 1.35;
    }

    .recent-duration {
        white-space: nowrap;
    }


    /* Footer */

    .site-footer {
        padding: 31px 12px 28px;
        line-height: 1.4;
    }


    /* Toast */

    .toast {
        right: 8px;
        bottom: 8px;
        left: 8px;

        max-width: none;

        text-align: center;
    }
}


/* ----------------------------------------------------------
   VERY SMALL PHONES
   ---------------------------------------------------------- */

@media (max-width: 360px) {

    .page-shell {
        width: calc(100% - 12px);
    }

    .brand {
        font-size: 1.55rem;
    }

    .tagline {
        font-size: 0.84rem;
    }

    .hero-card,
    .start-card,
    .chart-card,
    .category-card {
        padding: 15px;
    }

    .people-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        gap: 6px;
    }

    .stat-card {
        padding: 12px;
    }

    .bar-row {
        grid-template-columns: 65px 1fr auto;
    }
}


/* ----------------------------------------------------------
   SAFE AREA – MODERN PHONES
   ---------------------------------------------------------- */

@supports (
    padding-bottom:
        env(safe-area-inset-bottom)
) {
    .site-footer {
        padding-bottom:
            calc(
                28px +
                env(safe-area-inset-bottom)
            );
    }

    .toast {
        bottom:
            calc(
                8px +
                env(safe-area-inset-bottom)
            );
    }
}


/* ==========================================================
   POOTIMER V0.1.2
   SMALL UI POLISH
   ========================================================== */

.add-person-toggle {
    width: 100%;
    min-height: 48px;
    margin-top: 18px;
}

.add-person:not(.hidden) {
    margin-top: 10px;
}


/* ----------------------------------------------------------
   MOBILE – KEEP THE MAIN FLOW SHORT
   ---------------------------------------------------------- */

@media (max-width: 560px) {

    .add-person-toggle {
        min-height: 50px;
        margin-top: 16px;
    }

    .add-person:not(.hidden) {
        margin-top: 9px;
    }


    /* More compact statistics */

    .chart-grid {
        gap: 8px;
        margin-top: 8px;
    }

    .chart-card {
        padding: 15px 16px;
    }

    .chart-title p {
        margin-top: 2px;
    }

    .bar-chart {
        gap: 9px;
        margin-top: 14px;
    }

    .bar-row {
        min-height: 27px;
    }

    .category-card {
        margin-top: 8px;
        padding: 15px 16px;
    }

    .category-list {
        gap: 11px;
        margin-top: 14px;
    }

    .category-row {
        gap: 5px 10px;
    }


    /* Less empty space at the bottom */

    .site-footer {
        padding:
            20px
            12px
            18px;
    }
}


@supports (
    padding-bottom:
        env(safe-area-inset-bottom)
) {
    @media (max-width: 560px) {

        .site-footer {
            padding-bottom:
                calc(
                    18px +
                    env(safe-area-inset-bottom)
                );
        }
    }
}
