:root {
    --text: #242424;
    --muted: #777b82;
    --line: #d8dadd;
    --paper: #ffffff;
    --page: #f1f1f1;
    --blue: #428af7;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--page);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
    cursor: pointer;
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: var(--paper);
    color: var(--text);
    padding: 0 11px;
}

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

.stage {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 10px;
}

.hidden {
    display: none !important;
}

.message {
    border: 1px solid var(--text);
    background: var(--paper);
    padding: 12px 14px;
    font-weight: 700;
}

.global-message {
    position: fixed;
    z-index: 20;
    top: 18px;
    left: 50%;
    width: min(720px, calc(100vw - 24px));
    transform: translateX(-50%);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

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

.auth-shell {
    width: min(920px, 100%);
}

.auth-card,
.app-shell {
    background: var(--paper);
    border: 1px solid #cfcfcf;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
}

.auth-card {
    border-radius: 24px;
    overflow: hidden;
}

.auth-header {
    padding: 30px 34px;
    border-bottom: 1px solid var(--line);
}

.auth-header h1 {
    font-size: 3.2rem;
    line-height: 1;
}

.auth-header p {
    color: var(--muted);
    font-size: 1.2rem;
    margin-top: 10px;
}

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

.auth-form {
    display: grid;
    gap: 16px;
    padding: 30px 34px;
}

.auth-form + .auth-form {
    border-left: 1px solid var(--line);
}

.auth-form h2,
.sheet-header h2,
.sheet-section h3 {
    font-size: 1.2rem;
}

.auth-form button,
.sheet button,
.inline-form button {
    min-height: 42px;
    border: 1px solid var(--text);
    background: var(--paper);
    padding: 0 16px;
}

.auth-form button:hover,
.auth-form button:focus-visible,
.sheet button:hover,
.sheet button:focus-visible {
    background: var(--text);
    color: var(--paper);
}

.app-shell {
    width: min(760px, 100%);
    min-height: min(760px, calc(100vh - 20px));
    border-radius: 26px;
    overflow: hidden;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
}

.timer-home {
    min-height: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 42px;
    padding: 54px 28px;
}

.main-timer {
    font-size: 5.7rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.main-timer-button {
    min-width: 220px;
    min-height: 66px;
    border: 3px solid var(--text);
    border-radius: 999px;
    background: var(--paper);
    color: var(--text);
    font-size: 2rem;
    font-weight: 700;
}

.main-timer-button:hover,
.main-timer-button:focus-visible {
    background: var(--text);
    color: var(--paper);
}

.main-timer-button.is-running {
    border-color: var(--text);
    background: var(--text);
    color: var(--paper);
}

.main-timer-button.is-running:hover,
.main-timer-button.is-running:focus-visible {
    background: var(--paper);
    color: var(--text);
}

.sheet {
    border-top: 1px solid var(--line);
    background: #fcfcfc;
    padding: 22px 28px 26px;
    max-height: 54vh;
    overflow: auto;
}

.sheet-header,
.inline-form,
.user-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sheet-header {
    justify-content: space-between;
    margin-bottom: 18px;
}

.sheet-grid,
.stats-grid {
    display: grid;
    gap: 16px;
}

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

.sheet-grid > button {
    align-self: end;
}

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

.date-picker {
    width: 170px;
}

.user-panel {
    flex-wrap: wrap;
    justify-content: flex-end;
    color: var(--muted);
}

.sheet-section {
    display: grid;
    align-content: start;
    gap: 14px;
}

.category-list,
.subcategory-list,
.record-list,
.day-breakdown {
    display: grid;
    gap: 10px;
}

.category-item {
    border-top: 1px solid var(--line);
    padding-top: 12px;
    display: grid;
    gap: 10px;
}

.category-title,
.subcategory-row,
.record-edit-row {
    display: grid;
    gap: 8px;
}

.category-title,
.subcategory-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.subcategory-list {
    margin-left: 18px;
}

.day-breakdown {
    gap: 18px;
}

.empty-day {
    color: var(--muted);
    font-size: 1.1rem;
    font-weight: 700;
}

.category-summary,
.subcategory-summary {
    display: grid;
    gap: 7px;
}

.subcategory-summary {
    margin-left: 22px;
    margin-top: 8px;
}

.summary-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    min-width: 0;
}

.summary-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.category-summary > .summary-line {
    font-size: 1.55rem;
    font-weight: 700;
}

.subcategory-summary .summary-line {
    font-size: 1.25rem;
}

.summary-duration {
    flex: 0 0 auto;
    white-space: nowrap;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: var(--line);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    min-width: 0;
    background: var(--blue);
}

.day-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    color: var(--muted);
    font-size: 1.05rem;
    padding-top: 10px;
}

