:root {
    --bg-color: #F0F0F0;
    --text-color: #1A1A1A;
    --clock-face: #FFFFFF;
    --clock-border: #1A1A1A;
    --marker-color: #1A1A1A;

    /* Bauhaus Palette */
    --bauhaus-red: #DA4E55;
    --bauhaus-blue: #1D73C9;
    --bauhaus-orange: #F6B355;

    --hand-hour: var(--bauhaus-blue);
    --hand-minute: var(--bauhaus-orange);
    --hand-second: var(--bauhaus-red);

    --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #F0F0F0;
    --clock-face: #1E1E1E;
    --clock-border: #F0F0F0;
    --marker-color: #F0F0F0;
    --shadow: rgba(0, 0, 0, 0.5);
    /* Colors remain pop on dark, maybe slightly tweaked if needed, but primary Bauhaus usually stands */
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-y: auto;
}

#theme-toggle {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 100;
    background: none;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.2s, background-color 0.2s;
}

#theme-toggle:hover {
    transform: scale(1.1);
    background-color: var(--text-color);
    color: var(--bg-color);
}

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

[data-theme="dark"] .moon {
    display: none;
}

#logo-link {
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.2s;
}

#logo-link:hover {
    opacity: 0.8;
}

#logo {
    height: 40px;
    width: auto;
    display: block;
}

[data-theme="dark"] #logo {
    filter: brightness(1.1);
}

#display-toggle {
    position: absolute;
    top: 2rem;
    left: 2rem;
    /* MOVED TO LEFT */
    z-index: 100;
    background: none;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.2s, background-color 0.2s;
}

#display-toggle:hover {
    transform: scale(1.1);
    background-color: var(--text-color);
    color: var(--bg-color);
}

#display-toggle .digital {
    font-size: 0.7rem;
    font-weight: 700;
}

/* Visibility States for Toggles */
.hidden {
    display: none !important;
}

/* Clock Faces */
.analog-face,
.digital-face {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    background-color: transparent;
    /* Inherit from .clock-face parent */
}

.clock-face {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Prevent content overflow */
    border-radius: 50%;
}

.clock-face {
    /* ... existing props ... */
    overflow: hidden;
    /* Prevent content overflow */
}

.digital-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.digital-time {
    font-size: 5rem;
    /* Large time */
    font-weight: 700;
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.digital-date {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--bauhaus-red);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Layout Adjustments for Digital Mode */
/* When digital is active, we might want different control/timezone spacing?
   No, layout should remain consistent. */

#clock-grid {
    display: grid;
    /* responsive columns: 1 column on mobile, more on desktop */
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 4rem;
    padding: 2rem;
    padding-bottom: 12rem;
    /* Space for FABs */
    width: 100%;
    max-width: 1600px;
    margin: 2rem auto 0;
    justify-content: center;
    align-items: start;
    transition: gap 0.3s ease;
}

/* Extra padding when MCE overlay is active */
#clock-grid.mce-active {
    padding-bottom: 35rem;
}

@media (max-width: 768px) {
    #clock-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1rem;
        padding-bottom: 8rem;
    }
}

/* FAB */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: none;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
}

.fab:hover {
    transform: scale(1.1);
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Clock Card */
.clock-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    width: 100%;
    container-type: inline-size;
}

.home-icon,
.salesforce-icon {
    display: none;
    width: 32px;
    height: 32px;
    color: var(--text-color);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--bauhaus-red);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-icon {
    width: 32px;
    /* Fixed 32px */
    height: 32px;
    stroke: currentColor;
    stroke-width: 2;
}

.clock-card:hover .remove-btn {
    opacity: 1;
}

.clock-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clock-face {
    width: 100%;
    height: 100%;
    background-color: var(--clock-face);
    border-radius: 50%;
    border: 4px solid var(--clock-border);
    position: relative;
    box-shadow: 0 10px 30px var(--shadow);
    flex-shrink: 0;
    transition: background-color 0.5s ease;
}

/* Day/Night specific overrides */
.clock-card.day .clock-face {
    background-color: #FFFFFF;
    border-color: var(--clock-border);
}

.clock-card.day .digital-time {
    color: #1A1A1A;
    /* Dark text on light dial */
}

.clock-card.night .clock-face {
    background-color: #1E1E1E;
    border-color: var(--clock-border);
}

.clock-card.night .digital-time {
    color: #F0F0F0;
    /* Light text on dark dial */
}

/* Ensure markers contrast in night mode if needed */
.clock-card.night .marker::after {
    background-color: #F0F0F0;
}

.clock-card.day .marker::after {
    background-color: #1A1A1A;
}

