:root {
    /* Dark teal ramp; bright teal is the one accent */
    --bg: #0a1d21;
    --surface: #102a30;
    --surface-weekend: #0e262b;
    --surface-2: #15353c;
    --hover: #1b434c;
    --border: rgb(143 210 210 / 0.12);
    --border-strong: rgb(143 210 210 / 0.22);
    --text: #e4f1f0;
    --text-2: #a9c8c8;
    --muted: #7fa3a4;
    --band: linear-gradient(135deg, #06262b 0%, #0f766e 100%);
    --accent: #2dd4bf;
    --danger: #f08a80;
    --success: #7fd6a4;

    /* spacing scale (0.25rem grid) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.5rem;

    /* Sizes that follow the screen height smoothly instead of jumping at breakpoints */
    --gap: clamp(0.75rem, 2.4dvh, 1.5rem);
    --pad-card: clamp(0.75rem, 2.4dvh, 1.5rem);
    --bar-h: clamp(3rem, 6dvh, 3.5rem);
    --control-h: clamp(2.5rem, 5dvh, 2.75rem);

    --radius: 0.5rem;
    --radius-card: 0.875rem;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --dur: 120ms;
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;

    color-scheme: dark;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
}

/* Home page fits one screen: the calendar absorbs the leftover height */
html:has(body.home) { overflow: hidden; }
body.home {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.band { flex: none; background: var(--band); }
.top-bar,
.band > header { width: 100%; }

h1, h2 { font-weight: 500; }

/* Buttons and inputs */
button {
    cursor: pointer;
    height: 2rem;
    padding: 0 0.75rem;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 0.0625rem solid var(--border);
    border-radius: var(--radius);
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
button:hover { background: var(--hover); border-color: var(--border-strong); }
button:active { transform: scale(0.98); }

button[type="submit"] {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
    font-weight: 500;
}
button[type="submit"]:hover { background: #fff; }

input {
    height: 2.25rem;
    padding: 0 0.75rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 0.0625rem solid var(--border-strong);
    border-radius: var(--radius);
}
input::placeholder { color: var(--muted); }
input:not([type="submit"]) { cursor: text; } /* reset.css makes every input a pointer */
input[type="checkbox"] { height: auto; cursor: pointer; accent-color: var(--accent); }

:focus-visible {
    outline: 0.125rem solid var(--accent);
    outline-offset: 0.125rem;
}

.icon-button {
    width: 2rem;
    padding: 0;
    display: inline-grid;
    place-items: center;
    color: var(--text-2);
    background: transparent;
    border-color: transparent;
}
.icon-button svg { width: 1.125rem; height: 1.125rem; }

/* ---------- Home page ---------- */

.top-bar,
.band > header,
.home-grid {
    max-width: 90rem;
    margin-inline: auto;
    padding-inline: var(--space-4);
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--bar-h);
    border-bottom: 0.0625rem solid var(--border);
}
.top-bar h1 { font-size: 1rem; margin-right: var(--space-2); }
.top-bar a {
    color: var(--text-2);
    text-decoration: none;
    transition: color var(--dur) var(--ease);
}
.top-bar a:hover { color: var(--text); }
.top-bar .hub-label { color: var(--muted); margin-left: auto; }
.top-bar .switch-hub { flex: none; white-space: nowrap; }
.top-bar .hub-name {
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Clock and shortcuts */
.band > header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    padding-block: clamp(0.75rem, 3dvh, 1.5rem) clamp(0.75rem, 2.4dvh, 1.5rem);
}

#date { color: var(--text-2); font-size: 1rem; }
#time {
    font-size: clamp(2rem, 6.5dvh, 3.5rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.flex-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.shortcut { width: 4rem; text-align: center; }
.shortcut a {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin: 0 auto var(--space-2);
    background: var(--surface-2);
    border: 0.0625rem solid var(--border);
    border-radius: 0.75rem;
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.shortcut a:hover { background: var(--hover); border-color: var(--border-strong); }
.shortcut-icon { width: 1.5rem; height: 1.5rem; }
.shortcut-name {
    font-size: 0.75rem;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#shortcut-container > p { color: var(--muted); }

/* Page grid: the calendar leads, weather and today sit beside it */
.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
        "search   search"
        "calendar weather"
        "calendar events";
    gap: var(--gap);
    align-items: start;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding-top: var(--gap);
    padding-bottom: var(--gap);
}

#search { grid-area: search; }
#weather { grid-area: weather; }
#upcoming-events { grid-area: events; }
#calendar {
    grid-area: calendar;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#calendar-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
/* A long list scrolls inside its card, never the page */
#upcoming-events {
    max-height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.event-list { overflow-y: auto; min-height: 0; }

#weather,
#upcoming-events,
#calendar {
    background: var(--surface);
    border: 0.0625rem solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--pad-card);
}

.home-grid h2 { font-size: 1rem; }
#calendar h2 { font-size: clamp(1.125rem, 2.4dvh, 1.25rem); }
#calendar .calendar-heading { margin-bottom: clamp(0.5rem, 1.6dvh, 1rem); }

/* Search */
.searchform { display: flex; gap: var(--space-2); }
.searchform .search { flex: 1; height: var(--control-h); font-size: 1rem; background: var(--surface); }
.searchform button { height: var(--control-h); padding-inline: var(--space-4); }

/* Weather */
.weather-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--space-3);
}
#location { color: var(--muted); }
.weather-details {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "temp cond"
        "temp feels"
        "temp hum";
    column-gap: var(--space-3);
    align-items: center;
    color: var(--text-2);
}
#Tempature { grid-area: temp; font-size: 2.5rem; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
#Condition { grid-area: cond; color: var(--text); }
#feels-like { grid-area: feels; }
#Humidity { grid-area: hum; }
.weather-details p:empty { display: none; }

/* Today */
.events-header { margin-bottom: var(--space-2); }
.event-list > p { color: var(--muted); padding-block: var(--space-2); }
#calendar-body > p { margin-top: var(--space-3); color: var(--text-2); }

/* ---------- Dashboard, login and hubs pages ---------- */

.dashboard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 0.0625rem solid var(--border);
}
.dashboard-nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.dashboard-nav a:hover { text-decoration: underline; }