.metric {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}

.metric span:last-child {
    white-space: nowrap;
}

.metric-icon {
    width: 26px;
    height: 26px;
    border: 3px solid var(--muted);
    border-radius: 50%;
    position: relative;
    flex: 0 0 auto;
}

.clock-icon::before {
    content: "";
    position: absolute;
    width: 3px;
    height: 9px;
    left: 10px;
    top: 5px;
    background: var(--muted);
}

.clock-icon::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 3px;
    left: 7px;
    top: 12px;
    background: var(--muted);
}

.start-icon::before,
.end-icon::before {
    content: "";
    position: absolute;
    width: 10px;
    height: 3px;
    left: 7px;
    top: 11px;
    background: var(--muted);
    transform-origin: right center;
}

.start-icon::before {
    transform: rotate(45deg);
}

.end-icon::before {
    transform: rotate(-45deg);
}

.start-icon::after,
.end-icon::after {
    content: "";
    position: absolute;
    width: 7px;
    height: 7px;
    border-right: 3px solid var(--muted);
    border-bottom: 3px solid var(--muted);
    right: 5px;
    top: 5px;
}

.start-icon::after {
    transform: rotate(45deg);
}

.end-icon::after {
    transform: rotate(-45deg);
    top: 11px;
}

.record-edit-row {
    grid-template-columns: minmax(160px, 1fr) minmax(135px, 0.7fr) minmax(135px, 0.7fr) minmax(140px, 0.9fr) auto auto;
    align-items: end;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.record-meta {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.bottom-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 96px;
    border-top: 1px solid var(--line);
}

.bottom-button {
    border: 0;
    border-left: 1px solid var(--line);
    background: var(--paper);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
}

.bottom-button:first-child {
    border-left: 0;
}

.bottom-button:hover,
.bottom-button:focus-visible,
.bottom-button.is-active {
    background: #f7f7f7;
}

.bottom-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
}

.categories-icon,
.stats-icon {
    position: relative;
}

.categories-icon::before,
.categories-icon::after {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    height: 4px;
    background: var(--text);
    border-radius: 4px;
    box-shadow: 0 10px 0 var(--text), 0 20px 0 var(--text);
}

.categories-icon::before {
    top: 5px;
}

.categories-icon::after {
    display: none;
}

.stats-icon {
    align-items: end;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
}

.stats-icon::before {
    content: "";
    width: 100%;
    height: 11px;
    align-self: end;
    background: var(--text);
    box-shadow: 10px -8px 0 var(--text), 20px -16px 0 var(--text);
}

.add-icon {
    font-size: 2.35rem;
    line-height: 1;
}

@media (max-width: 760px) {
    .stage {
        padding: 0;
        place-items: stretch;
    }

    .auth-card,
    .app-shell {
        min-height: 100vh;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .auth-grid,
    .sheet-grid,
    .record-edit-row {
        grid-template-columns: 1fr;
    }

    .auth-form + .auth-form {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .auth-header h1 {
        font-size: 2rem;
    }

    .timer-home {
        gap: 32px;
        padding: 42px 18px;
    }

    .main-timer {
        font-size: 3.4rem;
    }

    .main-timer-button {
        min-width: 180px;
        min-height: 58px;
        font-size: 1.5rem;
    }

    .sheet {
        max-height: 62vh;
        padding: 18px;
    }

    .sheet-header {
        align-items: stretch;
        flex-direction: column;
    }

    .date-picker {
        width: 100%;
    }

    .category-title,
    .subcategory-row {
        grid-template-columns: 1fr;
    }

    .day-metrics {
        grid-template-columns: 1fr;
    }

    .bottom-bar {
        min-height: 82px;
    }
}
