@font-face { font-family: Marmelad; font-display: swap; src: url(fonts/marmelad-cyrillic-400.woff2) format("woff2"); unicode-range: U+0400-04FF, U+2116; }
@font-face { font-family: Marmelad; font-display: swap; src: url(fonts/marmelad-latin-400.woff2) format("woff2"); unicode-range: U+0000-03FF, U+2000-20FF; }
@font-face { font-family: Alegreya; font-weight: 400; font-display: swap; src: url(fonts/alegreya-sans-cyrillic-400.woff2) format("woff2"); unicode-range: U+0400-04FF, U+2116; }
@font-face { font-family: Alegreya; font-weight: 400; font-display: swap; src: url(fonts/alegreya-sans-latin-400.woff2) format("woff2"); unicode-range: U+0000-03FF, U+2000-20FF; }
@font-face { font-family: Alegreya; font-weight: 700; font-display: swap; src: url(fonts/alegreya-sans-cyrillic-700.woff2) format("woff2"); unicode-range: U+0400-04FF, U+2116; }
@font-face { font-family: Alegreya; font-weight: 700; font-display: swap; src: url(fonts/alegreya-sans-latin-700.woff2) format("woff2"); unicode-range: U+0000-03FF, U+2000-20FF; }

:root {
  --ground: #fbf7f1; --ink: #2b2533; --soft: #6c6473; --raise: #efe9e0; --accent: #5b4a7d; --on-accent: #fff;
  --card-ink: #2b2533;
  --c0: #fbf1b4; --c1: #dbe8c1; --c2: #c8ddf3; --c3: #e2d2f8; --c4: #e9e3da; --c5: #f9d2cf; --c6: #fbdabd;
  --title: Marmelad, Georgia, serif; --text: Alegreya, system-ui, sans-serif;
  --gut: 14px;
  color-scheme: light;
}
:root[data-night], .night-ground { --ground: #231d2e; --ink: #f3eee8; --soft: #b4abbd; --raise: #352d43; --accent: #cdbcf0; --on-accent: #231d2e; --card-ink: #f3eee8; }
:root[data-night] { color-scheme: dark; }

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; background: var(--ground); }
body { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--ground); color: var(--ink); font: 400 18px/1.32 var(--text); font-variant-numeric: lining-nums tabular-nums; overflow: hidden; overscroll-behavior: none; }
::selection { background: var(--c3); color: #2b2533; }
button, input { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: 3px; font-weight: 700; }
h1, h2, h3 { font-weight: 400; }
.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }

#view { flex: 1; min-height: 0; display: flex; flex-direction: column; outline: 0; }

#tabs { flex: none; position: relative; z-index: 3; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--ground); border-top: 1px solid var(--raise); }
#tabs button { height: 48px; border-radius: 14px; font-weight: 700; font-size: 17px; }
#tabs button[aria-current] { background: var(--accent); color: var(--on-accent); }

/* Сейчас */
#toolbar { flex: none; }
.today { flex: 1; min-width: 0; align-self: center; font: 400 22px/1.15 var(--title); padding-left: 4px; }
.today::first-letter { text-transform: uppercase; }
.stack { flex: 1; min-height: 0; padding-bottom: 20px; }
.head { font: 400 23px/1.15 var(--title); padding: 22px 18px 8px; }
.head.later { padding-top: 6px; }
.head small { font: 400 17px var(--text); color: var(--soft); margin-left: 6px; }

/* Card */
.cards { display: grid; gap: 8px; padding: 0 var(--gut) 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.cards .band { margin: 0; }
.band { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 54px; margin: 0 var(--gut) 8px; background: var(--bg); color: var(--card-ink); border-radius: 16px; overflow: hidden; --bg: var(--c4); }
.c0 { --bg: var(--c0); } .c1 { --bg: var(--c1); } .c2 { --bg: var(--c2); } .c3 { --bg: var(--c3); } .c4 { --bg: var(--c4); } .c5 { --bg: var(--c5); } .c6 { --bg: var(--c6); }
.open { cursor: pointer; }
.band > .open { display: flex; flex-direction: column; justify-content: flex-start; width: 100%; text-align: left; padding: 11px 0 13px 14px; border-radius: 16px; }
.band::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: var(--done, 0%); background: currentColor; opacity: .45; }
.when { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: baseline; font-weight: 700; font-size: 16px; line-height: 1.25; }
.when em { font-weight: 400; font-style: normal; }
.title { display: block; font: 400 20px/1.2 var(--title); margin-top: 3px; text-wrap: pretty; overflow-wrap: break-word; }
.meta { display: block; font-size: 16px; line-height: 1.25; margin-top: 5px; }
.meta b { font-weight: 700; }
.pick { display: grid; place-items: center; border-radius: 0 16px 16px 0; }
.pick i { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgb(255 255 255 / .65); }
.pick svg { width: 17px; height: 17px; display: block; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linejoin: round; }
.band.on .pick i { background: var(--accent); color: var(--on-accent); }
.band.on .pick svg { fill: currentColor; }

