:root {
    color-scheme: dark;
    --accent: 159, 220, 190;
    --bg: #252b32;
    --panel: #30373f;
    --panel-2: #292f36;
    --line: rgba(174, 195, 216, .2);
    --line-strong: rgba(184, 205, 225, .38);
    --text: #edf3f8;
    --muted: #aeb9c5;
    --faint: #7f8c99;
    --sky: #9bc2ed;
    --mint: #a8d9bd;
    --gold: #e6c381;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; min-width: 320px; color: var(--text); background: #252b32; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid rgba(var(--accent), .72); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.collection-shell { width: min(1500px, calc(100% - 32px)); min-height: 100dvh; margin: 0 auto; padding: 18px 0 48px; }
.collection-header { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; align-items: center; min-height: 54px; gap: 12px; }
.icon-button, .status-button {
    display: grid; width: 46px; height: 46px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 7px;
    color: var(--muted); background: rgba(45,53,61,.84); cursor: pointer;
    transition: color 150ms ease, border-color 160ms ease, background 180ms ease, transform 180ms cubic-bezier(.2,.8,.2,1);
}
.icon-button:hover, .status-button:hover { color: var(--text); border-color: var(--line-strong); background: #353d46; transform: translateY(-1px); }
.icon-button svg, .status-button svg { width: 22px; height: 22px; }
.collection-header > .icon-button { color: rgba(193,206,218,.72); border-color: transparent; background: transparent; }
.collection-heading { display: flex; min-width: 0; align-items: center; gap: 11px; }
.collection-heading > svg { width: 27px; height: 27px; color: rgb(var(--accent)); }
.collection-heading div { display: grid; min-width: 0; gap: 1px; }
.collection-heading strong { overflow: hidden; font-size: 1.08rem; text-overflow: ellipsis; white-space: nowrap; }
.collection-heading span { color: var(--faint); font-size: .68rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.collection-search { display: flex; flex-direction: row-reverse; align-items: center; }
.collection-search input { width: 0; height: 46px; padding: 0; opacity: 0; pointer-events: none; color: var(--text); border: 1px solid transparent; border-radius: 7px; background: #242b31; transition: width 240ms cubic-bezier(.2,.8,.2,1), opacity 150ms ease, padding 240ms ease, margin 240ms ease, border-color 180ms ease; }
.collection-search.is-open input { width: min(390px, 36vw); margin-right: 8px; padding: 0 14px; opacity: 1; pointer-events: auto; border-color: var(--line-strong); }

.course-tabs { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 7px; margin-top: 14px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: rgba(42,49,57,.72); }
.course-tab { min-width: 0; min-height: 44px; padding: 7px 10px; overflow: hidden; color: var(--muted); border: 1px solid transparent; border-radius: 6px; background: transparent; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; transition: color 150ms ease, background 170ms ease, border-color 170ms ease; }
.course-tab:hover { color: var(--text); background: rgba(var(--tab-accent), .07); }
.course-tab.is-active { color: var(--text); border-color: rgba(var(--tab-accent), .35); background: rgba(var(--tab-accent), .13); }

.collection-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.collection-summary > div { min-height: 76px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 7px; background: rgba(43,50,58,.66); }
.collection-summary span { display: block; color: var(--faint); font-size: .66rem; text-transform: uppercase; }
.collection-summary strong { display: block; margin-top: 7px; font-size: 1.34rem; font-variant-numeric: tabular-nums; }
.status-controls { display: flex; justify-content: flex-end; gap: 6px; margin: 10px 0; }
.status-button { width: 40px; height: 40px; background: transparent; }
.status-button svg { width: 19px; height: 19px; }
.status-button.is-active { color: #17242e; border-color: transparent; background: rgb(var(--accent)); }

.loading-state, .empty-state { min-height: 48dvh; place-items: center; color: var(--muted); }
.loading-state { display: grid; }
.loading-state span { width: 38px; height: 38px; border: 2px solid rgba(235,243,250,.14); border-top-color: #eff5fa; border-right-color: rgba(var(--accent),.9); border-radius: 50%; box-shadow: 0 0 16px rgba(220,236,248,.08); animation: spin 720ms linear infinite; }
.empty-state { display: grid; }
.empty-state[hidden], .loading-state[hidden], .collection-list[hidden] { display: none; }

.collection-list { display: grid; gap: 20px; }
.week-group { display: grid; gap: 9px; animation: rise-in 300ms cubic-bezier(.2,.8,.2,1) both; }
.week-header { display: flex; align-items: end; justify-content: space-between; min-height: 42px; padding: 0 4px 8px; border-bottom: 1px solid var(--line); }
.week-header h2 { margin: 0; font-size: 1rem; font-weight: 720; }
.week-header span { color: var(--faint); font-size: .72rem; }
.week-sets { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.set-card {
    position: relative; display: grid; min-width: 0; min-height: 190px; padding: 16px; gap: 12px;
    color: var(--text); border: 1px solid var(--line); border-radius: 8px; background: rgba(47,55,63,.74); text-decoration: none;
    transition: transform 180ms cubic-bezier(.2,.8,.2,1), border-color 180ms ease, background 180ms ease;
}
.set-card:hover { transform: translateY(-3px); border-color: rgba(var(--accent),.52); background: rgba(52,61,70,.9); }
.set-card.is-mastered { border-color: rgba(168,217,189,.38); background: linear-gradient(145deg, rgba(168,217,189,.075), transparent 52%), rgba(47,55,63,.8); }
.set-card-head { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 10px; }
.set-card h3 { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.set-status { display: inline-flex; min-height: 25px; align-items: center; padding: 3px 7px; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; font-size: .62rem; text-transform: uppercase; }
.set-status.is-current { color: rgb(var(--accent)); border-color: rgba(var(--accent),.34); }
.set-focus { margin: 0; color: #c7d1da; font-size: .83rem; line-height: 1.48; }
.set-categories, .set-days { display: flex; min-width: 0; flex-wrap: wrap; gap: 5px; }
.set-chip { min-height: 24px; padding: 4px 7px; color: var(--muted); border: 1px solid rgba(174,195,216,.14); border-radius: 5px; background: rgba(30,36,42,.3); font-size: .65rem; }
.set-chip.is-day { color: var(--gold); border-color: rgba(230,195,129,.24); }
.set-progress { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; margin-top: auto; }
.set-progress-track { height: 4px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.09); }
.set-progress-track b { display: block; height: 100%; background: rgb(var(--accent)); transition: width 320ms ease; }
.set-progress strong { min-width: 70px; color: var(--muted); font-size: .72rem; text-align: right; font-variant-numeric: tabular-nums; }
.set-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--faint); font-size: .66rem; }

.ui-tooltip { position: fixed; z-index: 50; max-width: 260px; padding: 7px 9px; pointer-events: none; color: var(--text); border: 1px solid var(--line-strong); border-radius: 5px; background: #1f252b; box-shadow: 0 8px 22px rgba(0,0,0,.28); font-size: .7rem; opacity: 0; transform: translateY(4px); transition: opacity 110ms ease, transform 110ms ease; }
.ui-tooltip[aria-hidden="false"] { opacity: 1; transform: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 760px) {
    .collection-shell { width: min(100% - 16px, 1500px); padding-top: 8px; }
    .collection-header { grid-template-columns: 42px minmax(0,1fr) auto; gap: 6px; }
    .icon-button { width: 42px; height: 42px; }
    #sort-order { display: none; }
    .collection-heading > svg { display: none; }
    .collection-heading strong { font-size: .94rem; }
    .collection-search.is-open { position: absolute; z-index: 10; left: 8px; right: 8px; top: 7px; padding-left: 44px; background: var(--bg); }
    .collection-search.is-open input { width: 100%; }
    .course-tabs { grid-template-columns: repeat(5, minmax(102px,1fr)); overflow-x: auto; }
    .collection-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .collection-summary > div { min-height: 64px; }
    .week-sets { grid-template-columns: 1fr; }
    .set-card { min-height: 180px; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
