body {
    font-size: 18px;
    font-family: 'Georgia', 'Times', serif;
    margin: 0;
    padding: 0;
    transition: background 0.5s ease, color 0.5s ease;
    color: #003366;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
}

/* Style to left-align form labels */
label {
    display: block; /* Ensures the label takes up the full line */
    text-align: left; /* Aligns text to the left */
    margin: 10px 0; /* Adds some vertical spacing for readability */
}

.container {
    background: #ffffff;
    color: #003366;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.2);
    width: 80%;
    margin: 40px auto;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
}

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #1e88e5, #42a5f5);
    animation: header-fade-in 1s ease-in-out;
    text-align: center;
    width: 80%;
    margin: 0 auto;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.sub-header {
    font-size: 1.25rem;
    font-weight: 300;
    color: #e3f2fd;
    text-align: center;
}

.button {
    display: block;
    background-color: #1e88e5;
    color: white;
    padding: 15px;
    margin: 15px auto;
    text-align: center;
    border: none;
    border-radius: 10px;
    width: 80%;
    animation: button-slide-up 0.5s ease;
    cursor: pointer;
    font-size: 1.125rem;
    transition: background-color 0.3s ease;
}

.footer {
    font-size: 0.875rem;
    color: #777777;
    margin-top: 20px;
    text-align: center;
}

input[type="text"], input[type="password"], input[type="email"], input[type="number"] {
    width: 90%;
    padding: 12px;
    margin: 25px auto;
    border: 1px solid #cccccc;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    display: block;
    box-sizing: border-box;
    background-color: #ffffff;
    color: #000000;
}

.error {
    color: red;
    font-size: 1rem;
    margin-top: 20px;
}

textarea {
    width: 90%; /* Matches the width of other input types */
    padding: 12px; /* Consistent padding */
    margin: 25px auto; /* Consistent margin */
    border: 1px solid #cccccc; /* Consistent border */
    border-radius: 5px; /* Consistent border-radius */
    font-size: 1rem; /* Consistent font size */
    transition: border-color 0.3s ease, box-shadow 0.3s ease; /* Consistent transition */
    display: block;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    background-color: #ffffff;
    color: #000000;
    resize: vertical; /* Allows users to resize vertically */
}

textarea:focus {
    border-color: #007bff; /* Consistent border color on focus */
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); /* Consistent focus shadow */
}

.button:hover {
    background-color: #1565c0;
}

#message {
    transition: opacity 1s ease-in-out;
    opacity: 0;
}

.message {
    margin-top: 20px;
    font-size: 1.125rem;
    color: #00796b;
    text-align: center;
    animation: message-fade-in-out 1s ease-out;
}

.fade-in {
    opacity: 1;
}

.fade-out {
    opacity: 0;
}

@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2a3c57, #1e2a3f);
        color: #e0e0e0;
    }

    input {
        background-color: #333333;
        color: #ffffff;
    }

    .container {
        background: #1b263b;
        color: #e0e0e0;
        box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.5);
    }

    .header {
        background: linear-gradient(135deg, #0a3d62, #1e5799);
    }

    .sub-header, .message {
        color: #bbbbbb;
    }

    .button {
        background-color: #0a3d62;
        color: #ffffff;
    }
}

@media (max-width: 600px) {
    .container {
        width: 90%;
        padding: 20px;
    }

    .header {
        width: 90%;
        font-size: 1.8rem;
        padding: 20px;
    }

    .button {
        width: 90%;
        margin-top: 10px;
    }
}

@keyframes header-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes button-slide-up {
    from {
        transform: translateY(20px);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes message-fade-in-out {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

/* ── Inline button variant ─────────────────────────────────────────────────── */
.button-inline {
    display: inline-block;
    width: auto;
    padding: 10px 20px;
    margin: 0;
    font-size: 1rem;
    border-radius: 8px;
}

/* ── Calendar manager row (label + count + button) ──────────────────────────── */
.cal-manager-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 10px 0;
    flex-wrap: wrap;
}

.cal-manager-label {
    font-size: 1rem;
    color: inherit;
}

.cal-account-count {
    font-size: 0.9rem;
    color: #1e88e5;
    font-style: italic;
}

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.cal-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.cal-modal-overlay[hidden] {
    display: none;
}

.cal-modal {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-sizing: border-box;
    color: #003366;
    font-family: 'Georgia', 'Times', serif;
}

.cal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.cal-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #003366;
}

.cal-modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.cal-modal-close:hover {
    color: #333;
}

/* ── Account list ───────────────────────────────────────────────────────────── */
.cal-account-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
    min-height: 20px;
}

