@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&display=swap");

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(ellipse at 50% -20%, var(--accent-soft), transparent 48%),
        var(--page);
    color: var(--text);
    font-family: "DM Sans", sans-serif;
    transition: background-color 180ms ease, color 180ms ease;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    min-height: 42px;
}

.brand {
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel);
    color: var(--accent);
}

.brand-mark svg {
    width: 21px;
    height: 21px;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.brand-caption,
.eyebrow,
.section-kicker {
    color: var(--muted);
    font-family: "DM Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.13em;
}

.brand-caption {
    margin-top: 2px;
    font-size: 8px;
    letter-spacing: 0.12em;
}

.theme-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    transition: border-color 150ms ease, color 150ms ease;
}

.theme-button:hover,
.test-button:hover,
.button-secondary:hover,
.button-quiet:hover {
    border-color: var(--accent);
    color: var(--text);
}

.theme-icon {
    width: 16px;
    height: 16px;
}

:root:not([data-theme="light"]) .theme-icon-moon {
    display: none;
}

:root[data-theme="light"] .theme-icon-sun {
    display: none;
}

.intro {
    max-width: 670px;
}

.eyebrow {
    margin: 0 0 12px;
}

.intro h1 {
    margin: 0;
    font-size: clamp(36px, 6vw, 58px);
    font-weight: 600;
    letter-spacing: -0.065em;
    line-height: 1.08;
}

.intro h1 span {
    color: var(--accent);
}

.intro-copy {
    max-width: 530px;
    margin: 15px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
}

.workspace {
    align-items: stretch;
}

.panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.timer-panel {
    display: flex;
    min-height: 470px;
    flex-direction: column;
    justify-content: space-between;
    padding: 25px;
}

.settings-panel {
    padding: 25px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-kicker {
    margin: 0 0 7px;
    font-size: 9px;
}

.panel-heading h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.035em;
}

.status-pill {
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-family: "DM Mono", monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
}

/* Menggunakan variabel warna dari thema.css */
.status-pill.is-running {
    border-color: var(--accent-alpha-30);
    background: var(--accent-soft);
    color: var(--accent);
}

.status-pill.is-done {
    border-color: var(--accent-alpha-30);
    color: var(--accent);
}

.timer-stage {
    display: flex;
    min-height: 265px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    padding: 20px 0;
}

.digital-readout {
    display: flex;
    align-items: baseline;
    justify-content: center;
    white-space: nowrap;
    font-family: "DM Mono", monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.075em;
}

.time-main {
    font-size: clamp(39px, 7vw, 65px);
    font-weight: 400;
}

.time-ms {
    color: var(--muted);
    font-size: clamp(17px, 3vw, 24px);
    letter-spacing: -0.06em;
}

.circle-wrap {
    position: relative;
    display: none;
    width: min(230px, 62vw);
    aspect-ratio: 1;
    align-items: center;
    justify-content: center;
}

.timer-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.circle-track,
.circle-progress {
    fill: none;
    stroke-width: 2;
}

.circle-track {
    stroke: var(--ring-track);
}

.circle-progress {
    stroke: var(--accent);
    stroke-dasharray: 615.75;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    transition: stroke-dashoffset 70ms linear;
}

.circle-content {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 4px;
    font-family: "DM Mono", monospace;
    font-variant-numeric: tabular-nums;
}

.circle-label {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 8px;
    letter-spacing: 0.15em;
}

.circle-time {
    font-size: clamp(24px, 4.8vw, 34px);
    letter-spacing: -0.08em;
}

.circle-ms {
    color: var(--muted);
    font-size: 14px;
}

.layout-classic .circle-wrap {
    display: none;
}

.layout-classic .digital-readout {
    display: flex;
}

.layout-circle .circle-wrap {
    display: flex;
}

.layout-circle .digital-readout {
    display: none;
}

.layout-combo .circle-wrap {
    display: flex;
    width: min(190px, 52vw);
}

.layout-combo .digital-readout {
    display: flex;
}

.layout-combo .circle-time {
    font-size: 27px;
}

.timer-footer {
    border-top: 1px solid var(--line-soft);
    padding-top: 18px;
}

