:root {
    --page: #f5f7fa;
    --surface: #ffffff;
    --surface-soft: #eef2f6;
    --text: #18212f;
    --muted: #5f6b7a;
    --border: #d7dee8;
    --blue: #1769aa;
    --green: #14765f;
    --amber: #b36a05;
    --red: #b42318;
    --done: #3f4652;
    --tile: #121923;
    --tile-top: #202b38;
    --focus: #1c75bc;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--page);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

button,
.header-link,
.auth-link {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--text);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

button:hover,
.header-link:hover,
.auth-link:hover {
    filter: brightness(1.05);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
    outline-offset: 2px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 11px 12px;
}

textarea {
    resize: vertical;
    min-height: 240px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.94rem;
}

.login-page {
    background:
        linear-gradient(120deg, rgba(23, 105, 170, 0.16), transparent 38%),
        linear-gradient(300deg, rgba(20, 118, 95, 0.16), transparent 42%),
        var(--page);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(100%, 440px);
    display: grid;
    gap: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 32px;
    box-shadow: 0 20px 50px rgba(24, 33, 47, 0.12);
}

.auth-heading {
    display: grid;
    gap: 4px;
}

.auth-heading p,
.site-header p,
.section-title p,
#stateKicker,
#timerLabel {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.auth-heading h1,
.site-header h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.08;
    overflow-wrap: anywhere;
}

.auth-link {
    background: var(--surface-soft);
    color: var(--text);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header > div:first-child {
    min-width: 0;
}

.site-header span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.header-link {
    background: var(--surface-soft);
    color: var(--text);
}

.timer-shell {
    width: min(1400px, calc(100% - 32px));
    margin: 22px auto 36px;
    display: grid;
    gap: 18px;
    container-type: inline-size;
}

.status-card {
    --state: var(--blue);
    position: relative;
    overflow: hidden;
    display: grid;
    align-items: center;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 440px);
    border-radius: 8px;
    background: var(--state);
    color: #ffffff;
    padding: 32px;
    box-shadow: 0 18px 44px rgba(24, 33, 47, 0.15);
}

.state-blue {
    --state: var(--blue);
}

.state-green {
    --state: var(--green);
}

.state-amber {
    --state: var(--amber);
}

.state-red {
    --state: var(--red);
}

.state-done {
    --state: var(--done);
}

.status-copy {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 8px;
}

#stateKicker,
#timerLabel {
    color: rgba(255, 255, 255, 0.78);
}

.status-copy h2 {
    margin: 0;
    font-size: 3.25rem;
    line-height: 1.05;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.status-copy p:last-child {
    margin: 0;
    max-width: 68ch;
    color: rgba(255, 255, 255, 0.88);
    font-size: 1.1rem;
}

.timer-wrap {
    width: 100%;
    max-width: 440px;
    justify-self: end;
    display: grid;
    align-content: center;
    gap: 12px;
}

.timer-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-width: 0;
}

.time-unit {
    display: grid;
    gap: 7px;
    text-align: center;
}

.time-unit > span:last-child {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.78rem;
    font-weight: 800;
}

.flap {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 104px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background:
        linear-gradient(180deg, var(--tile-top), var(--tile) 50%, #0b1018 50%, #0d131c);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 20px rgba(0, 0, 0, 0.24);
    color: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 4.25rem;
    font-weight: 900;
    line-height: 1;
}

.flap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(0, 0, 0, 0.55);
}

.timer-colon {
    padding-top: 31px;
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
}

.status-footer {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    padding-top: 4px;
}

.status-footer > div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.status-footer span {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-footer strong {
    overflow-wrap: anywhere;
    font-size: 1.1rem;
}

.progress-track {
    grid-column: 1 / -1;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
}

.progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.86);
    transition: width 240ms linear;
}

.instructions-panel,
.admin-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 24px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.section-title span {
    color: var(--muted);
    font-size: 0.92rem;
}

.instructions-content {
    font-size: 1.08rem;
    overflow-wrap: anywhere;
}

.instruction-callout {
    display: grid;
    gap: 10px;
    margin: 0 0 20px;
    border: 2px solid #1769aa;
    border-radius: 8px;
    background: #eef7ff;
    padding: 18px;
}

.instruction-callout h3,
.instruction-callout p {
    margin: 0;
}

.instruction-callout h3 {
    color: #104f83;
    font-size: 1.45rem;
}

