:root {
  --bg: #f4f4f4; --card: #fff; --ink: #1f2122; --mute: #6b6f72; --line: #e2e2e2;
  --green: #1f2122; --wheat: #24b24c; --chip: #e9e9e9; --tag-l: 32%;
  color-scheme: light dark;
}
:root[data-uni=freeuni] { --wheat: #ffcd29; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #121314; --card: #1b1c1e; --ink: #e8e8e8; --mute: #8d9194; --line: #2b2d30; --green: #0f1011; --chip: #26282a; --tag-l: 72%; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 'Noto Sans Georgian', system-ui, sans-serif; -webkit-text-size-adjust: 100%; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }

header { background: var(--green); color: #f2f2f2; padding: calc(14px + env(safe-area-inset-top)) 16px 14px; }
.bar, .summary, .groups, .variants, .sub, .week .inner, main { max-width: 1100px; margin-inline: auto; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }
h1 { margin: 0; font: 700 20px/1 'Noto Serif Georgian', Georgia, serif; letter-spacing: .03em; }
h1 span { margin-left: 6px; font: 500 13px 'Noto Sans Georgian', sans-serif; opacity: .65; letter-spacing: 0; }

.xlink { padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 999px; color: inherit; font-size: 14px; text-decoration: none; opacity: .85; }
.xlink:hover { background: rgba(255, 255, 255, .1); opacity: 1; }
#roomsbtn { margin-left: auto; }
.rooms-on #roomsbtn { margin-left: 0; }
.rooms-on .bar > a.xlink { display: none; }
.rooms-on #uni, .rooms-on #years, .rooms-on .summary, .rooms-on .groups, .rooms-on .variants, .rooms-on .sub, .rooms-on .week, .rooms-on #days { display: none; }
#rooms { max-width: 1100px; margin: 0 auto; padding: 12px 12px 20px; }
#rooms[hidden] { display: none; }
.rbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.rbar input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
.rbar button { padding: 7px 14px; border-radius: 10px; background: var(--chip); font-size: 14px; }
.legend { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; font-size: 13px; color: var(--mute); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; white-space: nowrap; }
.legend i { width: 12px; height: 12px; border-radius: 4px; }
.floor { margin-bottom: 12px; padding: 10px 12px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.floor h2 { display: flex; justify-content: space-between; margin: 0 0 8px; font-size: 14px; }
.floor h2 small { color: var(--mute); font-weight: 500; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.room { display: grid; gap: 1px; padding: 6px 8px; border: 1.5px solid; border-radius: 10px; text-align: left; }
.room b { font-size: 15px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room small { min-height: 1.3em; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.loader { width: 28px; height: 28px; margin: 64px auto; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy { --c: #e5484d; }
.ending { --c: #3e8ef7; }
.soon { --c: #f5a524; }
.free { --c: #30a46c; }
.busy, .ending, .soon, .free { background: color-mix(in srgb, var(--c) var(--tint, 14%), var(--card)); border-color: var(--c); }
.legend i { border: 0; background: var(--c); }
@media (prefers-color-scheme: dark) { :root { --tint: 30%; } }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.seg button { padding: 6px 14px; border-radius: 999px; font-size: 14px; opacity: .8; }
.seg button[aria-pressed=true] { background: var(--wheat); color: #1d2a21; opacity: 1; font-weight: 500; }
#uni button { display: flex; padding: 2px 14px; opacity: .45; }
#uni button[aria-pressed=true] { background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1.5px var(--wheat); opacity: 1; }
#uni img { width: 42px; height: 42px; margin: -4px 0; }
#uni [data-u=freeuni] img { width: 36px; height: 36px; margin: -1px 3px; }

.groups { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.groups::-webkit-scrollbar { display: none; }
.groups button { flex: none; padding: 5px 12px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.groups button[aria-pressed=true] { background: #fff; border-color: #fff; color: #1f2122; font-weight: 700; }
.groups button small { display: block; margin-top: 1px; font-size: 10px; line-height: 1.1; font-weight: 400; opacity: .65; }

.fam { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; font-size: 13px; }
.fam > span { opacity: .7; }
.fam .seg button { padding: 3px 10px; font-size: 13px; }
.fam.need > span { color: var(--wheat); opacity: 1; }
.fam.need .seg { box-shadow: 0 0 0 1.5px var(--wheat); }
.cloud { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.cloud button { padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); font-size: 13px; text-align: left; }
.cloud button[aria-pressed=true] { background: var(--wheat); color: #1d2a21; font-weight: 500; }
.collapsed #years, .collapsed .groups, .collapsed .variants { display: none; }
.summary { display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 12px; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 10px; text-align: left; }
.summary[hidden] { display: none; }
.summary:hover { background: rgba(255, 255, 255, .06); }
.summary b { font-size: 16px; font-variant-numeric: tabular-nums; }
.summary .hint { margin-left: -8px; font-size: 13px; opacity: .65; }
.summary .p { min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary b, .summary .hint, .summary em { flex: none; }
@media (max-width: 440px) { .summary { gap: 12px; } .summary .hint, .summary em span { display: none; } }
.summary .p small { display: block; font-size: 10px; line-height: 1.2; opacity: .6; }
.summary em { margin-left: auto; font-style: normal; font-size: 13px; color: var(--wheat); }
.sub { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sub[hidden] { display: none; }
#addbtn:disabled { opacity: .4; box-shadow: none; cursor: default; }
#addbtn { padding: 9px 18px; border-radius: 10px; background: var(--wheat); color: #1d2a21; font-size: 15px; font-weight: 700; box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.cloud button small { display: block; font-size: 10px; line-height: 1.2; opacity: .65; }
#add, #same { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .45); }
#add[hidden], #same[hidden] { display: none; }
#add .box, #same .box { max-width: 340px; padding: 20px; border-radius: 16px; background: var(--card); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
#add .box { display: flex; flex-direction: column; gap: 8px; width: 300px; }
.app { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: inherit; font-size: 15px; font-weight: 500; text-decoration: none; }
.ico { width: 26px; height: 26px; flex: none; filter: drop-shadow(0 0 1px rgba(0, 0, 0, .2)); }
.raw { margin-top: 2px; text-align: center; color: var(--mute); font-size: 13px; text-decoration: none; border-bottom: 1px dotted currentColor; align-self: center; }
#same .box { width: 100%; max-width: 420px; max-height: 80vh; overflow-y: auto; }
#same h3 { margin: 0; font-size: 15px; }
.mhead { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.mhead h3 { flex: 1; align-self: center; }
#same-x { flex: none; width: 36px; height: 36px; margin: -8px -8px 0 0; border-radius: 50%; background: var(--chip); color: var(--ink); font-size: 15px; }
#same .mhead:has(+ #same-list .tl) { position: sticky; top: -20px; z-index: 3; margin: -20px -20px 6px; padding: 20px 20px 10px; background: var(--card); }
html:has(#same:not([hidden])), html:has(#add:not([hidden])) { overflow: hidden; }
#same .box, #add .box { overscroll-behavior: contain; }
.tl { --gut: 44px; position: relative; margin: 6px 0 4px; }
.hr { position: absolute; left: var(--gut); right: 0; border-top: 1px solid var(--line); }
.hr span { position: absolute; left: calc(-1 * var(--gut)); top: -7px; font-size: 11px; color: var(--mute); font-variant-numeric: tabular-nums; }
.blk { position: absolute; display: flex; flex-direction: column; gap: 1px; padding: 3px 6px; overflow: hidden; border-radius: 6px; border-left: 3px solid #3a7bd5; background: color-mix(in srgb, #3a7bd5 16%, var(--card)); z-index: 1; font-size: 11px; line-height: 1.25; color: var(--mute); }
.blk b { font-size: 12px; color: var(--ink); }
.blk.cur { border-left-color: #d0453a; background: color-mix(in srgb, #d0453a 16%, var(--card)); }
.blk.past { color: color-mix(in srgb, var(--mute) 60%, var(--card)); }
.blk.past b { color: var(--mute); }
.nowline { position: absolute; left: calc(var(--gut) - 5px); right: 0; z-index: 2; border-top: 2px solid #ea4335; pointer-events: none; }
.nowline::before { content: ''; position: absolute; left: -1px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: #ea4335; }
.slot { display: grid; gap: 1px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--mute); }
.slot b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.slot.me { background: color-mix(in srgb, var(--wheat) 18%, transparent); border-radius: 8px; }
.pick { grid-column: 1 / -1; margin: 0; padding: 48px 0; text-align: center; color: var(--mute); }

.week { position: sticky; top: 0; z-index: 5; padding: 8px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#exam { display: flex; flex-direction: column; gap: 2px; margin: -8px -12px 8px; padding: 6px 12px; background: var(--wheat); color: #1d2a21; font-size: 14px; }
#exam[hidden] { display: none; }
#exam button { display: block; width: 100%; max-width: 1100px; height: auto; margin-inline: auto; padding: 2px 0; border-radius: 0; background: none; font-size: 14px; line-height: 1.35; text-align: left; }
.tag.exam { background: rgba(208, 69, 58, .15); color: #d0453a; font-weight: 600; }
.week .inner { display: flex; align-items: center; gap: 6px; }
.week #range { flex: 1; text-align: center; font-size: 16px; }
.week button { width: 40px; height: 38px; border-radius: 10px; background: var(--chip); font-size: 22px; line-height: 1; }
.week button:disabled { opacity: .3; cursor: default; }
.week .today { width: auto; padding: 0 12px; font-size: 14px; }

main { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; gap: 12px; padding: 12px 12px 20px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.day h2 { display: flex; justify-content: space-between; margin: 0; padding: 9px 14px; font-size: 14px; }
.day h2 small { color: var(--mute); font-weight: 500; }
.day.empty { background: transparent; }
.day.empty h2 { color: var(--mute); font-weight: 500; }
.day.is-today { border-color: var(--wheat); box-shadow: 0 0 0 1px var(--wheat); }
.day.is-today h2 { background: color-mix(in srgb, var(--wheat) 20%, transparent); }

.ev { --c: hsl(var(--h) 45% 46%); border-top: 1px solid var(--line); box-shadow: inset 4px 0 var(--c); }
.ev.now { background: color-mix(in srgb, var(--wheat) 13%, transparent); }
.row { display: grid; grid-template-columns: 50px 1fr; gap: 12px; padding: 10px 14px 10px 16px; }
.time { font-size: 13px; line-height: 1.3; font-variant-numeric: tabular-nums; color: var(--mute); }
.time b { display: block; font-size: 15px; color: var(--ink); }
.now .time b { color: #d0453a; }
.t { display: block; padding: 0; font-weight: 500; text-align: left; }
.meta { margin-top: 2px; font-size: 13px; color: var(--mute); }
.tag { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 6px; font-size: 12px; background: hsl(var(--h) 45% 46% / .15); color: hsl(var(--h) 45% var(--tag-l)); }

summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary .time::after { content: '⌄'; display: block; font-size: 12px; }
details[open] summary .time::after { content: '⌃'; }
.more { padding: 0 14px 10px 78px; font-size: 13px; color: var(--mute); overflow-wrap: anywhere; }
.more a { color: inherit; }

footer { padding: 4px 16px calc(28px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; }
footer a { color: var(--mute); text-decoration: none; border-bottom: 1px dotted currentColor; }
footer a + a { margin-left: 14px; }
