@font-face {
    font-family: "Bricolage Grotesque";
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url(/fonts/bricolage-latin.woff2?v=1) format("woff2");
    unicode-range: U+0020-007E, U+00A0-00FF, U+2010-2027, U+2030-203A, U+20AC, U+2122, U+2190-2193, U+2212;
}
@font-face {
    font-family: "Bricolage Grotesque";
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url(/fonts/bricolage-pl.woff2?v=1) format("woff2");
    unicode-range: U+0104-0107, U+0118-0119, U+0141-0144, U+015A-015B, U+0179-017C;
}

:root {
    --bg: #f2f4f7;
    --surface: #ffffff;
    --surface-2: #e7ebf0;
    --line: #cfd6df;
    --text: #0b1220;
    --muted: #475467;
    --accent: #0f766e;
    --accent-ink: #ffffff;
    --star: #b7791f;
    --error: #b42318;
    --shadow: 0 1px 2px rgba(11, 18, 32, .08), 0 10px 30px rgba(11, 18, 32, .10);
    --scrim: rgba(11, 18, 32, .4);
    --radius: 18px;

    --t-bg-s: 75%;  --t-bg-l: 90%;
    --t-ink-s: 60%; --t-ink-l: 14%;
    --t-sub-s: 40%; --t-sub-l: 27%;
    --t-dot-s: 75%; --t-dot-l: 40%;
    --t-trk-s: 45%; --t-trk-l: 80%;
    --t-bd-s: 45%;  --t-bd-l: 80%;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1d232c;
    --line: #262d37;
    --text: #e6edf3;
    --muted: #8b96a5;
    --accent: #2dd4bf;
    --accent-ink: #04221f;
    --star: #f5a524;
    --error: #ff8a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
    --scrim: rgba(0, 0, 0, .6);

    --t-bg-s: 32%;  --t-bg-l: 18%;
    --t-ink-s: 70%; --t-ink-l: 88%;
    --t-sub-s: 30%; --t-sub-l: 74%;
    --t-dot-s: 75%; --t-dot-l: 62%;
    --t-trk-s: 25%; --t-trk-l: 28%;
    --t-bd-s: 32%;  --t-bd-l: 18%;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line) transparent; }
::selection { background: var(--accent); color: var(--accent-ink); }
input { caret-color: var(--accent); }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) 16px 24px;
}
.app.wide { max-width: 1100px; }

.app-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.head-actions { display: flex; gap: 8px; }

.chip-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 44px; padding: 0 14px; border-radius: 22px;
    background: var(--surface); border: 1px solid var(--line);
    font-weight: 700; font-size: 14px; letter-spacing: .02em;
    max-width: 60vw;
}
.chip-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.round-btn {
    width: 44px; height: 44px; flex: none; border-radius: 22px;
    display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--line);
    transition: background-color .15s ease-out;
}
.round-btn:hover, .chip-btn:hover { background: var(--surface-2); }
.round-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.today-btn {
    height: 44px; padding: 0 16px; border-radius: 22px;
    background: var(--accent); color: var(--accent-ink);
    font-weight: 800; font-size: 14px;
}