:root[data-night] .band, .night-ground .band, :root[data-night] .fork .opt { background: color-mix(in srgb, var(--bg) 16%, #2c2539); }
:root[data-night] .title, .night-ground .title { color: var(--bg); }
:root[data-night] .pick i, .night-ground .pick i { background: rgb(255 255 255 / .1); }
:root[data-night] .band.on .pick i, .night-ground .band.on .pick i { background: var(--accent); }

.next { display: block; width: calc(100% - 2 * var(--gut)); margin: 0 var(--gut) 10px; text-align: left; background: var(--accent); color: var(--on-accent); padding: 13px 14px 15px; border-radius: 16px; }
.next small { display: block; font-size: 16px; }
.next strong { display: block; font: 400 22px/1.2 var(--title); margin: 3px 0 4px; text-wrap: pretty; }
.note { padding: 18px 18px 6px; color: var(--soft); font-size: 15px; }
.none { padding: 16px 18px; font-size: 19px; text-wrap: pretty; }

/* Themes and search */
.tools { flex: none; display: flex; gap: 8px; padding: 0 var(--gut) 8px; }
#view > #toolbar:first-child .tools { padding-top: calc(env(safe-area-inset-top) + 12px); }
.tools input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; font-size: 17px; border-radius: 14px; background: var(--raise); -webkit-appearance: none; appearance: none; }
.tools input::placeholder { color: var(--soft); opacity: 1; }
.topics { flex: none; max-width: 62%; min-height: 44px; padding: 3px 14px; border-radius: 14px; background: var(--raise); font-weight: 700; font-size: 17px; line-height: 1.1; }
.topics.set { background: var(--accent); color: var(--on-accent); }
.chips { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--gut) 10px; max-height: 56dvh; }
.lgroup { flex: 0 0 100%; font: 400 17px/1.2 var(--title); color: var(--soft); padding: 8px 0 1px; }
.lgroup:first-child { padding-top: 0; }
.chips button { min-height: 40px; padding: 0 13px; border-radius: 12px; background: var(--raise); font-size: 17px; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* Программа */
.days { flex: none; display: grid; grid-template-columns: repeat(5, 1fr) 1.2fr; gap: 4px; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px; }
.days button { padding: 6px 0 7px; border-radius: 12px; display: grid; justify-items: center; align-content: center; gap: 1px; font-size: 15px; line-height: 1.1; }
.days b { font: 400 25px/1 var(--title); }
.days .word { font-size: 15px; font-weight: 700; line-height: 1.05; }
.days button[aria-current] { background: var(--accent); color: var(--on-accent); }
.panes { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; }
.panes::-webkit-scrollbar { display: none; }
.pane { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; min-height: 0; height: 100%; }
.pane-day { padding: 6px 18px 2px; color: var(--soft); }
.hour { position: sticky; top: 0; z-index: 2; padding: 10px 18px 6px; background: var(--ground); font: 400 22px/1.1 var(--title); }
.night-ground { background: var(--ground); color: var(--ink); padding-top: 4px; }
.off { display: block; width: calc(100% - 2 * var(--gut)); margin: 0 var(--gut) 6px; padding: 10px 14px; text-align: left; border-radius: 14px; background: var(--raise); }
.off strong { display: block; font: 400 18px/1.2 var(--title); }
.off span { color: var(--soft); font-size: 16px; }
.end { height: 32px; }

/* Мой день */
.mine-head { flex: none; padding: calc(env(safe-area-inset-top) + 14px) 18px 4px; font: 400 clamp(32px, 10vw, 42px)/1.1 var(--title); }
.dayhead { padding: 18px 18px 8px; font: 400 21px/1.15 var(--title); }
.dayhead::first-letter { text-transform: uppercase; }
.mile { margin: 0 var(--gut) 8px; padding: 11px 14px 13px; border-radius: 16px; background: var(--raise); }
.mile .title { font-size: 19px; color: inherit; }
.gap { display: block; width: calc(100% - 2 * var(--gut)); margin: 0 var(--gut) 8px; text-align: left; padding: 8px 14px; color: var(--soft); font-size: 17px; }
.gap b { color: var(--accent); font-weight: 700; }
.fork-title { padding: 8px 18px 6px; font: 400 18px/1.2 var(--title); }
.fork { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 var(--gut) 8px; }
.fork .opt { display: flex; flex-direction: column; background: var(--bg); color: var(--card-ink); border-radius: 16px; min-width: 0; overflow: hidden; }
.fork .opt > .open { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; text-align: left; padding: 10px 10px 10px 12px; }
.fork .title { font-size: 17px; hyphens: auto; }
.fork .meta { font-size: 15px; }
.fork .when { font-size: 15px; }
.fork .choose { min-height: 46px; margin: 0 8px 8px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.backup { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin: 0 var(--gut) 8px; padding: 4px 12px 4px 14px; border-radius: 14px; background: var(--raise); font-size: 16px; }
.backup button { min-height: 44px; text-align: left; color: var(--accent); font-weight: 700; }
.backup .name { color: inherit; font-weight: 400; }
.changed { margin: 0 var(--gut) 4px; padding: 10px 14px; border-radius: 14px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.changed button { display: block; min-height: 38px; text-decoration: underline; text-underline-offset: 3px; }
.band.gone .title { text-decoration: line-through; }
.empty { padding: 4px 18px 24px; }
.empty p { font-size: 19px; margin: 6px 0 16px; text-wrap: pretty; }
.empty .go { display: block; width: 100%; text-align: left; min-height: 48px; padding: 0 14px; margin-bottom: 6px; border-radius: 14px; background: var(--raise); font-weight: 700; }

/* Sheet */
#sheet { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: flex-end; }
#sheet[hidden] { display: none; }
#scrim { position: absolute; inset: 0; background: rgb(35 29 46 / .55); }
#panel { position: relative; max-height: 90dvh; display: flex; flex-direction: column; background: var(--ground); color: var(--ink); border-radius: 22px 22px 0 0; overflow: hidden; }
.s-top { flex: none; background: var(--bg, var(--raise)); color: var(--card-ink); padding: 15px 56px 15px 18px; position: relative; }
:root[data-night] .s-top { background: color-mix(in srgb, var(--bg) 18%, #2c2539); }
.s-top.plain { background: var(--raise); }
.s-top h2 { font: 400 25px/1.18 var(--title); margin-top: 4px; text-wrap: pretty; }
.s-x { position: absolute; top: 6px; right: 6px; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; }
.s-x svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.s-body { flex: 1; min-height: 0; padding: 14px 18px 20px; }
.s-body.flush { padding: 12px 0 20px; }
.s-body dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 14px; margin-bottom: 14px; }
.s-body dt { color: var(--soft); }
.s-body dd { margin: 0; font-weight: 700; }
.roomlink { color: var(--accent); cursor: pointer; }
.s-about { white-space: pre-line; max-width: 68ch; margin-bottom: 14px; }
.s-warn { background: var(--raise); padding: 10px 14px; border-radius: 14px; font-weight: 700; margin-bottom: 14px; }
.s-warn button { display: block; text-align: left; color: var(--accent); min-height: 32px; font-weight: 400; }
.s-actions { flex: none; padding: 8px var(--gut) calc(8px + env(safe-area-inset-bottom)); }
.s-actions button { width: 100%; min-height: 52px; border-radius: 14px; font-weight: 700; background: var(--accent); color: var(--on-accent); }
.s-actions button.is-on { background: var(--raise); color: var(--ink); }

@media (min-width: 620px) {
  #sheet { align-items: center; }
  #panel { width: 100%; max-width: 640px; }
  .days, .tools, .chips, #mine, .mine-head { width: 100%; max-width: 760px; margin-inline: auto; }
  #tabs { padding-inline: max(10px, calc((100% - 760px) / 2)); }
}

#rail, #side { display: none; }
.wempty { padding: 2px 18px 8px; color: var(--soft); }
.band.sel { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Desktop: same chrome, three working columns */
@media (min-width: 1100px) {
  body { display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(360px, 26vw); grid-template-rows: auto minmax(0, 1fr); }
  body[data-view="mine"] { grid-template-columns: 250px minmax(0, 1fr); }
  #tabs { grid-column: 1; grid-row: 1; grid-template-columns: 1fr; gap: 4px; padding: 16px 12px 12px; border-top: 0; }
  #tabs button { text-align: left; padding: 0 14px; height: 46px; }
  #rail { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; gap: 12px; padding: 4px 12px 0; overflow: hidden; min-height: 0; }
  #view { grid-column: 2; grid-row: 1 / 3; min-width: 0; border-inline: 1px solid var(--raise); }
  body[data-view="mine"] #view { border-right: 0; }
  #side { grid-column: 3; grid-row: 1 / 3; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
  body[data-view="mine"] #side { display: none; }
  #side .s-body { flex: 1; }
  .side-mine { flex: 1; min-height: 0; padding-top: 10px; }

  #rail input { flex: none; width: 100%; height: 44px; padding: 0 14px; font-size: 17px; border-radius: 14px; background: var(--raise); -webkit-appearance: none; appearance: none; }
  #rail input::placeholder { color: var(--soft); opacity: 1; }
  .rdays { display: grid; gap: 2px; }
  .rdays button { display: grid; grid-template-columns: 34px 1fr; align-items: baseline; text-align: left; min-height: 42px; padding: 5px 14px; border-radius: 12px; }
  .rdays button > span:only-child { grid-column: 1 / 3; font-weight: 700; }
  .rdays b { font: 400 23px/1 var(--title); }
  .rdays span { font-size: 16px; }
  .rdays button:hover, .rlens button:hover, #tabs button:not([aria-current]):hover { background: var(--raise); }
  .rdays button[aria-current] { background: var(--accent); color: var(--on-accent); }
  .rlens { flex: 1; min-height: 0; display: grid; align-content: start; gap: 2px; overflow-y: auto; scrollbar-width: thin; padding-bottom: 16px; }
  .rdays { flex: none; }
  .rlens .lgroup { padding: 10px 14px 2px; }
  .rlens button { text-align: left; min-height: 36px; padding: 4px 14px; line-height: 1.15; border-radius: 10px; font-size: 17px; }
  .rlens button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }

  .today.big { flex: none; align-self: stretch; padding: 22px 24px 8px; font-size: 32px; }
  .stack .head { padding-inline: 24px; }
  .stack .cards, .pane .cards { padding-inline: 24px 20px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
  .stack .next { width: auto; margin-inline: 24px 20px; }
  .note { padding-inline: 24px; }
  .band { transition: none; }
  .band > .open:hover .title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

  .panes.wide { display: block; overflow: hidden; height: 100%; }
  .panes.wide .pane { height: 100%; }
  .pane-day { padding: 22px 24px 10px; color: var(--ink); font: 400 32px/1.1 var(--title); }
  .pane-day::first-letter { text-transform: uppercase; }
  .pane [data-hour] { display: grid; grid-template-columns: 92px minmax(0, 1fr); padding-top: 10px; }
  .pane .hour { align-self: start; padding: 8px 0 8px 24px; background: none; font-size: 21px; }
  .pane .cards { padding-left: 0; padding-right: 20px; }
  .pane .head { padding-inline: 24px; }
  .pane .off { width: auto; margin-inline: 24px 20px; }

  .mine-head { padding: 22px 24px 4px; max-width: none; margin: 0; font-size: 32px; }
  .week { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); overflow-x: auto; scrollbar-width: none; }
  .wday { min-height: 0; border-left: 1px solid var(--raise); }
  .wday:first-child { border-left: 0; }
  .wday .dayhead { font-size: 18px; padding: 12px 14px 8px; position: sticky; top: 0; background: var(--ground); z-index: 1; }
  .wday .band, .wday .mile, .wday .backup, .wday .gap, .wday .changed { margin-inline: 8px; }
  .wday .gap { width: calc(100% - 16px); padding-inline: 8px; }
  .wday .band { grid-template-columns: minmax(0, 1fr) 44px; }
  .wday .band > .open { padding-left: 11px; }
  .wday .title { font-size: 17px; }
  .wday .meta, .wday .when { font-size: 15px; }
  .wday .fork { grid-template-columns: 1fr; margin-inline: 8px; }
  .wday .fork-title { padding-inline: 14px; }
  .wday .wempty { padding-inline: 14px; }
  .empty { max-width: 560px; }
}