.dashboard-container {
    max-width: 56.25rem;
    margin: var(--space-5) auto;
    padding: 0 var(--space-4);
}
.dashboard-container section {
    background: var(--surface);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border: 0.0625rem solid var(--border);
    border-radius: var(--radius-card);
}
.dashboard-container h2 { margin-top: 0; }
hr { border: 0; border-top: 0.0625rem solid var(--border); }

#connected-calendars { padding-left: var(--space-4); }
#connected-calendars li { margin-bottom: var(--space-3); }

.google-calendars,
.apple-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0.75rem 0 0 var(--space-4);
}
.google-calendars label,
.apple-options label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

#apple-calendar-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 28.125rem;
}
#apple-calendar-form div { display: flex; flex-direction: column; gap: var(--space-1); }
#apple-calendar-error { color: var(--danger); }
#apple-calendar-success { color: var(--success); }

/* ---------- Mobile ---------- */
@media (max-width: 48rem) {
    .top-bar,
    .band > header,
    .home-grid { padding-inline: var(--space-3); }

    .top-bar { gap: 0.75rem; }
    .top-bar .hub-label { display: none; }
    .top-bar .hub-name { margin-left: auto; color: var(--text-2); }

    .band > header {
        flex-wrap: nowrap;
        align-items: center;
        gap: var(--space-3);
    }
    #date { font-size: 0.875rem; }
    #time { font-size: clamp(1.75rem, 5dvh, 2.5rem); }
    /* many shortcuts slide sideways instead of pushing the page down */
    #shortcut-container { flex-wrap: nowrap; overflow-x: auto; min-width: 0; gap: 0.75rem; }
    .shortcut { flex: none; width: 3rem; }
    .shortcut a { width: 2.5rem; height: 2.5rem; margin-bottom: 0.25rem; border-radius: 0.625rem; }
    .shortcut-name { font-size: 0.6875rem; }

    .home-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "search   search"
            "calendar calendar"
            "events   weather";
        gap: clamp(0.5rem, 1.6dvh, 0.75rem);
        padding-block: clamp(0.5rem, 1.6dvh, 0.75rem);
    }
    #upcoming-events,
    #weather { align-self: stretch; height: clamp(6.5rem, 17dvh, 9rem); }
    .weather-header,
    .events-header { margin-bottom: 0.5rem; }
    .weather-details { column-gap: 0.75rem; font-size: 0.75rem; }
    #Tempature { font-size: 1.75rem; }
    .today-event { font-size: 0.75rem; padding: 0.25rem 0; }
    .today-event .event-time { min-width: 3.75rem; }

    #weather,
    #upcoming-events,
    #calendar { padding: clamp(0.75rem, 1.6dvh, 1rem); }

    /* Sunday -> S, Monday -> M. No HTML change needed */
    .home-grid .days-title div { font-size: 0; padding: 0 0 0.5rem; text-align: center; }
    .home-grid .days-title div::first-letter { font-size: 0.75rem; }

    /* Cells show dots only; tapping a day lists its events below */
    /* .home-grid prefix: calendar.css loads after this file */
    .home-grid .day { min-height: 0; padding: 0.25rem; text-align: center; }
    .home-grid .day-num { display: flex; width: 1.5rem; margin: 0 auto 0.25rem; }
    .home-grid .day-event { display: inline-flex; padding: 0; margin: 0 0.0625rem; font-size: 0; }
    .home-grid .day-event .dot { margin: 0; width: 0.375rem; height: 0.375rem; }
    .home-grid .day-more { display: none; }
}
