:root {
    /* Colors */
    --bg-base: #0f172a;
    /* Tailwind Slate 900 */
    --bg-panel: rgba(30, 41, 59, 0.7);
    /* Slate 800 */
    --bg-panel-border: rgba(255, 255, 255, 0.1);

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */
    --text-muted: #64748b;
    /* Slate 500 */

    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;

    /* Variables mapping to cron parts */
    --col-1: var(--accent-blue);
    --col-2: var(--accent-purple);
    --col-3: var(--accent-green);
    --col-4: var(--accent-yellow);
    --col-5: var(--accent-red);

    /* Geometry */
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-glass: 0 10px 30px -10px rgba(0, 0, 0, 0.5);

    /* Fonts */
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;

    /* Subtle background grid */
    background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    background-position: center center;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--bg-panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---> Editor Section <--- */
.editor-section {
    position: relative;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.editor-header h2 {
    margin-bottom: 0;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.input-container {
    position: relative;
    margin-bottom: 1.5rem;
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* The actual input floats above the backdrop so we can select/edit */
.cron-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: transparent;
    /* Text color hidden, we see caret and backdrop */
    caret-color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: 0.1em;
    position: relative;
    z-index: 2;
}

/* The backdrop renders the colored syntax */
.input-backdrop {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    pointer-events: none;
    z-index: 1;
    color: var(--text-muted);
    /* default fallback */
    letter-spacing: 0.1em;
    white-space: pre;
    /* preserve spaces exactly */
    overflow: hidden;
}

/* Colored parts injected via JS */
.part-1 {
    color: var(--col-1);
}

.part-2 {
    color: var(--col-2);
}

.part-3 {
    color: var(--col-3);
}

.part-4 {
    color: var(--col-4);
}

.part-5 {
    color: var(--col-5);
}

.part-invalid {
    color: var(--accent-red);
    text-decoration: underline wavy var(--accent-red);
}

.part-macro {
    color: var(--accent-green);
    font-weight: 700;
}

.translation-box {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#translation-text {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.error-message {
    color: var(--accent-red);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: none;
}

/* ---> Breakdown Dials <--- */
.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.breakdown-col {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.breakdown-col:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Colored borders for each column */
#col-minute {
    border-top: 3px solid var(--col-1);
}

#col-hour {
    border-top: 3px solid var(--col-2);
}

#col-day {
    border-top: 3px solid var(--col-3);
}

#col-month {
    border-top: 3px solid var(--col-4);
}

#col-weekday {
    border-top: 3px solid var(--col-5);
}

.col-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.col-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    /* allow breaking for long lists */
    word-break: break-all;
}

.col-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
    /* push to bottom */
}

/* Highlight specific columns for macros */
.macro-active .breakdown-col {
    border-top-color: var(--text-muted);
    opacity: 0.5;
}

.macro-active .breakdown-col:first-child {
    opacity: 1;
    border-top-color: var(--accent-green);
}


/* ---> Bottom Panels <--- */
.bottom-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Next Runs */
.next-runs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.next-runs-list li {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    border-left: 2px solid transparent;
}

.next-runs-list li:first-child {
    border-left-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.run-date {
    color: var(--text-primary);
}

.run-relative {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font-ui);
}

/* Cheat Sheet */
.cheat-table {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}

.cheat-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cheat-row:last-child {
    border-bottom: none;
}

.cheat-row.header {
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.cheat-col code {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    color: var(--text-primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-base);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: var(--shadow-glass);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .input-container {
        font-size: 2rem;
    }

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

    .bottom-panels {
        grid-template-columns: 1fr;
    }

    .cheat-row {
        grid-template-columns: 60px 1fr;
    }

    .cheat-row .cheat-col:nth-child(3) {
        display: none;
    }

    /* Hide example col on very small screens */
}