.timer-hint {
    min-height: 18px;
    margin: 0 0 15px;
    color: var(--muted);
    font-size: 12px;
}

.timer-actions {
    display: flex;
    gap: 9px;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 15px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition:
        background 150ms ease,
        border-color 150ms ease,
        color 150ms ease,
        opacity 150ms ease;
}

.button svg {
    width: 16px;
    height: 16px;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

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

.button-primary:hover:not(:disabled) {
    filter: brightness(1.06);
}

.button-secondary,
.button-quiet {
    border-color: var(--line);
    background: transparent;
    color: var(--muted);
}

.button-quiet {
    width: 42px;
    padding: 0;
}

.button-quiet svg {
    width: 17px;
    height: 17px;
}

.setting-block {
    min-width: 0;
    margin: 20px 0 0;
    padding: 0;
    border: 0;
}

.setting-label {
    margin-bottom: 10px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

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

.two-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.duration-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
    color: var(--muted);
    font-size: 10px;
}

.duration-field input,
.select-wrap select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    background: var(--input);
    color: var(--text);
    font-size: 13px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.duration-field input {
    padding: 0 11px;
    font-family: "DM Mono", monospace;
    font-size: 15px;
}

.duration-field input:focus,
.select-wrap select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.select-wrap {
    position: relative;
    display: block;
}

.select-wrap select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0 36px 0 11px;
    cursor: pointer;
}

.select-wrap>svg {
    position: absolute;
    top: 50%;
    right: 11px;
    width: 16px;
    height: 16px;
    color: var(--muted);
    pointer-events: none;
    transform: translateY(-50%);
}

.saved-indicator {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 9px;
    white-space: nowrap;
}

.saved-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.sound-description {
    margin: -4px 0 10px;
}

.milestone-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.check-card {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 55px;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--input);
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}

.check-card:has(input:checked) {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
    background: var(--accent-soft);
}

.check-card input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.custom-check {
    display: grid;
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    place-items: center;
    border: 1px solid var(--faint);
    border-radius: 4px;
}

.check-card input:checked+.custom-check {
    border-color: var(--accent);
    background: var(--accent);
}

.check-card input:checked+.custom-check::after {
    width: 7px;
    height: 4px;
    border-bottom: 1.5px solid var(--accent-ink);
    border-left: 1.5px solid var(--accent-ink);
    content: "";
    transform: translateY(-1px) rotate(-45deg);
}

.check-card input:focus-visible+.custom-check {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.check-card-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.check-card-copy strong {
    font-size: 10px;
    font-weight: 600;
}

.check-card-copy small {
    color: var(--muted);
    font-size: 8px;
    line-height: 1.25;
}

.sound-options {
    padding-top: 15px;
    border-top: 1px solid var(--line-soft);
}

.sound-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
}

.sound-select-label,
.volume-row label {
    color: var(--muted);
    font-size: 10px;
}

.sound-select-wrap select {
    height: 38px;
    font-size: 11px;
}

.test-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.test-button {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    white-space: nowrap;
    transition: border-color 150ms ease, color 150ms ease;
}

.volume-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 9px;
    margin-top: 14px;
}

.volume-row input {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.volume-row span {
    color: var(--muted);
    font-family: "DM Mono", monospace;
    font-size: 10px;
    text-align: right;
}

.duplicate-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    cursor: pointer;
}

.duplicate-toggle>input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.toggle-track {
    position: relative;
    width: 32px;
    height: 18px;
    flex: 0 0 32px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--input);
    transition: background 150ms ease, border-color 150ms ease;
}

.toggle-track::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
    content: "";
    transition: transform 150ms ease, background 150ms ease;
}

.duplicate-toggle input:checked+.toggle-track {
    border-color: var(--accent);
    background: var(--accent);
}

.duplicate-toggle input:checked+.toggle-track::after {
    background: var(--accent-ink);
    transform: translateX(14px);
}