.instruction-callout a {
    color: #104f83;
    font-weight: 800;
}

.instructions-content code {
    border-radius: 6px;
    background: #edf1f6;
    padding: 2px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 800;
}

.instructions-content h1,
.instructions-content h2,
.instructions-content h3 {
    margin: 0 0 12px;
    line-height: 1.16;
}

.instructions-content ul,
.instructions-content ol {
    margin: 12px 0 0;
    padding-left: 1.4rem;
}

.instructions-content li + li {
    margin-top: 8px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert-error {
    background: #fff0ed;
    color: #8f1d14;
    border: 1px solid #ffc8bf;
}

.alert-success {
    background: #e9f7f1;
    color: #0f5d49;
    border: 1px solid #bde4d6;
}

.admin-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 26px auto 56px;
    display: grid;
    gap: 18px;
}

.admin-form {
    display: grid;
    gap: 18px;
}

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

.session-list {
    display: grid;
    gap: 16px;
}

.session-editor {
    display: grid;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfe;
    padding: 16px;
}

.editor-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

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

.component-editor {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(190px, 1fr) minmax(120px, 0.5fr) auto;
    gap: 12px;
    align-items: end;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.small-button,
.icon-button {
    min-height: 40px;
    background: var(--surface-soft);
    color: var(--text);
    padding-inline: 13px;
}

.icon-button {
    width: 92px;
}

.danger-button {
    background: #fff0ed;
    color: #8f1d14;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    padding: 14px 0 0;
    background: linear-gradient(180deg, rgba(245, 247, 250, 0), var(--page) 32%);
}

@container (max-width: 1050px) {
    .status-card {
        grid-template-columns: 1fr;
    }

    .timer-wrap {
        max-width: 520px;
        justify-self: stretch;
    }
}

@media (max-width: 1100px) {
    .status-copy h2 {
        font-size: 2.75rem;
    }

    .flap {
        min-height: 92px;
        font-size: 3.55rem;
    }

    .timer-colon {
        padding-top: 27px;
        font-size: 3.35rem;
    }
}

@media (max-width: 900px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px 24px;
    }

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

    .timer-wrap {
        width: 100%;
        max-width: none;
        justify-self: stretch;
    }

    .status-copy h2 {
        font-size: 2.45rem;
    }

    .status-footer,
    .form-grid,
    .editor-heading,
    .component-editor {
        grid-template-columns: 1fr;
    }

    .icon-button {
        width: 100%;
    }
}

@media (max-width: 700px) {
    .auth-heading h1,
    .site-header h1 {
        font-size: 1.6rem;
    }

    .timer-shell,
    .admin-shell {
        width: min(100% - 24px, 1180px);
        margin-top: 16px;
    }

    .status-card,
    .instructions-panel,
    .admin-section {
        padding: 18px;
    }

    .status-copy h2 {
        font-size: 2rem;
    }

    .status-copy p:last-child,
    .status-footer strong,
    .instructions-content {
        font-size: 1rem;
    }

    .instruction-callout h3 {
        font-size: 1.2rem;
    }

    .flap {
        min-height: 76px;
        font-size: 2.75rem;
    }

    .timer-colon {
        padding-top: 22px;
        font-size: 2.65rem;
    }
}

@media (max-width: 520px) {
    .timer-shell,
    .admin-shell {
        width: min(100% - 20px, 1180px);
        margin-top: 14px;
    }

    .site-header {
        padding: 16px;
    }

    .status-card,
    .instructions-panel,
    .admin-section,
    .auth-panel {
        padding: 16px;
    }

    .timer-board {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 6px;
    }

    .flap {
        min-height: 62px;
        font-size: 2.15rem;
    }

    .timer-colon {
        padding-top: 18px;
        font-size: 2rem;
    }
}

@media (max-width: 380px) {
    .status-card {
        gap: 16px;
    }

    .status-copy h2 {
        font-size: 1.7rem;
    }

    .flap {
        min-height: 54px;
        font-size: 1.8rem;
    }

    .timer-colon {
        padding-top: 16px;
        font-size: 1.65rem;
    }
}

@media (max-height: 760px) and (min-width: 901px) {
    .site-header {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .timer-shell {
        margin-top: 16px;
        gap: 14px;
    }

    .status-card {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .status-copy h2 {
        font-size: 2.75rem;
    }
}