.cal-empty-state {
    text-align: center;
    color: #999;
    font-style: italic;
    font-size: 0.95rem;
    padding: 10px 0;
}

.cal-account-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #f0f6ff;
    border: 1px solid #c7ddf5;
    border-radius: 10px;
    padding: 12px 14px;
}

.cal-type-badge {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 20px;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

.cal-badge-icloud    { background: #1e88e5; }
.cal-badge-google    { background: #43a047; }
.cal-badge-microsoft { background: #5e35b1; }
.cal-badge-webdav    { background: #607d8b; }

.cal-account-info {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    color: #003366;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-account-sub {
    font-size: 0.78rem;
    color: #666;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-remove-btn {
    background: none;
    border: 1px solid #e57373;
    color: #e57373;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.cal-remove-btn:hover {
    background: #e57373;
    color: #fff;
}

/* ── Add account section ────────────────────────────────────────────────────── */
.cal-add-section {
    border-top: 1px solid #d0e4f7;
    padding-top: 18px;
    margin-bottom: 18px;
}

.cal-add-title {
    margin: 0 0 14px 0;
    font-size: 1.1rem;
    color: #1e88e5;
}

.cal-field-label {
    display: block;
    font-size: 0.95rem;
    color: #003366;
    margin-bottom: 10px;
}

.cal-select,
.cal-input {
    display: block;
    width: 100%;
    padding: 9px 11px;
    margin-top: 4px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
    background: #fff;
    color: #000;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cal-select:focus,
.cal-input:focus {
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.18);
    outline: none;
}

.cal-add-error {
    color: #c62828;
    font-size: 0.88rem;
    margin-bottom: 8px;
}

.cal-add-btn {
    margin-top: 6px;
}

/* ── Calendar list inside each account card ─────────────────────────────────── */
.cal-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cal-calendar-section {
    margin-top: 12px;
    border-top: 1px solid #d0e4f7;
    padding-top: 10px;
}

.cal-calendar-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cal-calendar-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5a7fa0;
    flex: 1;
}

.cal-load-btn {
    background: none;
    border: 1px solid #1e88e5;
    color: #1e88e5;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.cal-load-btn:hover:not(:disabled) {
    background: #1e88e5;
    color: #fff;
}

.cal-load-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.cal-load-status {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
}

.cal-load-error {
    color: #c62828;
}

.cal-calendar-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cal-calendar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.9rem;
    color: #003366;
    user-select: none;
}

.cal-calendar-row:hover {
    background: #daeeff;
}

.cal-calendar-checkbox {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #1e88e5;
}

.cal-calendar-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Dark mode ──────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .cal-modal {
        background: #1b263b;
        color: #e0e0e0;
    }

    .cal-modal-header h2 {
        color: #e0e0e0;
    }

    .cal-account-card {
        background: #243447;
        border-color: #2e4a6e;
    }

    .cal-account-info {
        color: #d0e4ff;
    }

    .cal-account-sub {
        color: #90aac8;
    }

    .cal-add-section {
        border-top-color: #2e4a6e;
    }

    .cal-field-label {
        color: #c8ddf0;
    }

    .cal-select,
    .cal-input {
        background: #243447;
        color: #e0e0e0;
        border-color: #3d5a80;
    }

    .cal-account-count {
        color: #64b5f6;
    }

    .cal-calendar-section {
        border-top-color: #2e4a6e;
    }

    .cal-calendar-section-title {
        color: #7eafd0;
    }

    .cal-calendar-row {
        color: #d0e4ff;
    }

    .cal-calendar-row:hover {
        background: #2e4a6e;
    }

    .cal-load-status {
        color: #90aac8;
    }
}