.duplicate-toggle input:focus-visible+.toggle-track {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.duplicate-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.duplicate-copy strong {
    font-size: 10px;
    font-weight: 600;
}

.duplicate-copy small {
    color: var(--muted);
    font-size: 9px;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 2px;
    color: var(--muted);
    font-size: 10px;
}

.footer-divider {
    margin: 0 4px;
    color: var(--faint);
}

/* Warna timer berubah saat memasuki batas peringatan dan tetap merah saat selesai */
.timer-stage.is-warning .time-main,
.timer-stage.is-warning .time-ms,
.timer-stage.is-warning .circle-time,
.timer-stage.is-warning .circle-ms {
    color: var(--warning);
}

.timer-stage.is-warning .circle-progress {
    stroke: var(--warning);
}

/* Animasi pudar muncul (fade-in / fade-out pulse) */
@keyframes warning-fade-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.28;
    }
}

.timer-stage.is-warning.warning-pulse .time-main,
.timer-stage.is-warning.warning-pulse .time-ms,
.timer-stage.is-warning.warning-pulse .circle-time,
.timer-stage.is-warning.warning-pulse .circle-ms,
.timer-stage.is-warning.warning-pulse .circle-progress,
.timer-stage.is-warning.warning-pulse .overtime-badge {
    animation: warning-fade-pulse 1.1s ease-in-out infinite;
}

/* Span / badge terpisah untuk waktu minus */
.overtime-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--input);
    color: var(--text);
    font-family: "DM Mono", monospace;
    font-variant-numeric: tabular-nums;
    font-size: clamp(14px, 2.5vw, 18px);
    transition: all 180ms ease;
}

.overtime-badge[hidden] {
    display: none !important;
}

.overtime-badge-label {
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--line-soft);
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.overtime-badge-value {
    font-weight: 500;
    letter-spacing: -0.04em;
}

/* Menggunakan variabel warna alpha di sini */
.timer-stage.is-warning .overtime-badge {
    border-color: var(--warning-alpha-40);
    background: var(--warning-alpha-08);
    color: var(--warning);
}

.timer-stage.is-warning .overtime-badge .overtime-badge-label {
    background: var(--warning-alpha-20);
    color: var(--warning);
}

.sub-setting-field {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: var(--panel-raised);
    transition: opacity 150ms ease;
}

.sub-setting-field[hidden] {
    display: none !important;
}

.field-label-sm {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

.option-toggle {
    margin-top: 14px;
}

/* Panel timer memenuhi layar saat fullscreen */
.timer-panel:fullscreen {
    display: flex;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(24px, 5vw, 64px);
    border: 0;
    border-radius: 0;
    background: var(--page);
}

.timer-panel:fullscreen .timer-stage {
    flex: 1;
    min-height: 0;
}

.timer-panel:fullscreen .time-main {
    font-size: clamp(64px, 13vw, 160px);
}

.timer-panel:fullscreen .time-ms {
    font-size: clamp(24px, 4vw, 48px);
}

.timer-panel:fullscreen .circle-wrap {
    width: min(58vh, 58vw);
}

.timer-panel:fullscreen .layout-combo .circle-wrap {
    width: min(42vh, 42vw);
}

.timer-panel:fullscreen .overtime-badge {
    font-size: clamp(22px, 4vw, 42px);
    padding: 12px 28px;
    gap: 14px;
}

.timer-panel:fullscreen .overtime-badge-label {
    font-size: clamp(12px, 1.8vw, 18px);
    padding: 4px 10px;
}

/* Desktop: Panel timer */
@media (min-width: 1024px) {
    .workspace {
        align-items: start;
    }

    .timer-panel {
        position: sticky;
        top: 0;
        height: 100vh;
        align-self: start;
        z-index: 10;
        overflow-y: auto;
        scrollbar-width: thin;
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding-top: 22px;
    }

    .intro {
        margin-top: 38px;
    }

    .intro-copy {
        font-size: 13px;
    }

    .timer-panel,
    .settings-panel {
        padding: 19px;
    }

    .timer-panel {
        min-height: 400px;
    }

    .timer-stage {
        min-height: 230px;
    }

    .milestone-grid {
        gap: 6px;
    }

    .check-card {
        gap: 6px;
        padding: 7px 6px;
    }

    .check-card-copy small {
        font-size: 7px;
    }

    .sound-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .test-btn-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .page-footer {
        flex-direction: column;
        padding-top: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}