:root {
    --bg: #17181c;
    --card: #24262c;
    --card-border: #34363d;
    --text: #eceef1;
    --text-dim: #9a9ea7;
    --accent: #5b8cff;
    --accent-text: #0b0e14;
    --danger: #e5555a;
    --ok: #4caf6d;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

h1, h2, h3 {
    line-height: 1.2;
}

a {
    color: var(--accent);
}

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

button, .btn {
    font: inherit;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 14px 18px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

button:hover, .btn:hover {
    border-color: var(--accent);
}

button.selected, .btn.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

button.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input[type=text], input[type=password], select {
    font: inherit;
    background: var(--bg);
    border: 1px solid var(--card-border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 14px;
    width: 100%;
    outline: none;
}

/* Without this, the browser's own focus ring (often a light/white halo) shows up
   on top of our dark inputs right after picking a value, which read as a stray
   highlight rather than "this is now selected". Our own ring replaces it. */
input[type=text]:focus, input[type=password]:focus, select:focus {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-dim);
    font-size: 0.9em;
}

.field {
    margin-bottom: 16px;
}

.error {
    color: var(--danger);
    margin-bottom: 12px;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.top-nav .who {
    color: var(--text-dim);
    font-size: 0.9em;
}

/* --- Scheduler --- */

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.month-nav h2 {
    margin: 0;
}

.calendar {
    display: grid;
    /* minmax(0, 1fr), not a bare 1fr: a bare 1fr still lets a column's minimum
       content width (e.g. a long name tag that won't wrap) win out over its
       equal share, which is what made some weekday columns wider than others. */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    user-select: none;
}

.calendar .dow {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8em;
    padding-bottom: 4px;
}

.day-cell {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    touch-action: none;
}

.day-cell.outside {
    opacity: 0.35;
}

.day-cell.past {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.day-cell.selecting {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.day-cell.day-unavailable {
    background: #3a2226;
    border-color: var(--danger);
}

.day-cell.full-table {
    background: #1c3226;
    border-color: var(--ok);
}

.day-cell .date-num {
    font-size: 0.85em;
    color: var(--text-dim);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.full-table-badge {
    color: var(--ok);
    font-size: 0.9em;
    line-height: 1;
}

.session-btn {
    margin-left: auto;
    background: none;
    border: none;
    padding: 0 2px;
    font-size: 0.95em;
    line-height: 1;
    color: var(--text-dim);
    cursor: pointer;
    opacity: 0.6;
}

.session-btn:hover {
    opacity: 1;
    border: none;
}

.session-badge {
    background: rgba(91, 140, 255, 0.25);
    color: var(--text);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.72em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.day-cell .names {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    min-height: 0;
}

.name-tag {
    color: var(--text);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.78em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.name-tag.status-available {
    background: rgba(52, 211, 153, 0.55);
    color: #082b1d;
}

.name-tag.status-unavailable {
    background: rgba(248, 113, 113, 0.6);
    color: #3a0a0a;
}

.name-tag.status-no_data {
    background: rgba(154, 158, 167, 0.2);
    color: var(--text-dim);
}

/* Shared by member name tags and the time-range summary below them — both switch to
   an abbreviated form once their own day cell gets too narrow to hold the full text. */
.compact-name {
    display: none;
}

/* Overlap of everyone's marked times for the day, pinned to the bottom of the cell.
   Italic = not everyone in the group has responded yet, so it may still change. */
.time-summary {
    margin-top: auto;
    padding-top: 2px;
    font-size: 0.68em;
    line-height: 1.15;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.time-summary.no-overlap {
    color: var(--danger);
}

.time-summary.incomplete {
    font-style: italic;
}

/*
 * Container queries, not a viewport media query: what actually determines whether text
 * fits is the day cell's own rendered width, not the browser window's. A fixed viewport
 * breakpoint tuned for names was letting the (much longer) time-range text get visibly
 * ellipsis-clipped well before that breakpoint ever kicked in. Each abbreviates at its
 * own threshold since names ("Spencer") need far less room than a full range
 * ("12:00 PM–11:30 PM").
 */
.day-cell {
    container-type: inline-size;
}

@container (max-width: 85px) {
    .day-cell {
        padding: 4px;
    }
    .name-tag {
        font-size: 0.72em;
    }
    .name-tag .full-name {
        display: none;
    }
    .name-tag .compact-name {
        display: inline;
    }
}

/*
 * 95px, not something higher: container queries measure the day cell's *content* box
 * (padding and border excluded), and the page caps at max-width:900px — so even at the
 * widest possible window, that content box can never exceed ~107px. A threshold above
 * that (115px, previously) can never be satisfied, so it was showing the compact form
 * unconditionally, in every browser, regardless of window width.
 */
@container (max-width: 95px) {
    .time-summary .full-name {
        display: none;
    }
    .time-summary .compact-name {
        display: inline;
    }
}

/* --- Modal --- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 10;
}

.modal {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 420px;
}

.time-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

#time-fields {
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px;
    margin: 0 -10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#time-fields:hover {
    border-color: var(--accent);
}

/* The larger ring around the whole panel when a time range is the active choice... */
#time-fields.active {
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* ...plus a highlight on whichever control within it last set the range: After,
   Before, or From+To together as a pair. Both show at once, by design. */
#time-fields select.time-active {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

[hidden] {
    display: none !important;
}
