/* ── Themes ─────────────────────────────────────────── */
:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --transition: background-color 0.4s, color 0.4s;
}

.theme-light {
    --bg:       #f0efea;
    --fg:       #1a1a1a;
    --accent:   #c0392b;
    --panel-bg: rgba(255,255,255,0.92);
}

.theme-dark {
    --bg:       #111111;
    --fg:       #e8e8e8;
    --accent:   #e74c3c;
    --panel-bg: rgba(30,30,30,0.92);
}

.theme-red {
    --bg:       #1a0000;
    --fg:       #ff4444;
    --accent:   #ff6600;
    --panel-bg: rgba(40,0,0,0.92);
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body / App Shell ───────────────────────────────── */
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: var(--transition);
}

/* ── Top Controls ──────────────────────────────────── */
#top-controls {
    position: fixed;
    top: 18px;
    right: 18px;
    display: flex;
    gap: 8px;
    z-index: 200;
}
#theme-toggle, #settings-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity 0.2s;
    padding: 4px;
}
#theme-toggle:hover, #settings-toggle:hover { opacity: 1; }

/* ── Settings Panel ─────────────────────────────────── */
#settings-panel {
    position: fixed;
    top: 66px;
    right: 18px;
    width: 270px;
    background: var(--panel-bg);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(128,128,128,0.15);
    border-radius: 14px;
    padding: 22px;
    z-index: 150;
    color: var(--fg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    transition: opacity 0.25s, transform 0.25s;
}
#settings-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
}
#settings-panel h2 {
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 16px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.55;
}

/* ── Setting Groups ─────────────────────────────────── */
.setting-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.setting-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
}
.setting-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.5;
    margin-bottom: 2px;
}

/* ── Theme Picker ───────────────────────────────────── */
.theme-picker {
    display: flex;
    gap: 8px;
}
.theme-btn {
    flex: 1;
    padding: 7px 4px;
    border: 1.5px solid rgba(128,128,128,0.25);
    border-radius: 8px;
    background: transparent;
    color: var(--fg);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.theme-btn.active {
    border-color: var(--fg);
    background: var(--fg);
    color: var(--bg);
}

/* ── Reset Button ───────────────────────────────────── */
#reset-settings {
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(128,128,128,0.25);
    border-radius: 8px;
    background: transparent;
    color: var(--fg);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}
#reset-settings:hover { background: rgba(128,128,128,0.1); }

.version-tag {
    margin-top: 14px;
    text-align: center;
    font-size: 0.72rem;
    opacity: 0.35;
    letter-spacing: 0.04em;
}
/* ── Stats Section ──────────────────────────────────── */
.stats-section {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(128,128,128,0.15);
    font-size: 0.85rem;
}
.stats-section h3 {
    font-size: 0.8rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.5;
    margin-bottom: 8px;
}
.stats-section p {
    margin-bottom: 5px;
    opacity: 0.7;
}

.nudge-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}
.action-btn {
    display: block;
    text-align: center;
    padding: 9px;
    background: var(--fg);
    color: var(--bg);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.88rem;
    transition: opacity 0.2s;
}
.action-btn:hover { opacity: 0.82; }
.coffee-btn {
    background: #FFDD00;
    color: #000;
    font-weight: 600;
}

/* ── Clock Wrapper ───────────────────────────────────── */
.clock-wrapper {
    position: relative;         /* digital clock positions relative to this */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100dvh;
}

/* ── Analog Clock container ─────────────────────────── */
#analog-clock {
    position: relative;
    width: 50vmin;
    height: 50vmin;
    flex-shrink: 0;
}

#clock-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* ── Digital Overlay (analog + digital both shown) ──── */
#digital-clock {
    position: absolute;
    /* Center horizontally over the analog clock.
       analog = 50vmin wide, centered in viewport.
       So left edge is at 50vw - 25vmin, right at 50vw + 25vmin.
       We position relative to .clock-wrapper. */
    left: 50%;
    top: calc(50% + 50vmin * 0.22);   /* ~lower third of clock face */
    transform: translateX(-50%);
    width: 25vmin;                    /* 50% of 50vmin analog */
    text-align: center;
    font-size: 5vmin;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    color: var(--fg);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
}