.stale-banner {
    margin: 14px 0 0; padding: 10px 14px; border-radius: 14px;
    background: #fff4e0; color: #6b3d00; font-size: 14px; font-weight: 600;
}
[data-theme="dark"] .stale-banner { background: #3a2a10; color: #ffd9a0; }

.day-title { margin: 18px 0 14px; }
.day-title h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.day-title p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.nav-row { display: flex; align-items: center; gap: 8px; margin: 18px 0 12px; }
.nav-row .nav-label { flex: 1; text-align: center; display: flex; flex-direction: column; line-height: 1.2; }
.nav-row .nav-label b { font-size: 17px; font-weight: 800; }
.nav-row .nav-label small { font-size: 13px; color: var(--muted); }
.nav-row.compact { margin: 0 0 10px; }

.week-strip { display: grid; grid-template-columns: 36px repeat(7, minmax(0, 1fr)) 36px; gap: 2px; align-items: center; }
.week-strip .arrow { height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.day-pill {
    height: 60px; border-radius: 16px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.day-pill .dn { font-size: 12px; font-weight: 700; }
.day-pill .dd { font-size: 18px; font-weight: 800; }
.day-pill .dot { width: 4px; height: 4px; border-radius: 2px; background: transparent; }
.day-pill.has .dot { background: var(--accent); }
.day-pill.empty { color: var(--muted); }
.day-pill.today .dd { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.day-pill.sel { background: var(--accent); color: var(--accent-ink); }
.day-pill.sel .dot { background: var(--accent-ink); }

.tint { --h: 220; --s: 0; }
.tint {
    background: hsl(var(--h) calc(var(--s) * var(--t-bg-s)) var(--t-bg-l));
    color: hsl(var(--h) calc(var(--s) * var(--t-ink-s)) var(--t-ink-l));
    border: 1px solid hsl(var(--h) calc(var(--s) * var(--t-bd-s)) var(--t-bd-l));
}
.tint .sub { color: hsl(var(--h) calc(var(--s) * var(--t-sub-s)) var(--t-sub-l)); }
.tint .dot, .dot.tint-dot { background: hsl(var(--h) calc(var(--s) * var(--t-dot-s)) var(--t-dot-l)); }
.tint .track { background: hsl(var(--h) calc(var(--s) * var(--t-trk-s)) var(--t-trk-l)); }
.tint .fill { background: hsl(var(--h) calc(var(--s) * var(--t-dot-s)) var(--t-dot-l)); }

.day-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.ev-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: start; }
.ev-time { padding-top: 12px; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.ev-time b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.ev-time span { font-size: 13px; font-weight: 600; color: var(--muted); }

.ev-card {
    width: 100%; border-radius: var(--radius); padding: 12px 14px;
    display: flex; flex-direction: column; gap: 4px;
    transition: opacity .2s ease-out, filter .2s ease-out, transform .1s ease-out;
}
.ev-card:active { transform: scale(.985); }
.ev-subject { font-size: 16px; font-weight: 800; line-height: 1.25; }
.ev-type { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.ev-type .dot { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.ev-type .count { font-variant-numeric: tabular-nums; }
.ev-type .count::before { content: "·"; margin-right: 6px; }
.ev-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; font-size: 14px; font-weight: 600; }
.ev-meta span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ev-meta svg { flex: none; }
.ev-place b { font-weight: 800; font-variant-numeric: tabular-nums; }
.ev-live { display: none; margin-top: 6px; flex-direction: column; gap: 6px; }
.ev-live .row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.track { height: 6px; border-radius: 3px; overflow: hidden; }
.fill { height: 100%; border-radius: 3px; width: var(--progress, 0%); }

.ev-card.live { box-shadow: 0 0 0 2px var(--accent); }
.ev-card.live .ev-live { display: flex; }
.ev-card.past, .wk-cell.past { filter: saturate(0); opacity: .8; }

.gap-row { display: flex; align-items: center; gap: 10px; padding-left: 58px; font-size: 12px; font-weight: 600; color: var(--muted); }
.gap-row::before, .gap-row::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.empty-day {
    margin-top: 16px; padding: 28px 20px; border-radius: var(--radius);
    background: var(--surface); border: 1px dashed var(--line);
    text-align: center; color: var(--muted);
}
.empty-day b { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }
.link-btn { margin-top: 12px; height: 44px; padding: 0 16px; border-radius: 22px; background: var(--surface-2); color: var(--text); font-weight: 700; }

.message { margin-top: 32px; padding: 24px; text-align: center; color: var(--muted); }
.message.error { color: var(--error); }

.week-grid {
    display: grid;
    grid-template-columns: 34px repeat(var(--days, 5), minmax(0, 1fr));
    grid-auto-rows: minmax(78px, auto);
    grid-template-rows: 40px;
    gap: 4px;
}
.wk-head {
    border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.wk-head b { font-size: 11px; font-weight: 600; }
.wk-head span { font-size: 14px; font-weight: 800; }
.wk-head.today { background: var(--accent); color: var(--accent-ink); }
.wk-time { padding-top: 4px; font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.2; display: flex; flex-direction: column; }
.wk-slot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wk-cell {
    flex: 1; min-width: 0; border-radius: 10px; padding: 6px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 4px; overflow: hidden;
}
.wk-cell .ab { font-size: 13px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.wk-cell .full { display: none; }
.wk-cell .meta { display: flex; flex-direction: column; font-size: 10.5px; font-weight: 600; line-height: 1.25; }
.wk-cell .meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-cell.live { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

@media (min-width: 720px) {
    .week-grid { grid-template-columns: 54px repeat(var(--days, 5), minmax(0, 1fr)); grid-auto-rows: minmax(96px, auto); gap: 6px; }
    .wk-cell { padding: 8px 10px; }
    .wk-cell .ab { display: none; }
    .wk-cell .full { display: block; font-size: 14px; font-weight: 800; line-height: 1.2; }
    .wk-cell .meta { font-size: 12px; }
    .wk-time { font-size: 12px; }
}

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mo-head { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.mo-day {
    height: 56px; border-radius: 14px; padding: 6px 0;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
}
.mo-day.outside { color: var(--muted); font-weight: 500; }
.mo-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.mo-day.sel { background: var(--accent); color: var(--accent-ink); }
.mo-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 34px; }
.mo-dots .dot { width: 6px; height: 6px; border-radius: 3px; }
.mo-day.sel .mo-dots .dot { box-shadow: 0 0 0 1.5px var(--accent-ink); }
.mo-day-title { margin: 22px 0 0; font-size: 20px; font-weight: 800; }

dialog { color: var(--text); padding: 0; border: 0; }
dialog::backdrop { background: var(--scrim); }

.sheet {
    width: min(560px, 100vw); max-width: 100vw; max-height: 88vh;
    margin: auto auto 0; border-radius: 24px 24px 0 0;
    background: var(--surface); box-shadow: var(--shadow);
    padding: 12px 20px max(24px, env(safe-area-inset-bottom));
    overflow-y: auto;
}
@media (min-width: 620px) { .sheet { margin: auto; border-radius: 24px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 800; }

.search-field {
    display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px;
    border-radius: 14px; background: var(--surface-2); color: var(--muted);
}
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 16px; font-weight: 600; }
.search-results { margin-top: 8px; min-height: 40vh; }
.search-group-title { margin: 14px 4px 4px; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--muted); }
.search-result-item { display: block; width: 100%; padding: 12px; border-radius: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.search-result-item:hover, .search-result-item:focus-visible { background: var(--surface-2); }
.search-result-item.current { color: var(--accent); }
.search-empty { padding: 16px 12px; color: var(--muted); }

.setting { padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting h3 { margin: 0 0 10px; font-size: 14px; font-weight: 800; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented button { height: 40px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted); text-align: center; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
[data-theme="dark"] .segmented button[aria-pressed="true"] { background: #2a323d; }

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.primary-btn { height: 46px; padding: 0 18px; border-radius: 23px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.ghost-btn { height: 44px; padding: 0 16px; border-radius: 22px; background: var(--surface-2); font-weight: 700; }
.status { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.status b { color: var(--text); }
.status .ghost-btn { align-self: flex-start; margin-top: 6px; color: var(--text); }

.fullscreen {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
    background: var(--bg); overflow-y: auto;
    padding: max(16px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
}
.fullscreen::backdrop { background: var(--bg); }
.series-head, .series-body { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.series-head { display: flex; align-items: center; gap: 12px; }
.series-title { min-width: 0; }
.series-title h2 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.15; }
.series-title p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.type-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 12px; }
.type-chips button { height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; }
.type-chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.series-summary { border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.series-summary .big { display: flex; align-items: baseline; gap: 8px; }
.series-summary .big b { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.series-summary .big span { font-size: 16px; font-weight: 700; }
.series-summary .track { height: 8px; border-radius: 4px; }
.series-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.series-facts div { display: flex; flex-direction: column; gap: 2px; }
.series-facts small { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.series-facts b { font-size: 15px; font-weight: 800; }

.series-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; }
.series-month { margin: 14px 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.series-item {
    display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center;
    padding: 10px 12px; border-radius: 14px;
}
.series-item .idx { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.series-item .idx small { color: var(--muted); font-weight: 600; }
.series-item .when { display: flex; flex-direction: column; min-width: 0; }
.series-item .when b { font-size: 15px; font-weight: 700; }
.series-item .when span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-item .state { font-size: 12px; font-weight: 800; color: var(--muted); display: inline-flex; align-items: center; }
.series-item.done .idx, .series-item.done .when b { color: var(--muted); font-weight: 600; }
.series-item.next { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.series-item.next .state { color: var(--accent); }
.series-item.picked { background: var(--surface-2); }

.notice {
    position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
    max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
    background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px;
    box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.notice.show { opacity: 1; }
.notice.error { background: var(--error); color: #fff; }

.app-footer { margin-top: 32px; text-align: center; font-size: 13px; color: var(--muted); }
.app-footer a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    .round-btn.spinning svg { animation: none; }
    .round-btn.spinning { opacity: .6; }
}

.fav-bar { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.fav-bar[hidden], .fav-section[hidden] { display: none; }
.fav-chip {
    flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 20px;
    border: 1px solid var(--line); background: var(--surface); color: var(--text);
    font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; text-decoration: none; letter-spacing: .02em;
    transition: background-color .15s ease-out;
}
.fav-chip:hover { background: var(--surface-2); }
.fav-chip.current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fav-section { margin: 4px 0 14px; }
.fav-section h3 { margin: 0 0 8px; font-size: 14px; font-weight: 800; }
.fav-list { display: flex; flex-wrap: wrap; gap: 8px; }
.fav-item { display: inline-flex; align-items: center; border-radius: 20px; border: 1px solid var(--line); background: var(--surface-2); }
.fav-item .fav-chip { border: 0; background: none; padding-right: 6px; }
.fav-item .fav-chip.current { background: var(--accent); border-radius: 20px 0 0 20px; padding-right: 12px; }
.fav-remove { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 0 20px 20px 0; color: var(--muted); }
.fav-remove:hover { color: var(--text); background: var(--line); }
.search-row { display: flex; align-items: center; gap: 4px; }
.search-row .search-result-item { flex: 1; min-width: 0; }
.fav-star { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; }
.fav-star svg { fill: transparent; stroke: var(--muted); }
.fav-star[aria-pressed="true"] svg { fill: var(--star); stroke: var(--star); }
.fav-star:hover { background: var(--surface-2); }
.about-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); font-weight: 700; text-underline-offset: 3px; }
