:root {
    --bg: #eef3f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #1e9f74;
    --primary-dark: #16825d;
    --warn: #f97316;
    --danger: #ef4444;
    --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Manrope", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.page {
    max-width: 980px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
}

.back-link {
    text-decoration: none;
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 8px 14px;
    border-radius: 999px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.back-link:hover {
    color: var(--text);
    border-color: var(--primary);
}

.alarm-card {
    background: var(--card);
    border-radius: 16px;
    padding: 28px 28px 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.clock-section {
    text-align: center;
    padding: 12px 0 18px;
}

.clock-time {
    font-size: clamp(40px, 6vw, 72px);
    font-weight: 700;
    display: inline-flex;
    align-items: flex-end;
    gap: 14px;
}

.clock-period {
    font-size: clamp(18px, 2vw, 28px);
    color: var(--muted);
    padding-bottom: 8px;
}

.clock-date {
    color: var(--muted);
    margin-top: 8px;
}

.alarm-summary {
    margin-top: 16px;
    font-weight: 600;
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 18px 0;
}

.next-alarm {
    text-align: center;
    display: grid;
    gap: 6px;
    justify-items: center;
}

.next-time {
    font-size: 28px;
    font-weight: 600;
}

.next-label {
    color: var(--muted);
}

.set-alarm {
    text-align: center;
    margin-top: 6px;
}

.set-alarm h3,
.alarm-list h3 {
    font-size: 18px;
    margin-bottom: 14px;
}

#alarm-form {
    display: grid;
    gap: 14px;
    justify-items: center;
}

.time-selectors {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-selectors select {
    min-width: 80px;
}

select,
input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: #f8fafc;
    color: var(--text);
}

#alarm-label {
    width: min(520px, 100%);
}

.sound-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-actions {
    display: flex;
    gap: 12px;
}

.btn {
    border: none;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

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

.btn.ghost {
    background: #f8fafc;
    color: var(--text);
}

.btn.warn {
    background: var(--warn);
    color: white;
}

.btn.stop {
    background: var(--danger);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.alarm-list {
    margin-top: 22px;
}

.alarm-items {
    display: grid;
    gap: 10px;
}

.alarm-items .empty {
    text-align: center;
    color: var(--muted);
}

.alarm-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #f8fafc;
}

.alarm-info {
    display: grid;
    gap: 4px;
}

.alarm-info span {
    color: var(--muted);
    font-size: 13px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.toggle input {
    width: 42px;
    height: 22px;
    appearance: none;
    background: #d1d5db;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    outline: none;
}

.toggle input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.toggle input:checked {
    background: #a7f3d0;
}

.toggle input:checked::after {
    transform: translateX(20px);
}

.delete-button {
    background: transparent;
    border: none;
    color: var(--danger);
    font-weight: 600;
    cursor: pointer;
}

.footer {
    text-align: center;
    margin-top: 24px;
    color: var(--muted);
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
}

.overlay.hidden {
    display: none;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
}

.modal h2 {
    color: var(--danger);
    margin-bottom: 10px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

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

    .alarm-card {
        padding: 22px;
    }

    .alarm-item {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .form-actions {
        width: 100%;
    }

    .form-actions .btn {
        flex: 1;
    }
}

@media (max-width: 520px) {
    .page {
        padding: 24px 16px 36px;
    }

    .time-selectors {
        flex-wrap: wrap;
        justify-content: center;
    }

    .sound-row {
        flex-direction: column;
    }
}
