:root {
    --bg: #0b0f14;
    --panel: #0f1621;
    --text: #e6edf3;
    --muted: #9fb1c3;
    --accent: #7cc4ff;
    --accent-press: #58b0ff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --radius: 14px;
    /* Quality colors for 1..6 cycles */
    --q1: #ff4d4f; /* red - terrible */
    --q2: #fa8c16; /* orange - poor */
    --q3: #fadb14; /* yellow - not too bad */
    --q4: #95de64; /* light green - good */
    --q5: #2fcb72; /* deep green - perfect */
    --q6: #69c0ff; /* blue - maybe too much */
}

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

@supports (height: 100dvh) {
    .app {
        min-height: 100dvh;
    }
}

header {
    text-align: center;
    padding: 32px 16px 0;
    position: relative;
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px;
}

header p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px 16px 48px;
}

.card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 28px 0 28px;
    box-shadow: var(--shadow);
    width: min(520px, 100%);
    margin: 0 auto;
    text-align: center;
}

.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 22px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: var(--accent);
    color: #00192b;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.2px;
    transition: transform 0.06s ease, background 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 6px 18px rgba(124, 196, 255, 0.35);
}

.cta:hover {
    background: #86caff;
}

.cta:active {
    transform: translateY(1px);
    background: var(--accent-press);
}

.cta:focus-visible {
    outline: 2px solid #b6deff;
    outline-offset: 2px;
}

footer {
    padding: 18px 16px 30px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

/* Mode toggle (top-right) */
.mode-toggle {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.mode-toggle__text {
    opacity: 0.9;
}

@media (max-width: 719px) {
    /* Hide the left label "Simple" on narrow/mobile screens */
    .mode-toggle .mode-toggle__text:first-of-type {
        display: none;
    }
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch__slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s ease;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.switch__slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: var(--accent);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
    box-shadow: 0 2px 6px rgba(124, 196, 255, 0.5);
}

.switch input:checked + .switch__slider {
    background: rgba(124, 196, 255, 0.25);
}

.switch input:checked + .switch__slider:before {
    transform: translateX(20px);
}

/* Pre-initialization visual for saved advanced mode to avoid toggle jump */
html.pref-advanced .switch__slider {
    background: rgba(124, 196, 255, 0.25);
}
html.pref-advanced .switch__slider:before {
    transform: translateX(20px);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 1px, 1px);
    border: 0;
}

.result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.result__msg {
    margin: 0;
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover,
.back-link:focus-visible {
    text-decoration: underline;
}

/* Grid of suggested wake times */
.wake-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    padding: 0 16px;
    box-sizing: border-box;
}

@media (min-width: 720px) {
    .wake-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* If only one card is shown (simple mode), make it span all columns */
    .wake-grid.wake-grid--single > * {
        grid-column: 1 / -1;
    }
}

/* Individual time card */
.wake-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow);
}

/* Recommended highlight (5 cycles) */
.wake-card--recommended {
    /* Subtle green-tinted outline glow without changing layout */
    box-shadow: var(--shadow), 0 0 0 3px color-mix(in oklab, var(--q5) 50%, transparent);
}

/* Color-coded variants by cycles */
.wake-card--1 {
    border-color: color-mix(in oklab, var(--q1) 60%, transparent);
    background: linear-gradient(0deg, color-mix(in oklab, var(--q1) 18%, transparent), color-mix(in oklab, var(--q1) 18%, transparent)), rgba(255, 255, 255, 0.03);
}

.wake-card--2 {
    border-color: color-mix(in oklab, var(--q2) 60%, transparent);
    background: linear-gradient(0deg, color-mix(in oklab, var(--q2) 16%, transparent), color-mix(in oklab, var(--q2) 16%, transparent)), rgba(255, 255, 255, 0.03);
}

.wake-card--3 {
    border-color: color-mix(in oklab, var(--q3) 60%, transparent);
    background: linear-gradient(0deg, color-mix(in oklab, var(--q3) 14%, transparent), color-mix(in oklab, var(--q3) 14%, transparent)), rgba(255, 255, 255, 0.03);
}

.wake-card--4 {
    border-color: color-mix(in oklab, var(--q4) 60%, transparent);
    background: linear-gradient(0deg, color-mix(in oklab, var(--q4) 14%, transparent), color-mix(in oklab, var(--q4) 14%, transparent)), rgba(255, 255, 255, 0.03);
}

.wake-card--5 {
    border-color: color-mix(in oklab, var(--q5) 60%, transparent);
    background: linear-gradient(0deg, color-mix(in oklab, var(--q5) 16%, transparent), color-mix(in oklab, var(--q5) 16%, transparent)), rgba(255, 255, 255, 0.03);
}

.wake-card--6 {
    border-color: color-mix(in oklab, var(--q6) 60%, transparent);
    background: linear-gradient(0deg, color-mix(in oklab, var(--q6) 16%, transparent), color-mix(in oklab, var(--q6) 16%, transparent)), rgba(255, 255, 255, 0.03);
}

.wake-time {
    font-size: 22px;
    font-weight: 800;
}

.wake-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.result__title {
    margin: 0 0 6px;
    color: var(--muted);
}


/* Noscript notice */
.noscript-notice {
    background: var(--panel);
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 16px;
    width: min(520px, 100%);
    margin: 0 auto 16px;
    text-align: center;
}

@media (max-width: 719px) {
  /* Compact layout on mobile to help advanced mode fit vertically */
  header h1 { font-size: 22px; }
  main { padding: 16px 8px 24px; }
  .card { padding: 16px 0 16px; }
  .result { gap: 8px; }
  .wake-grid { gap: 8px; padding: 0 12px; }
  .wake-card { padding: 12px; border-radius: 10px; }
  .wake-time { font-size: clamp(18px, 6vw, 20px); }
  .wake-subtitle { font-size: 11px; margin-top: 2px; }
  .back-link { font-size: 14px; }
}

/* Ultra-compact for short viewports */
@media (max-width: 719px) and (max-height: 640px) {
  header h1 { font-size: 20px; }
  .card { padding: 12px 0 12px; }
  .wake-grid { gap: 6px; padding: 0 10px; }
  .wake-card { padding: 10px; border-radius: 9px; }
  .wake-time { font-size: clamp(16px, 5.5vw, 18px); }
  .wake-subtitle { font-size: 10px; }
  .mode-toggle { top: 8px; right: 10px; font-size: 11px; }
}

/* Digital clock styles */
.clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 16px 18px;
}

.clock__time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-feature-settings: "tnum" 1, "ss01" 1;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-align: center;
    font-size: clamp(32px, 12vw, 88px);
    color: var(--text);
    text-shadow: 0 2px 14px rgba(124, 196, 255, 0.18);
}

.clock__date {
    color: var(--muted);
    font-size: clamp(12px, 3.2vw, 16px);
    letter-spacing: 0.3px;
}

/* Space between clock and button */
.clock + .cta {
    margin-top: 8px;
}
