*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0e0e18;
    color: #e8eaf0;
    line-height: 1.5;
}

:focus-visible {
    outline: 2px solid #4da3ff;
    outline-offset: 2px;
}

.app {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem 2rem;
}

.app__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.app__title {
    margin: 0 0 0.35rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app__subtitle {
    margin: 0;
    color: #9aa0b4;
    font-size: 0.95rem;
}

/* Only printed. On screen the semester chips and sidebar already say all this. */
.app__stamp {
    display: none;
}

.app__main {
    flex: 1;
    display: grid;
    grid-template-columns: 20rem minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    max-width: 75rem;
    width: 100%;
    margin: 0 auto;
}

@media (max-width: 860px) {
    .app__main {
        grid-template-columns: 1fr;
    }
}

/* ---------- sidebar ---------- */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1rem;
}

@media (max-width: 860px) {
    .sidebar {
        position: static;
    }
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    background: #12121c;
    border-radius: 8px;
    padding: 0.3rem;
}

.chip {
    padding: 0.4rem 0.7rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #9aa0b4;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.chip:hover {
    color: #e8eaf0;
}

.chip[aria-checked="true"] {
    background: #2a3a52;
    color: #e8eaf0;
}

.search {
    position: relative;
}

.search__results {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    max-height: 18rem;
    overflow-y: auto;
    background: #1a1a28;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.search__results li {
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: baseline;
}

.search__results li:hover,
.search__results li[data-active="true"] {
    background: #2a3a52;
}

.search__results .search__code {
    font-weight: 600;
    white-space: nowrap;
}

.search__results .search__meta {
    color: #9aa0b4;
    font-size: 0.78rem;
    white-space: nowrap;
}

.search__results li[data-added="true"] {
    opacity: 0.5;
}

.search__results li[data-added="true"] .search__meta {
    color: #6b9fd4;
}

/* Not selectable: these rows explain the list, they are not in it. */
.search__notice {
    padding: 0.5rem 0.65rem;
    color: #6b7280;
    font-size: 0.8rem;
    cursor: default;
}

.search__notice:hover {
    background: none;
}

.field {
    display: block;
    margin-bottom: 0.75rem;
}

.field__label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #b8bcc8;
}

.field__input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: #12121c;
    color: #e8eaf0;
    font: inherit;
    font-size: 0.95rem;
    transition: border-color 0.15s;
}

.field__input::placeholder {
    color: #6b7280;
}

.field__input:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

.field__input:focus {
    outline: none;
    border-color: #4da3ff;
}

.picks {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar__empty {
    color: #6b7280;
    font-size: 0.88rem;
    margin: 0;
}

.pick {
    background: #1a1a28;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--pick-color, #3b82c4);
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
}

/* Still listed, but the semester filter is keeping it off the grid. */
.pick--filtered {
    opacity: 0.55;
}

.pick__note {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: #9aa0b4;
}

.pick__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.pick__code {
    font-weight: 600;
    font-size: 0.98rem;
}

.pick__offered {
    margin-left: 0.4rem;
    font-size: 0.72rem;
    color: #9aa0b4;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
}

.pick__remove {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    line-height: 1;
}

.pick__remove:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

.stream {
    margin-top: 0.5rem;
}

.stream__label {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa0b4;
    margin: 0 0 0.3rem;
}

.seg {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.seg button {
    padding: 0.3rem 0.55rem;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: transparent;
    color: #9aa0b4;
    font: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.seg button:hover {
    color: #e8eaf0;
}

.seg button[data-selected="true"] {
    background: #2a3a52;
    border-color: #2a3a52;
    color: #e8eaf0;
}

.venues {
    margin-top: 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.venue-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: #b8bcc8;
}

.venue-row select {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.45rem;
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: #12121c;
    color: #e8eaf0;
}

.custom {
    background: #1a1a28;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
}

.custom summary {
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    color: #b8bcc8;
}

.custom form {
    margin-top: 0.85rem;
}

.custom__row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
}

@media (max-width: 480px) {
    .custom__row {
        grid-template-columns: 1fr;
    }
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.actions__hint {
    margin: -0.1rem 0 0.15rem;
    font-size: 0.78rem;
    color: #6b7280;
}

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

.actions__row .btn {
    flex: 1;
}

.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s, color 0.15s;
}

.btn--full {
    width: 100%;
}

.btn--primary {
    background: #3b82c4;
    color: #fff;
}

.btn--primary:hover:not(:disabled) {
    background: #4da3ff;
}

.btn--ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #b8bcc8;
}

.btn--ghost:hover {
    color: #e8eaf0;
    border-color: rgba(255, 255, 255, 0.28);
}

.btn--danger {
    background: transparent;
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #f87171;
}

.btn--danger:hover {
    background: rgba(248, 113, 113, 0.1);
}

/* ---------- board ---------- */

.board {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.clash-banner {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
}

.clash-banner strong {
    color: #fecaca;
}

.clash-banner ul {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
}

.grid-wrap {
    background: #1a1a28;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    overflow-x: auto;
}

.grid {
    display: grid;
    grid-template-columns: 3.4rem repeat(5, minmax(8.5rem, 1fr));
    gap: 0.4rem;
    min-width: 46rem;
}

.grid__day {
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: #b8bcc8;
    padding-bottom: 0.35rem;
}

.grid__axis {
    position: relative;
    font-size: 0.72rem;
    color: #6b7280;
}

.grid__axis span {
    position: absolute;
    transform: translateY(-50%);
    right: 0.35rem;
}

.grid__col {
    position: relative;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.04) 0,
            rgba(255, 255, 255, 0.04) 1px,
            transparent 1px,
            transparent var(--hour-px)
        );
    border-radius: 6px;
}