#timezone-picker {
    position: fixed;
    bottom: 5.5rem;
    right: 2rem;
    width: 300px;
    max-height: 400px;
    background-color: var(--bg-color);
    border: 2px solid var(--text-color);
    border-radius: 8px;
    box-shadow: 0 5px 20px var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 150;
    overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
    transform-origin: bottom right;
}

#notification-toast {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    background-color: var(--bauhaus-red);
    color: white;
    padding: 1rem 1.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 1000;
    box-shadow: 0 8px 24px var(--shadow);
    border-radius: 4px;
    animation: toastSlideIn 0.3s ease-out;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#timezone-picker.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    visibility: hidden;
}

#timezone-search {
    width: 100%;
    padding: 1rem;
    border: none;
    border-bottom: 2px solid var(--text-color);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    outline: none;
}

#timezone-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    max-height: 300px;
}

.timezone-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--shadow);
    transition: background-color 0.1s;
}

.timezone-option:hover {
    background-color: var(--bauhaus-blue);
    color: white;
}

.plus-icon {
    margin-top: -2px;
}

.date-display {
    position: absolute;
    top: 50%;
    right: 15%;
    transform: translateY(-50%);
    font-weight: 700;
    font-size: 5cqi;
    /* Scales with clock width (~5% of size) - reduced from 7cqi */
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 0.6cqi 1.2cqi;
    /* Also scale padding - reduced from 0.8cqi 1.6cqi */
    border-radius: 2px;
    z-index: 5;
}

/* Hands */
.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    border-radius: 2px 2px 0 0;
    z-index: 10;
}

.hour-hand {
    width: 6px;
    height: 25%;
    background-color: var(--hand-hour);
}

.minute-hand {
    width: 4px;
    height: 40%;
    background-color: var(--hand-minute);
    z-index: 11;
}

.second-hand {
    width: 2px;
    height: 45%;
    background-color: var(--hand-second);
    z-index: 12;
}

.second-hand::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background-color: var(--hand-second);
    border-radius: 50%;
}

.center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background-color: var(--text-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    transition: background-color 0.5s ease;
}

.clock-card.night .center-dot {
    background-color: #F0F0F0;
}

.clock-card.day .center-dot {
    background-color: #1A1A1A;
}

#timezone-display,
.timezone-display {
    /* Set by granular rules */
    font-weight: 300;
    font-size: 1.2rem;
    letter-spacing: 1px;
    color: var(--text-color);
    text-transform: uppercase;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    align-items: center;
}

.timezone-details {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.8;
}

/* Markers */
/* Junghans Style Markers: Very thin, long */
.marker {
    position: absolute;
    bottom: 50%;
    left: 50%;
    width: 2px;
    /* Thinner */
    height: 50%;
    transform-origin: bottom center;
    margin-left: -1px;
    /* Center based on width */
    z-index: 1;
}

.marker::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 12%;
    /* Elegant length */
    background-color: var(--marker-color);
    display: block;
}

/* Rotations */
.hour-1 {
    transform: rotate(30deg);
}

.hour-2 {
    transform: rotate(60deg);
}

.hour-3 {
    transform: rotate(90deg);
}

.hour-4 {
    transform: rotate(120deg);
}

.hour-5 {
    transform: rotate(150deg);
}

.hour-6 {
    transform: rotate(180deg);
}

.hour-7 {
    transform: rotate(210deg);
}

.hour-8 {
    transform: rotate(240deg);
}

.hour-9 {
    transform: rotate(270deg);
}

.hour-10 {
    transform: rotate(300deg);
}

.hour-11 {
    transform: rotate(330deg);
}

.hour-12 {
    transform: rotate(0deg);
}

/* Double length for 12, 3, 6, 9 */
.hour-12::after,
.hour-3::after,
.hour-6::after,
.hour-9::after {
    height: 25%;
}

/* Fix Controls Visibility */
.clock-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    z-index: 60;
    flex-shrink: 0;
    min-height: 40px;
}

/* ------------------------------------------------ */
/* GRANULAR SPACING LOGIC (Based on Feedback)       */
/* ------------------------------------------------ */

/* ------------------------------------------------ */
/* GRANULAR SPACING LOGIC (Based on Feedback)       */
/* ------------------------------------------------ */

/* 4+ Clocks (Benchmark "Nice" spacing) */
.clock-controls {
    margin-bottom: 6cqi;
}

.timezone-display {
    margin-top: 6cqi;
}

/* Spacing logic for different clock counts */
@container (min-width: 400px) {
    #clock-grid[data-clock-count="3"] .clock-controls {
        margin-bottom: 6cqi;
    }

    #clock-grid[data-clock-count="3"] .timezone-display {
        margin-top: 6cqi;
    }

    #clock-grid[data-clock-count="2"] .clock-controls {
        margin-bottom: 4cqi;
    }

    #clock-grid[data-clock-count="2"] .timezone-display {
        margin-top: 4cqi;
    }
}



