:root {
    --bg: #f5f7f9;
    --panel: #ffffff;
    --ink: #15202b;
    --muted: #627081;
    --line: #d9e0e7;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --secondary: #314256;
    --danger: #b42318;
    --warning: #f4b740;
    --shadow: 0 18px 40px rgba(21, 32, 43, .09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

button,
input,
textarea {
    font: inherit;
}

textarea,
input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

textarea {
    min-height: 120px;
    padding: 14px;
    resize: vertical;
    line-height: 1.45;
}

input {
    padding: 11px 12px;
}

textarea:focus,
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

.topbar {
    min-height: 86px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px clamp(18px, 4vw, 44px);
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.topbar h1,
.panel h2,
.setup-panel h1,
.setup-panel h2 {
    margin: 0;
    letter-spacing: 0;
}

.topbar h1 {
    font-size: 28px;
}

.eyebrow {
    display: block;
    color: var(--primary);
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.top-actions,
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button {
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    min-height: 42px;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    white-space: nowrap;
}

.button.primary {
    background: var(--primary);
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.secondary,
.button.ghost {
    background: var(--secondary);
}

.button.danger {
    background: var(--danger);
}

.button.compact {
    padding: 8px 12px;
    min-height: 34px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1.15fr) minmax(280px, .85fr);
    gap: 18px;
    padding: 22px clamp(18px, 4vw, 44px) 40px;
    align-items: start;
}

.panel,
.setup-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.composer {
    grid-row: span 2;
}

.history-panel {
    grid-column: 1 / -1;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel h2 {
    font-size: 20px;
}

.accordion {
    padding: 0;
    overflow: hidden;
}

.accordion > summary {
    cursor: pointer;
    list-style: none;
    margin: 0;
    padding: 18px;
    user-select: none;
}

.accordion > summary::-webkit-details-marker {
    display: none;
}

.accordion > summary::after {
    content: "+";
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--primary-dark);
    background: #eef4f4;
    font-weight: 900;
}

.accordion[open] > summary::after {
    content: "-";
}

.accordion > summary .pill,
.accordion > summary strong {
    margin-left: auto;
}

.accordion-body {
    border-top: 1px solid var(--line);
    padding: 18px;
}

.status-text,
.pill {
    color: var(--muted);
    font-size: 13px;
}

.pill {
    min-width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef4f4;
    color: var(--primary-dark);
    font-weight: 800;
}

.composer textarea {
    min-height: 340px;
    margin-bottom: 14px;
    font-size: 18px;
}

.time-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

#countdown-preview {
    font-variant-numeric: tabular-nums;
    font-size: 24px;
    color: var(--primary-dark);
}

.countdown-status {
    margin: -4px 0 14px;
    color: var(--muted);
    font-weight: 800;
    font-size: 14px;
}

.item-list {
    display: grid;
    gap: 10px;
    max-height: 420px;
    overflow: auto;
    padding-right: 2px;
}

.empty-list {
    color: var(--muted);
    font-size: 14px;
}

.list-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfd;
    display: grid;
    gap: 10px;
}

.list-item h3,
.list-item p {
    margin: 0;
}

.list-item h3 {
    font-size: 15px;
}

.item-meta {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.list-item p {
    color: var(--secondary);
    line-height: 1.4;
    white-space: pre-wrap;
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.item-actions .button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.snippet-form {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.block-action {
    margin-bottom: 14px;
}

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

.setup-panel {
    width: min(560px, 100%);
    padding: 26px;
}

.setup-panel.inline {
    margin: 40px auto;
}

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

.notice {
    padding: 12px 14px;
    border-radius: 8px;
    margin: 16px 0;
    font-weight: 700;
}

.notice.success {
    background: #e8f7ef;
    color: #166534;
}

.notice.error {
    background: #feeceb;
    color: #991b1b;
}

.display-body {
    min-height: 100vh;
    overflow: hidden;
    background: #05070a;
    color: #fff;
}

.display-stage {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    padding: clamp(28px, 5vw, 72px);
    gap: 24px;
}

.display-message-wrap {
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.display-message {
    max-width: 96vw;
    max-height: 100%;
    overflow: hidden;
    white-space: pre-wrap;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    font-weight: 850;
    line-height: 1.08;
    letter-spacing: 0;
    text-wrap: balance;
}

.display-message.idle {
    color: #b98500;
    font-weight: 780;
}

.display-message.attention {
    --animate-duration: 850ms;
}

.display-countdown {
    justify-self: center;
    min-width: min(620px, 92vw);
    max-width: 92vw;
    padding: 18px 28px;
    border: 2px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: var(--warning);
    text-align: center;
    font-size: clamp(58px, 9vw, 132px);
    line-height: 1;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    position: relative;
    z-index: 2;
}

.display-countdown.expired {
    animation: expiredCountdownBlink .85s steps(2, start) infinite;
    background: #b42318;
    border-color: #ffb4ae;
    color: #fff;
}

@keyframes expiredCountdownBlink {
    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 rgba(244, 63, 94, 0);
    }

    50% {
        opacity: .35;
        box-shadow: 0 0 34px rgba(244, 63, 94, .65);
    }
}

.hidden {
    display: none;
}

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

    .composer {
        grid-row: auto;
    }
}

@media (max-width: 620px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .top-actions,
    .action-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .time-inputs {
        grid-template-columns: 1fr;
    }

    .display-stage {
        padding: 24px;
    }
}