.block {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 7px;
    padding: 0.35rem 0.5rem;
    font-size: 0.74rem;
    line-height: 1.3;
    overflow: hidden;
    border-left: 3px solid var(--block-color);
    background: color-mix(in srgb, var(--block-color) 16%, #14141f);
    transition: filter 0.15s;
}

.block:hover {
    filter: brightness(1.2);
}

.block__code,
.block__venue {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.block__code {
    font-weight: 600;
    font-size: 0.78rem;
}

.block__venue {
    color: #c3c8d4;
}

/* Three or more at once leaves no room for a venue. The code wins. */
.block--tight {
    padding: 0.25rem 0.3rem;
}

.block--tight .block__code {
    font-size: 0.68rem;
    white-space: normal;
}

.block--tight .block__venue {
    display: none;
}

.block--clash {
    outline: 2px solid #ef4444;
    outline-offset: -1px;
}

.board__empty {
    text-align: center;
    color: #6b7280;
    font-size: 0.9rem;
    margin: 2rem 0;
}

.app__footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.85rem;
}

.app__source {
    max-width: 34rem;
    margin: 0 auto 0.5rem;
    color: #6b7280;
    font-size: 0.8rem;
}

.app__footer a {
    color: #6b9fd4;
    text-decoration: none;
}

.app__footer a:hover {
    text-decoration: underline;
}

.toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a28;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #e8eaf0;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 50;
}

.toast[data-show="true"] {
    opacity: 1;
}

/* ---------- print / PDF ---------- */

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    body {
        background: #fff;
        color: #111;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .sidebar,
    .clash-banner,
    .app__subtitle,
    .app__footer,
    .board__empty,
    .toast {
        display: none !important;
    }

    .app__stamp {
        display: block;
        margin: 0;
        color: #444;
        font-size: 10pt;
    }

    .app,
    .app__main {
        display: block;
        padding: 0;
        max-width: none;
    }

    .app__header {
        margin-bottom: 3mm;
    }

    .app__title {
        font-size: 15pt;
    }

    .grid-wrap {
        background: #fff;
        border: 1px solid #bbb;
        overflow: visible;
        padding: 4mm;
    }

    .grid {
        min-width: 0;
    }

    .grid__day {
        color: #222;
    }

    .grid__axis {
        color: #666;
    }

    .grid__col {
        background:
            repeating-linear-gradient(
                to bottom,
                #ccc 0,
                #ccc 1px,
                transparent 1px,
                transparent var(--hour-px)
            );
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .block {
        padding: 0.2rem 0.35rem;
        line-height: 1.25;
        background: color-mix(in srgb, var(--block-color) 22%, #fff);
        color: #111;
        border-left-color: var(--block-color);
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .block__venue {
        color: #333;
    }
}
