* {
    box-sizing: border-box;
}

[hidden] {
    display: none;
}

body {
    margin: 0;
    font-family: "Nunito", "Trebuchet MS", system-ui, -apple-system, sans-serif;
    background: #eef4f7;
    color: #1f2a33;
}

.page {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 4vw, 32px) 16px;
}

.card {
    width: min(720px, 100%);
    background: #fdfefe;
    border-radius: 28px;
    padding: 34px;
    border: 2px solid #d4e3ea;
    box-shadow: 0 16px 32px rgba(31, 98, 128, 0.12);
    display: grid;
    gap: 20px;
}

.card--create {
    background: linear-gradient(135deg, #fdfefe 0%, #eaf2f6 100%);
    border: 2px solid #c5dbe5;
    gap: 24px;
}

.title {
    margin: 0;
    font-size: 2.2rem;
}

.subtitle {
    margin: 6px 0 0;
    color: #5a7b8c;
}

.create-header {
    display: grid;
    gap: 8px;
}

.badge {
    display: inline-flex;
    width: fit-content;
    padding: 6px 12px;
    border-radius: 999px;
    background: #d8eef4;
    color: #2b6b7e;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    font-size: 0.72rem;
}

.form {
    display: grid;
    gap: 12px;
}

.form--create {
    gap: 18px;
}

.input-group {
    display: grid;
    gap: 8px;
}

.label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2b3a44;
}

.input {
    padding: 12px 14px;
    border-radius: 14px;
    border: 2px solid #c7dae2;
    font-size: 1rem;
    background: #f7fbfd;
}

.input--hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
    padding: 0;
    border: none;
}

.input--picker-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
    padding: 0;
    border: none;
}

.time-picker {
    position: relative;
}

.input--pill {
    border-radius: 999px;
    padding: 14px 18px;
}

.input-stack {
    position: relative;
}

.input--stack {
    width: 100%;
    padding-right: 120px;
}

.input-chip {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #d8eef4;
    color: #2b6b7e;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 999px;
}

/* Hidden native datetime picker is triggered via JS */

.input:focus {
    outline: none;
    border-color: #5aa6bf;
    box-shadow: 0 0 0 3px rgba(90, 166, 191, 0.25);
}

.readonly {
    background: #e8f1f5;
}

.button {
    margin-top: 8px;
    padding: 12px 18px;
    background: #5aa6bf;
    border: none;
    border-radius: 999px;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(37, 108, 134, 0.28);
}

.button--glow {
    box-shadow: 0 14px 26px rgba(37, 108, 134, 0.32);
}

.button:hover {
    background: #4b97b1;
}

