:root {
    /* Color Palette from emil.codes */
    --bg-gradient-start: #CFEAD9;
    --bg-gradient-end: #B4E2C7;
    --text-primary: #1A1A1A;
    --text-secondary: #4A5D50;
    --accent-primary: #1F4D2B;
    --accent-hover: #14331D;
    --accent-pill-bg: #D8EFE2;
    --accent-pill-text: #2D5A3C;

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: 1px solid rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(31, 77, 43, 0.1);
    --glass-blur: blur(20px) saturate(180%);

    /* Spacing & Layout */
    --radius-lg: 24px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-pill: 9999px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Center vertically too */
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    box-sizing: border-box;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.glass-card:last-child {
    margin-bottom: 0;
}

/* Form Grid & Labels */
.form-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 16px 24px;
    align-items: center;
}

.form-label {
    text-align: right;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-label.align-start {
    align-self: start;
    margin-top: 8px;
    /* Align with input baseline */
}

/* Settings Grid Overrides */
.settings-grid select {
    width: 100%;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 32px 0;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    text-align: center;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    text-align: left;
}

.today-date-layout {
    display: flex;
    gap: 16px;
    align-items: center;
}

.today-day-number {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.today-date-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.today-month-year,
.today-day-name {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Utility to center content in a card */
.card-center {
    align-items: center;
    text-align: center;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.text-secondary {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.today-button {
    font-family: var(--font-family);
    font-size: 1.5rem;
    /* Larger for the crossing */
    font-weight: 500;
    line-height: 1;
    /* Adjust to perfectly center the cross */
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.4);
    border: none;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.2s ease;
}

.today-button.hidden {
    visibility: hidden;
    pointer-events: none;
}

.today-button:hover {
    background: var(--accent-pill-bg);
    color: var(--accent-pill-text);
    transform: translateY(-1px);
}

/* Form Elements */
input[type="date"],
select,
input[type="text"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-family: var(--font-family);
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
    line-height: 1.5;
}

/* Custom arrow for selects */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%234A5D50' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

input[type="date"]:hover,
select:hover {
    background-color: rgba(255, 255, 255, 0.8);
}

input[type="date"]:focus,
select:focus {
    background-color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 77, 43, 0.15);
}

/* Settings Grid */
.settings-grid select {
    width: 100%;
}

.settings-value-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-caption {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    grid-column: 2;
    /* Align with the input field in the grid */
    line-height: 1.4;
}

/* Custom Checkbox */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    vertical-align: middle;
    /* margin-right removed in favor of flex gap in .settings-row.start */
    margin: 0;
    position: relative;
    transition: all 0.2s ease;
}

input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Links */
a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Definition Link */
.definition-link {
    font-size: 0.85em;
    font-weight: 400;
    margin-left: 6px;
    opacity: 0.8;
}

.definition-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Word of the Day Card */
.day-word-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.day-name-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.day-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.day-nature {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.day-explanation {
    font-size: 1rem;
    line-height: 1.5;
    margin: 4px 0 12px 0;
    color: var(--text-primary);
}

.definition-link-button {
    color: var(--accent-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.4);
    font-weight: 500;
    font-size: 0.95rem;
}

.definition-link-button:hover {
    background: var(--accent-pill-bg);
    color: var(--accent-pill-text);
    text-decoration: none;
    transform: translateY(-1px);
}

.definition-link-button::before {
    content: "↗";
    font-size: 1.1em;
}

/* Decimal Time Display */
.decimal-time-display {
    text-align: left;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-family);
    font-size: 3rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.decimal-fraction {
    font-size: 0.6em;
    opacity: 0.7;
}

/* Date Details Grid (Overrides form-grid) */
.date-details-grid {
    align-items: baseline;
    width: 100%;
}

.detail-value {
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .glass-card {
        padding: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .form-label {
        text-align: left;
        margin-top: 12px;
    }

    .date-details-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .app-container {
        padding: 10px;
    }
}

/* Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
    :root {
        /* Dark Palette */
        --bg-gradient-start: #1A2F23;
        --bg-gradient-end: #0F1F15;
        --text-primary: #E0E0E0;
        --text-secondary: #A0B0A5;
        --accent-primary: #4E9F65;
        --accent-hover: #60B67A;
        --accent-pill-bg: rgba(78, 159, 101, 0.2);
        --accent-pill-text: #4E9F65;

        /* Glassmorphism Dark */
        --glass-bg: rgba(0, 0, 0, 0.45);
        --glass-border: 1px solid rgba(255, 255, 255, 0.1);
        --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    }

    /* Checkbox & Inputs */
    input[type="checkbox"] {
        background: rgba(0, 0, 0, 0.4);
        border-color: rgba(255, 255, 255, 0.15);
    }

    input[type="checkbox"]:checked {
        border-color: var(--accent-primary);
        background: var(--accent-primary);
    }

    /* Hover States - Prevent "Flashlight" effect */
    input[type="date"]:hover,
    select:hover,
    input[type="text"]:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }

    /* Input/Select Backgrounds (optional tweak for better integration) */
    input[type="date"],
    select,
    input[type="text"] {
        background: rgba(0, 0, 0, 0.3);
        border-color: rgba(255, 255, 255, 0.15);
        color: var(--text-primary);
    }

    input[type="date"]:focus,
    select:focus {
        background-color: rgba(0, 0, 0, 0.5);
        border-color: var(--accent-primary);
    }

    .today-button {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .today-button:hover {
        background: var(--accent-pill-bg);
        color: var(--accent-primary);
        border-color: var(--accent-primary);
    }

    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%23A0B0A5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
    }
}