/* Base mobile spacing (smaller margins) */
.clock-controls {
    margin-bottom: 4cqi;
}

.timezone-display {
    margin-top: 4cqi;
}

/* Delete Overlay */
.delete-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
    transition: opacity 0.3s ease;
}

.delete-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
}

.delete-question {
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.delete-actions {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.delete-actions button {
    background: none;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 0.8rem 2rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.delete-actions .confirm-delete:hover {
    background-color: var(--bauhaus-red);
    border-color: var(--bauhaus-red);
    color: white;
}

.delete-actions .cancel-delete:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}


#mce-container {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: max-content;
}

#mce-reset-btn {
    background-color: var(--bauhaus-red);
    color: white;
    border: none;
    padding: 0 1.5rem;
    height: 48px;
    border-radius: 48px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.2s;
    white-space: nowrap;
    animation: slideRightFade 0.3s ease-out;
}

#mce-reset-btn:hover {
    background-color: #b73a3f;
    transform: scale(1.05);
}

@keyframes slideRightFade {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#mce-btn {
    background: var(--bg-color);
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    height: 48px;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px var(--shadow);
}

#mce-btn:hover {
    transform: scale(1.1);
    background-color: var(--text-color);
    color: var(--bg-color);
}

#mce-options-list {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: var(--bg-color);
    border: 2px solid var(--text-color);
    border-radius: 8px;
    list-style: none;
    padding: 0;
    min-width: 240px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 110;
    animation: slideUpFade 0.3s ease-out;
    overflow: hidden;
}

.mce-opt {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    transition: background 0.1s;
    border-bottom: 1px solid var(--shadow);
}

.mce-opt:last-child {
    border-bottom: none;
}

.mce-opt:hover {
    background-color: var(--bauhaus-red);
    color: white;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Inline MCE controls - Absolute to prevent shifting */
#mce-inline-controls {
    position: fixed;
    bottom: 10rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    /* Stack instruction and input */
    align-items: center;
    gap: 0.8rem;
    padding: 1.2rem 2.5rem;
    background-color: var(--bg-color);
    border: 3px solid var(--text-color);
    /* Bolder */
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.mce-instruction {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
    color: var(--bauhaus-blue);
}

.mce-input-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#mce-inline-controls input {
    padding: 0.8rem 1.2rem;
    border: 2px solid var(--text-color);
    background: var(--clock-face);
    color: var(--text-color);
    font-family: inherit;
    font-weight: 500;
    width: 280px;
    border-radius: 4px;
}

#mce-inline-controls button {
    padding: 0.8rem 1.5rem;
    background-color: var(--bauhaus-blue);
    color: white;
    border: none;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

#mce-inline-controls button:hover {
    background: var(--text-color);
    color: var(--bg-color);
}

#mce-inline-controls.hidden {
    display: none !important;
}

/* Get Script Utility */
.get-script-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
}

.get-script-btn {
    background: none;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 0.5rem 1.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 1px;
    border-radius: 48px;
    /* Rounded pill shape */
    transition: all 0.2s;
    opacity: 0.9;
}

.get-script-btn:hover {
    opacity: 1;
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Script Output Panel at bottom */

#script-output {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 80vh;
    background-color: #121212;
    /* Fixed Deep Dark */
    color: #ffffff;
    /* Fixed White */
    padding: 1.5rem 2rem;
    z-index: 1000;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: slideInUp 0.4s cubic-bezier(0, 0, 0.2, 1);
    overflow-y: auto;
}

.script-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.8rem;
}

.script-output-header span {
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 0.8rem;
    color: var(--bauhaus-blue);
}

.script-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

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

.script-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

.script-content {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    background-color: #1e1e1e;
    /* Fixed Darker Grey */
    padding: 0.8rem;
    border-radius: 4px;
    border-left: 3px solid var(--bauhaus-blue);
}

.script-section:nth-child(2) .script-content {
    border-left-color: #f2a600;
}

/* AMPScript Orange */
.script-section:nth-child(3) .script-content {
    border-left-color: var(--bauhaus-red);
}

/* SSJS Red */

code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    flex: 1;
    word-break: break-all;
    white-space: pre-wrap;
    line-height: 1.5;
    color: #e0e0e0;
    /* Fixed Light Grey for code */
}

.copy-btn {
    background-color: var(--bauhaus-blue);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-btn:hover {
    background-color: #3b6bd6;
    transform: translateY(-2px);
}

.copy-btn.copied {
    background-color: var(--bauhaus-red) !important;
}

#close-script-panel {
    background: none;
    border: none;
    color: #ffffff;
    /* Fixed White Close Button */
    font-size: 1.2rem;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s;
}

#close-script-panel:hover {
    transform: scale(1.2) rotate(90deg);
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

#script-output.hidden {
    display: none !important;
}