.hint {
    font-size: 0.9rem;
    color: #5a7b8c;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.form-error {
    padding: 10px 12px;
    background: #ffe8e3;
    color: #b3544b;
    border-radius: 14px;
    font-weight: 700;
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.link {
    color: #2b6b7e;
    text-decoration: none;
    font-weight: 700;
}

.link--cta {
    background: #5aa6bf;
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 999px;
    box-shadow: 0 8px 16px rgba(37, 108, 134, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}


.focus-label-short {
    display: none;
}

.countdown {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.time-box {
    background: #eef5f8;
    border-radius: 18px;
    padding: clamp(12px, 2vw, 18px);
    text-align: center;
    border: 2px dashed #c1d6df;
}

.time-box--input {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.time-box--input:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(31, 98, 128, 0.2);
}

.time-builder {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.time-picker .time-box {
    width: 100%;
}

.time-value {
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    font-weight: 700;
}

.time-label {
    margin-top: 4px;
    font-size: 0.85rem;
    color: #5a7b8c;
}

.end-time {
    display: grid;
    gap: 6px;
}

.expired-message {
    text-align: center;
    padding: 18px;
    background: #e3f0f6;
    border-radius: 16px;
    animation: pop 0.5s ease-out;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(19, 61, 80, 0.35);
    display: grid;
    place-items: center;
    z-index: 30;
    padding: 16px;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    background: #fdfefe;
    border-radius: 20px;
    padding: 26px;
    width: min(360px, 100%);
    box-shadow: 0 18px 40px rgba(31, 98, 128, 0.2);
    display: grid;
    gap: 12px;
    text-align: center;
    border: 2px solid #c5dbe5;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-text {
    color: #5a7b8c;
}


.expired-emoji {
    font-size: 2rem;
    margin-bottom: 6px;
}

.expired-text {
    font-weight: 600;
}

.is-expired .countdown {
    opacity: 0.35;
}

.is-expired .share {
    display: none;
}

.share {
    display: grid;
    gap: 12px;
}

.focus-mode .share,
.focus-mode .end-time,
.focus-mode .subtitle,
.focus-mode .link,
.focus-mode .header-actions {
    display: none;
}

.focus-mode .title {
    font-size: 1.4rem;
    color: #6f8593;
    margin-bottom: 6px;
}

.focus-mode .countdown {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.focus-mode .time-value {
    font-size: clamp(2.2rem, 5vw, 3.4rem);
}

.focus-mode .card {
    padding: 48px;
}

@media (max-width: 720px) {
    .input--picker-hidden {
        position: absolute;
        inset: 0;
        height: 100%;
        width: 100%;
        opacity: 0.01;
        pointer-events: auto;
        cursor: pointer;
        border-radius: 18px;
        -webkit-appearance: none;
        appearance: auto;
    }

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

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

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

.focus-exit {
    position: fixed;
    right: 20px;
    bottom: 20px;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    background: #5aa6bf;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 12px 22px rgba(37, 108, 134, 0.25);
    cursor: pointer;
    z-index: 40;
}

.focus-mode .focus-exit {
    display: inline-flex;
}

.focus-exit[hidden] {
    display: none;
}

.share-card {
    background: #fdfefe;
    border: 2px solid #c5dbe5;
    border-radius: 18px;
    padding: 14px 16px;
    display: grid;
    gap: 10px;
    box-shadow: 0 10px 22px rgba(31, 98, 128, 0.12);
}

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

.share-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.share-value[hidden] {
    display: none;
}

.share-title {
    font-weight: 700;
    color: #2b3a44;
}

.share-value {
    background: #eef5f8;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #2b3a44;
    word-break: break-all;
}

.chip {
    border: none;
    border-radius: 999px;
    background: #d8eef4;
    color: #2b6b7e;
    font-weight: 700;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chip:hover {
    background: #c6e5ee;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    padding: 2px;
    background: #eef5f8;
    border-radius: 14px;
    border: 1px solid #d4e3ea;
}

.tab-button {
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #4b6a7a;
    font-weight: 700;
    padding: 7px 12px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    text-align: center;
}

.tab-button--active {
    background: #ffffff;
    color: #1f2a33;
    border-color: #d4e3ea;
}

.preset-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tab-panels {
    position: relative;
    min-height: 220px;
}

.duration-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.duration-grid .input {
    width: 100%;
}

.tab-panel {
    display: grid;
    gap: 12px;
    opacity: 0;
    transform: translateY(6px);
}

.tab-panel[hidden] {
    display: none;
}

.tab-panel--active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.flash {
    position: fixed;
    top: 18px;
    right: 18px;
    background: #fdfefe;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(31, 98, 128, 0.2);
    font-weight: 700;
    z-index: 20;
}

.flash-error {
    border-left: 4px solid #c4685d;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 600px) {
    .card {
        padding: 24px;
    }

    .timer-header {
        flex-direction: column;
        position: relative;
    }

    .header-actions {
        position: absolute;
        top: 0;
        right: 0;
    }

    .timer-title-block {
        padding-right: 120px;
    }

    .focus-label {
        display: none;
    }

    .focus-label-short {
        display: inline;
    }

    .link--cta {
        padding: 6px 12px;
        border-radius: 999px;
    }

    .link-text {
        display: inline;
    }
}
