:root {
    --bg: #f7f7f5;
    --text: #1d232a;
    --muted: #5f6b76;
    --panel: #ffffff;
    --border: #d5dade;
    --work: #26b95b;
    --break: #e8590c;
    --error: #c92a2a;
    --accent: var(--work);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12161a;
        --text: #f1f3f5;
        --muted: #9aa5b1;
        --panel: #1d232a;
        --border: #343d46;
        --work: #40c057;
        --break: #ff7a45;
        --error: #ff6b6b;
    }
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* The whole window, like the maximized Swing frame: round on top, time in the middle, buttons at the bottom */
main {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

main.break {
    --accent: var(--break);
}

.round {
    font-size: clamp(28px, 8vmin, 70px);
    font-weight: 700;
    color: var(--accent);
    margin-top: 4vh;
}

.time {
    flex: 1;
    display: flex;
    align-items: center;
    font-size: min(32vw, 50vh);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

/* The countdown at the end of a round or break (3 or 10 seconds, see the mode) */
.time.ending {
    color: var(--accent);
}

.time.done {
    font-size: min(14vw, 26vh);
    color: var(--accent);
}

.buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

button {
    font: inherit;
    font-weight: 700;
    font-size: clamp(20px, 5vmin, 44px);
    min-width: 6em;
    padding: 0.45em 1em;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
}

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

button:focus-visible {
    outline: 4px solid var(--text);
    outline-offset: 3px;
}

/* Set Time */
dialog {
    width: min(400px, calc(100% - 32px));
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel);
    color: var(--text);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

dialog form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.preview {
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

dialog input {
    width: 140px;
    font: inherit;
    font-size: 28px;
    text-align: center;
    padding: 6px;
    margin-bottom: 12px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
}

dialog input:focus {
    outline: none;
    border-color: var(--accent);
}

dialog button {
    font-size: 20px;
}

.error {
    min-height: 1.3em;
    margin: 0;
    color: var(--error);
    text-align: center;
}

/* Running / Pilates */
.modes {
    display: flex;
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.modes label {
    position: relative;
    padding: 10px 18px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
}

.modes input {
    position: absolute;
    opacity: 0;
}

.modes label:has(input:checked) {
    background: var(--accent);
    color: #fff;
}

.modes label:has(input:focus-visible) {
    outline: 3px solid var(--text);
    outline-offset: -3px;
}

.hint {
    min-height: 1.2em;
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 15px;
    text-align: center;
}