/* ── Solo Digital (no analog) ───────────────────────── */
body.no-analog #digital-clock {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    font-size: 25vmin;              /* 25% of smallest viewport dimension */
}

/* ── SVG Elements ───────────────────────────────────── */
.clock-face {
    fill: none;
    stroke: var(--fg);
    stroke-width: 1.5;
}
.hand {
    stroke: var(--fg);
    stroke-linecap: round;
}
.hour-hand   { stroke-width: 3.5; }
.minute-hand { stroke-width: 2; }
.second-hand {
    stroke: var(--accent);
    stroke-width: 1.2;
}
.center-dot  { fill: var(--fg); }
.clock-mark  { stroke: var(--fg); stroke-width: 1; }
.clock-mark-minor { stroke: var(--fg); stroke-width: 0.5; opacity: 0.4; }

/* ── Hidden State ───────────────────────────────────── */
.hidden-component { display: none !important; }
/* ── Timer Dialog ───────────────────────────────────── */
#timer-dialog {
    position: fixed;
    inset: 0;
    background: var(--panel-bg);
    backdrop-filter: blur(14px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#timer-dialog.hidden {
    display: none;
}
.timer-dialog-content {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.timer-duration-input {
    display: flex;
    align-items: center;
    gap: 8px;
}
.timer-duration-input input {
    width: 70px;
    padding: 12px 8px;
    font-size: 2rem;
    text-align: center;
    border: 2px solid var(--fg);
    border-radius: 12px;
    background: transparent;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}
.timer-duration-input input::-webkit-outer-spin-button,
.timer-duration-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.timer-separator {
    font-size: 2rem;
    font-weight: bold;
    color: var(--fg);
}
#timer-start-btn {
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: var(--fg);
    color: var(--bg);
    cursor: pointer;
    transition: opacity 0.2s;
}
#timer-start-btn:hover {
    opacity: 0.85;
}
.timer-recent {
    width: 100%;
}
.timer-recent-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.5;
    margin-bottom: 10px;
    text-align: center;
}
#timer-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.timer-recent-item {
    padding: 8px 14px;
    border: 1px solid rgba(128,128,128,0.3);
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    background: transparent;
    color: var(--fg);
    transition: background 0.2s, border-color 0.2s;
}
.timer-recent-item:hover {
    background: var(--fg);
    color: var(--bg);
}

/* ── Timers Container ───────────────────────────────── */
#timers-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
}

/* ── Timer Bar ──────────────────────────────────────── */
.timer-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    pointer-events: auto;
    cursor: pointer;
    transition: background 0.3s;
}
.timer-bar.paused {
    opacity: 0.7;
}
.timer-elapsed {
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
}
.timer-total {
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: right;
}
.timer-progress {
    flex: 1;
    height: 100%;
    margin: 0 16px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.timer-progress-bg {
    position: absolute;
    inset: 0;
    background: var(--fg);
    opacity: 0.15;
    border-radius: 4px;
}
.timer-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--fg);
    transition: width 0.1s linear, background 0.3s;
}
.timer-bar.warning .timer-progress-fill {
    background: #f1c40f;
}
.timer-bar.overtime .timer-progress-fill {
    background: #e74c3c;
}
.timer-progress-text {
    position: relative;
    z-index: 1;
    font-size: 1.2rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.timer-bar.overtime .timer-progress-text {
    color: #fff;
}
.timer-controls {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 2;
}
.timer-controls.hidden {
    display: none;
}
.timer-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, opacity 0.15s;
}
.timer-control-btn:hover {
    transform: scale(1.1);
}
.timer-play-btn {
    background: var(--fg);
    color: var(--bg);
}
.timer-stop-btn {
    background: #e74c3c;
    color: #fff;
}

/* Timer bar positions */
.timer-bar[data-index="0"] { top: 70px; }
.timer-bar[data-index="1"] { top: 140px; }
.timer-bar[data-index="2"] { top: 210px; }
.timer-bar[data-index="3"] { top: 280px; }
.timer-bar[data-index="4"] { top: 350px; }
.timer-bar[data-index="5"] { top: 420px; }
.timer-bar[data-index="6"] { top: 490px; }
.timer-bar[data-index="7"] { top: 560px; }
.timer-bar[data-index="8"] { top: 630px; }
.timer-bar[data-index="9"] { top: 700px; }
