:root {
  color-scheme: light;
  --background: #f8f9fa;
  --surface: #ffffff;
  --current-pair: #f1f3f6;
  --current-pair-border: #bbc3ce;
  --text: #20242a;
  --muted: #68717d;
  --border: #dfe3e8;
  --week-divider: #e8ebef;
  --soft: #f1f3f5;
  --hover: #f5f6f8;
  --focus: #64748b;
  --icon-filter: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #17191d;
  --surface: #202329;
  --current-pair: #292e36;
  --current-pair-border: #505b6b;
  --text: #edeef0;
  --muted: #a4abb5;
  --border: #383d46;
  --week-divider: #30353d;
  --soft: #2b2f36;
  --hover: #292d34;
  --focus: #b0bac8;
  --icon-filter: brightness(0) invert(1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button, a, summary, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
a { color: inherit; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
main:focus { outline: none; }
.app-icon { display: block; width: 20px; height: 20px; flex-shrink: 0; object-fit: contain; filter: var(--icon-filter); opacity: .9; }
.app-shell { width: min(100% - 40px, 780px); margin: 0 auto; }
.app-header { display: flex; align-items: center; gap: 12px; min-height: 76px; border-bottom: 1px solid var(--border); }
.brand { font-size: 19px; font-weight: 650; text-decoration: none; letter-spacing: -.3px; }
.header-group { margin-left: auto; font-size: 14px; color: var(--muted); }
.icon-button { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); padding: 0; }
main { padding: 30px 0 48px; }
.back-link { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 24px; text-decoration: none; font-size: 14px; color: var(--muted); }
.back-link .app-icon { width: 16px; height: 16px; opacity: .7; }
.eyebrow { margin: 0 0 9px; color: var(--muted); font-size: 13px; }
h1 { font-size: clamp(25px, 4vw, 32px); line-height: 1.25; font-weight: 650; letter-spacing: -.65px; margin: 0; }
h2 { font-size: 18px; font-weight: 600; margin: 0; }
.page-note { color: var(--muted); margin: 10px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.selection-list { display: grid; gap: 10px; margin-top: 27px; }
.choice { display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; width: 100%; padding: 19px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.choice:enabled:active { border-color: var(--muted); background: var(--hover); }
.choice-title { display: block; font-weight: 550; line-height: 1.45; }
.choice-note { display: block; font-size: 13px; color: var(--muted); margin-top: 5px; }
.choice > .app-icon { width: 18px; height: 18px; opacity: .7; }
.compact-choices { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); }
.step-track { display: flex; gap: 5px; width: 110px; margin: 0 0 23px; }
.step-track span { height: 3px; flex: 1; border-radius: 2px; background: var(--border); }
.step-track .complete { background: var(--muted); }
.page-heading { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; margin-bottom: 22px; }
.date-line { margin: 7px 0 0; color: var(--muted); font-size: 15px; }
.week-label { white-space: nowrap; background: var(--soft); padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; }
.group-context { padding: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.group-context strong { color: var(--text); font-weight: 600; font-size: 15px; }
.daily-context { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
.daily-context > strong, .daily-context > div { grid-column: 1; }
.daily-context .week-label { grid-column: 2; grid-row: 1 / 3; align-self: start; }
.day-switches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.day-switch { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; padding: 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.day-switch strong { font-size: 15px; font-weight: 600; }
.day-switch > span { font-size: 13px; color: var(--muted); }
.day-switch[aria-current="date"] { border-color: var(--muted); }
.day-switch[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.day-switch[aria-pressed="true"] > span { color: inherit; opacity: .8; }
.day-schedule { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.day-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); background: var(--soft); }
.day-card-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; }
.day-card-title h1 { font-size: 20px; font-weight: 600; letter-spacing: -.2px; }
.day-card-date { font-size: 14px; color: var(--muted); }
.day-card-status { flex-shrink: 0; color: var(--muted); font-size: 13px; }
.list-heading { display: flex; justify-content: space-between; align-items: center; padding: 15px 19px; border-bottom: 1px solid var(--border); gap: 12px; }
.list-heading span { color: var(--muted); font-size: 13px; }
.time-slot { display: grid; grid-template-columns: 64px minmax(0, 1fr); }
.time-slot.is-current { background: var(--current-pair); --border: var(--current-pair-border); --soft: var(--current-pair-border); --week-divider: var(--current-pair-border); }
.time-slot.is-current + .time-slot { border-top-color: var(--current-pair-border); }
.slot-content { display: flex; flex-direction: column; min-width: 0; }
.slot-content > .week-block, .slot-content > .week-cycle { flex: 1; }
.time-slot + .time-slot { border-top: 1px solid var(--border); }
.lesson-time { padding: 16px 6px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lesson-time strong { font-size: 16px; font-weight: 600; }
.lesson-time > span { color: var(--muted); font-size: 13px; }
.lesson-time .now { color: var(--text); font-size: 11px; margin-top: 5px; }
.lesson { padding: 19px 20px; }
.lesson + .lesson { border-top: 1px solid var(--soft); }
.lesson-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.tag { display: inline-block; color: var(--muted); font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; }
.lesson h3 { font-size: 16px; line-height: 1.5; font-weight: 550; margin: 0; overflow-wrap: anywhere; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin-top: 7px; overflow-wrap: anywhere; }
.lesson-room { white-space: pre-line; }
.empty-day { text-align: center; padding: 40px 22px; }
.empty-day h2 { font-weight: 550; font-size: 18px; }
.empty-day p { font-size: 14px; color: var(--muted); margin: 7px 0 0; }
.week-link { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; margin-top: 19px; padding: 17px 19px; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; font-size: 15px; font-weight: 500; }
.schedule-notice { margin-top: 20px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 13px; line-height: 1.6; }
.schedule-notice p { margin: 0; }
.schedule-notice a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.day-panels { display: grid; gap: 10px; }
.day-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
.day-panel > summary { display: flex; align-items: center; gap: 14px; padding: 18px 19px; }
.day-title { display: flex; flex-direction: column; gap: 2px; }
.day-title strong { font-size: 15px; font-weight: 550; }
.day-panel > summary .app-icon { width: 17px; height: 17px; margin-left: auto; opacity: .7; transition: transform .15s; }
.day-panel[open] > summary { border-bottom: 1px solid var(--border); }
.day-panel[open] > summary .app-icon { transform: rotate(180deg); }
.day-panel .day-schedule { border: 0; border-radius: 0; }
.week-block + .week-block, .week-block + .week-cycle, .week-cycle + .week-block { border-top: 1px solid var(--border); }
.week-cycle { display: grid; grid-template-rows: repeat(2, 1fr); }
.week-block { display: flex; flex-direction: column; min-width: 0; }
.week-block[data-week="denominator"] { border-top: 1px dashed var(--week-divider); }
.week-block-label { display: block; flex-shrink: 0; padding: 9px 16px 0; color: var(--muted); font-size: 11px; font-weight: 600; }
.week-lessons.split-subgroups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lesson-layout { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lesson-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); flex: 1; min-width: 0; }
.lesson-row + .lesson-row { border-top: 1px solid var(--soft); }
.room-cell { display: flex; flex-direction: column; justify-content: center; gap: 5px; min-width: 0; padding: 10px 8px; border-right: 1px solid var(--border); text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.room-value { white-space: pre-line; overflow-wrap: anywhere; }
.room-subgroups { display: grid; border-right: 1px solid var(--border); }
.room-subgroups .room-cell { border-right: 0; }
.room-subgroups .room-cell + .room-cell { border-top: 1px solid var(--soft); }
.week-subgroup { display: flex; flex-direction: column; min-width: 0; }
.week-subgroup > .lesson { flex: 1; }
.split-subgroups .week-subgroup + .week-subgroup { border-left: 1px solid var(--soft); }
.compact-schedule .lesson { display: flex; flex-direction: column; justify-content: center; padding: 12px 16px; }
.week-empty { display: block; padding: 12px 16px; color: var(--muted); font-size: 14px; }
.lesson-row > .week-empty, .week-subgroup > .week-empty { display: flex; align-items: center; flex: 1; }
.conditions { border: 1px solid var(--border); border-radius: 9px; margin-top: 15px; background: var(--surface); overflow: hidden; }
.conditions > summary { padding: 15px 18px; font-size: 14px; }
.conditions > summary::after { content: "+"; float: right; color: var(--muted); }
.conditions[open] > summary::after { content: "−"; }
.conditions-note { padding: 0 18px 15px; margin: 0; color: var(--muted); font-size: 13px; }
.conditions .time-slot { border-top: 1px solid var(--border); }
.day-schedule > .conditions { margin: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.day-panel .conditions { margin: 12px; }
.status { color: var(--muted); text-align: center; padding: 48px 10px; }
.error-message { border: 1px solid var(--border); padding: 24px; border-radius: 10px; background: var(--surface); }
.error-message p { color: var(--muted); font-size: 14px; }
.plain-button { background: var(--soft); border: 1px solid var(--border); padding: 10px 16px; border-radius: 7px; }
.inline-status { margin: 18px 0 0; color: var(--muted); font-size: 14px; }
dialog { position: fixed; inset: 72px auto auto max(20px, calc((100vw - 780px) / 2)); margin: 0; padding: 21px; width: min(340px, calc(100vw - 40px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 26px rgb(0 0 0 / .10); }
dialog::backdrop { background: rgb(0 0 0 / .12); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-header .icon-button { border: 0; width: 32px; height: 32px; }
.change-button { width: 100%; padding: 12px 15px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); text-align: left; }
.theme-fieldset { padding: 0; margin: 24px 0 0; border: 0; min-width: 0; }
.theme-fieldset legend { font-size: 14px; font-weight: 550; margin-bottom: 10px; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.theme-options label { cursor: pointer; position: relative; }
.theme-options label + label { border-left: 1px solid var(--border); }
.theme-options input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.theme-options span { display: block; text-align: center; font-size: 13px; padding: 10px 6px; color: var(--muted); }
.theme-options input:checked + span { background: var(--soft); color: var(--text); font-weight: 600; }
.theme-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -3px; }
.settings-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover { background: var(--hover); }
  .back-link:hover { color: var(--text); }
  .choice:enabled:hover { border-color: var(--muted); background: var(--hover); }
  .day-switch:not([aria-pressed="true"]):hover { background: var(--hover); }
  .week-link:hover { background: var(--hover); border-color: var(--muted); }
  .day-panel > summary:hover { background: var(--hover); }
  .change-button:hover { background: var(--hover); }
}

@media (max-width: 540px) {
  .app-shell { width: calc(100% - 28px); }
  .app-header { min-height: 66px; }
  main { padding-top: 24px; }
  .page-heading { gap: 10px; }
  .week-label { font-size: 12px; padding: 5px 8px; }
  .choice { padding: 16px; }
  .day-switches { gap: 6px; }
  .day-switch { min-height: 58px; padding: 7px 4px; }
  .day-card-header { padding: 14px 12px; gap: 8px; }
  .day-card-title h1 { font-size: 18px; }
  .day-card-date, .day-card-status { font-size: 12px; }
  .time-slot { grid-template-columns: 64px minmax(0, 1fr); }
  .lesson-time { padding: 18px 6px; }
  .lesson-time strong { font-size: 16px; }
  .lesson { padding: 16px 14px; }
  .compact-schedule .time-slot { grid-template-columns: 52px minmax(0, 1fr); }
  .compact-schedule .lesson-time { padding: 12px 4px; }
  .compact-schedule .lesson-time strong { font-size: 14px; }
  .compact-schedule .lesson { padding: 10px 6px; }
  .lesson-row { grid-template-columns: 50px minmax(0, 1fr); }
  .room-cell { padding: 9px 4px; font-size: 12px; }
  .week-block-label, .week-empty { padding-left: 12px; padding-right: 12px; }
  .lesson h3 { font-size: 13px; line-height: 1.4; -webkit-hyphens: auto; hyphens: auto; }
  .split-subgroups .lesson h3 { font-size: 12px; }
  .lesson-meta { display: grid; gap: 4px; }
  .list-heading { padding: 14px; }
  .day-panel > summary { padding: 16px 14px; gap: 10px; }
  dialog { left: 14px; top: 64px; width: min(340px, calc(100vw - 28px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

.additional-subgroup-label { display: block; padding: 9px 16px 0; color: var(--muted); font-size: 11px; font-weight: 600; }
