*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--font-head); margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--on-primary); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

.topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--brand); color: var(--ivory); border-bottom: 3px solid var(--gold); }
.topbar .brand { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; margin-right: auto; color: var(--ivory); text-decoration: none; }
.topbar button, .topbar select { background: transparent; color: var(--ivory); border: 1px solid var(--gold); border-radius: 8px; padding: .3rem .6rem; font: inherit; cursor: pointer; }
.topbar select option { color: #2B1A1E; }

.layout { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1100px; margin: 0 auto; }
nav.tabs { display: flex; gap: .25rem; overflow-x: auto; padding: .5rem .75rem 0; border-bottom: 1px solid var(--border); }
nav.tabs a { padding: .55rem .9rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0; text-decoration: none; color: var(--muted); white-space: nowrap; border: 1px solid transparent; border-bottom: 0; }
nav.tabs a[aria-current="page"] { color: var(--primary); background: var(--surface); border-color: var(--border); font-weight: 600; }
main { padding: 1rem; flex: 1; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; }

label { display: block; font-weight: 600; margin: .6rem 0 .2rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .7rem; }
input[type="checkbox"] { width: auto; }
.btn { font: inherit; cursor: pointer; border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary); border-radius: var(--radius-sm); padding: .5rem 1rem; font-weight: 600; }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .25rem .6rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.error { color: var(--danger); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
ul.clean { list-style: none; margin: 0; padding: 0; }
ul.clean li { padding: .5rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .6rem; align-items: center; }
ul.clean li:last-child { border-bottom: 0; }
.done { text-decoration: line-through; color: var(--muted); }

.kodas-footer { text-align: center; padding: 1rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }

.grow { flex: 1; min-width: 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; background: var(--surface-2); padding: .1rem .4rem; border-radius: 6px; }
.auth { max-width: 460px; margin: 1rem auto; }
.auth .row { margin-bottom: .75rem; }
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 20; }
.toast { background: var(--brand); color: var(--ivory); padding: .6rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--gold); box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }
[hidden] { display: none !important; }
.topbar #who { font-size: .9rem; }

/* Kalendorius */
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--muted); }
.mc-0 { --mc: #5A2430; } .mc-1 { --mc: #2F6B3F; } .mc-2 { --mc: #1D5FBF; } .mc-3 { --mc: #B45309; }
.mc-4 { --mc: #7A3E9D; } .mc-5 { --mc: #0F766E; } .mc-6 { --mc: #A12727; } .mc-7 { --mc: #6B5B2E; } .mc-all { --mc: #8A7A6E; }
:root[data-theme="dark"] .mc-0 { --mc: #D98BA0; } :root[data-theme="dark"] .mc-1 { --mc: #7FCB95; } :root[data-theme="dark"] .mc-2 { --mc: #86B4FF; }
:root[data-theme="dark"] .mc-3 { --mc: #F0B26A; } :root[data-theme="dark"] .mc-4 { --mc: #C79BE6; } :root[data-theme="dark"] .mc-5 { --mc: #62D4C7; }
:root[data-theme="dark"] .mc-6 { --mc: #FF9C9C; } :root[data-theme="dark"] .mc-7 { --mc: #D4C48A; }
.dot[class*="mc-"] { background: var(--mc); }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-bottom: 1rem; }
.month .wd { text-align: center; font-weight: 600; color: var(--muted); padding: .25rem 0; }
.month .day { font: inherit; color: var(--text); text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-height: 5.2rem; padding: .25rem; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.month .day.other { opacity: .5; }
.month .day.today .num { background: var(--primary); color: var(--on-primary); border-radius: 999px; padding: 0 .4rem; }
.month .day.sel { outline: 2px solid var(--primary); outline-offset: -2px; }
.month .num { font-weight: 600; align-self: flex-start; }
.chip { display: block; font-size: .72rem; line-height: 1.2; padding: 1px 4px; border-radius: 4px; border-left: 3px solid var(--mc); background: var(--surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { font-size: .72rem; color: var(--muted); }
.agenda .time { min-width: 5.5rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.agenda li { align-items: flex-start; flex-wrap: wrap; }
.fs { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: .6rem 0; padding: .4rem .7rem; }
label.inline { display: inline-flex; gap: .35rem; align-items: center; font-weight: 400; margin: .2rem .6rem .2rem 0; }
.cal-title { min-width: 9rem; text-align: center; }
@media (max-width: 600px) { .month .day { min-height: 3.6rem; } .chip { display: none; } .month .day:has(.chip)::after { content: "•"; color: var(--primary); } }
.badge { margin-left: .4rem; }

/* Pirkiniai */
.addrow { flex-wrap: wrap; } .addrow input[name=name] { flex: 2 1 12rem; } .addrow select { flex: 1 1 10rem; width: auto; } .addrow .qty { flex: 0 1 7rem; width: 7rem; }
h3.cat { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .8rem 0 .2rem; font-family: var(--font); }
ul.clean li input[type=checkbox] { width: 1.3rem; height: 1.3rem; }

/* Mokykla */
.lessons li { align-items: flex-start; flex-wrap: wrap; }
.lessons li.cancelled { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.lessons li.changed { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.lessons .time { min-width: 7.5rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.badge.warn { border-color: var(--danger); color: var(--danger); }
.banner { background: var(--surface-2); border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: .6rem 1rem; display: flex; gap: .5rem; align-items: center; justify-content: space-between; }
.today-card { border-color: var(--primary); }
.timegrid { display: grid; grid-template-columns: 2rem 1fr 1fr; gap: .4rem .6rem; align-items: center; max-width: 24rem; margin-bottom: .6rem; }
.lgrid { display: grid; grid-template-columns: 1.6rem repeat(5, minmax(0, 1fr)); gap: .35rem; align-items: center; overflow-x: auto; }
.lgrid .cell { display: flex; flex-direction: column; gap: 2px; min-width: 6rem; }
.lgrid input { padding: .3rem .4rem; font-size: .85rem; } .lgrid input.room { font-size: .75rem; color: var(--muted); }

/* Skaitymas */
.clock { font-size: 2.4rem; font-variant-numeric: tabular-nums; font-family: var(--font-head); color: var(--primary); margin: .3rem 0 .6rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .7rem; }
.stat strong { font-size: 1.15rem; }
svg.bars { width: 100%; max-width: 420px; height: auto; display: block; margin: .4rem 0 .8rem; }
svg.bars .bar { fill: var(--primary); opacity: .55; } svg.bars .bar.today { opacity: 1; } svg.bars .axis { stroke: var(--border); }
progress { width: 100%; height: .9rem; accent-color: var(--primary); margin: .2rem 0 .7rem; }
.badge.gold { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.badges { margin-top: .6rem; } .stars { color: #B7791F; letter-spacing: .1em; }
:root[data-theme="dark"] .stars { color: var(--accent); }

/* Transportas */
ol.trip { margin: .5rem 0 0; padding-left: 1.4rem; columns: 2 16rem; }
ol.trip li { padding: .1rem 0; }
ol.trip li.here { font-weight: 700; color: var(--primary); }
.dep { margin: .35rem 0; }
.dep[aria-expanded="true"] { border-color: var(--primary); }
.grow { flex: 1 1 14rem; } .grow input { width: 100%; }
.dep.wide { width: 100%; text-align: left; }
button.cardbtn { text-align: left; cursor: pointer; font: inherit; color: inherit; }

/* Įrenginiai */
.lockcard { border-color: var(--danger); } .okcard { border-color: var(--accent); }
.warncard { border-color: var(--gold, #c9a227); background: color-mix(in srgb, var(--gold, #c9a227) 12%, transparent); }
table.rules { width: 100%; border-collapse: collapse; } table.rules th, table.rules td { padding: .25rem .3rem; text-align: left; }
table.rules input[type=number] { width: 5.5rem; } table.rules input[type=time] { width: 7.2rem; }
.tablewrap { overflow-x: auto; } .nowrap { flex-wrap: nowrap; gap: .25rem; }
.wd-short { display: none; } @media (max-width: 560px) { .wd-full { display: none; } .wd-short { display: inline; } table.rules input[type=time] { width: 6.4rem; } }
.pending { margin: .6rem 0; padding: .5rem .7rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.pair { background: var(--surface-2); padding: .15rem .5rem; border-radius: var(--radius-sm); }

/* pranešimų varpelis */
.bell { position: relative; }
.bell-count { background: var(--gold); color: #2B1A1E; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 0 .35rem; margin-left: .25rem; }
.bell-panel { position: absolute; right: 0; top: 2.4rem; width: min(22rem, 90vw); max-height: 70vh; overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .6rem; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.bell-panel[hidden], .bell-count[hidden] { display: none; }
.bell-head { justify-content: space-between; margin-bottom: .4rem; }
.bell-item { display: block; padding: .45rem .3rem; border-bottom: 1px solid rgba(128,128,128,.25); color: inherit; text-decoration: none; }
.bell-item small { display: block; }
.bell-item.unread { font-weight: 600; border-left: 3px solid var(--gold); padding-left: .5rem; }

/* Profilio meniu */
.topbar .profile { position: relative; }
.topbar .profile-btn { width: 2.4rem; height: 2.4rem; padding: 0; border-radius: 50%; font-weight: 700; background: var(--gold); color: #2B1A1E; }
.menu-panel { position: absolute; right: 0; top: 2.9rem; min-width: 14rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .35rem; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,.25); display: grid; gap: .1rem; }
.menu-who { padding: .45rem .6rem; font-weight: 700; border-bottom: 1px solid var(--border); margin-bottom: .2rem; }
.topbar .menu-panel .menu-item { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); border: 0; border-radius: 8px; padding: .55rem .6rem; }
.topbar .menu-panel .menu-item:hover, .topbar .menu-panel .menu-item:focus-visible { background: var(--surface-2); }

/* Prisijungimo forma – centruota */
.auth h1 { text-align: center; }
.auth > .row[role=tablist] { justify-content: center; }
.auth form, .auth > div:not([role=tablist]) { max-width: 22rem; margin-left: auto; margin-right: auto; }
.auth label, .auth .muted, .auth form .error { text-align: center; }
.auth form > .row { justify-content: center; margin-top: .8rem; }
.auth input { text-align: center; }
.auth > div > p { text-align: center; }

/* Naudojimo laiko / mokyklos režimo dienų redaktorius */
.dayed { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin: .5rem 0; display: grid; gap: .45rem; }
.dayed h5 { margin: 0; font-size: 1rem; }
.dayed .breaks { display: grid; gap: .35rem; }
.dayed .breakrow { flex-wrap: wrap; }
.dayed input[type=number] { width: 6rem; }

/* Nustatymų langas */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-card { width: min(24rem, 100%); }
.settings-form { display: grid; gap: .8rem; }
.settings-form select { width: 100%; }

/* Savi laiko / datos laukai */
.picker { display: inline-flex; align-items: center; gap: .25rem; position: relative; }
.timepick select { width: auto; padding: .35rem .3rem; min-width: 3.4rem; }
.datebtn { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; font: inherit; min-width: 8.5rem; text-align: left; cursor: pointer; }
.datebtn.empty { color: var(--muted, #8a7a7e); }
.dp-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .6rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); width: 18.5rem; max-width: 92vw; display: grid; gap: .5rem; }
.dp-head { display: flex; gap: .3rem; align-items: center; }
.dp-head select { width: auto; flex: 1; min-width: 0; padding: .3rem; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { text-align: center; font-size: .8rem; color: var(--muted, #8a7a7e); padding: .2rem 0; }
.dp-day { background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 6px; padding: .45rem 0; cursor: pointer; font: inherit; }
.dp-day.other { opacity: .45; }
.dp-day.today { border-color: var(--gold); }
.dp-day.sel { background: var(--brand); color: #fff; opacity: 1; }
.dp-day:hover, .dp-day:focus-visible { background: var(--surface-2); }
.dp-day.sel:hover { background: var(--brand); }
.dp-foot { justify-content: space-between; }

/* Kompaktiškas savaitės tvarkaraštis */
.weekgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: .6rem; }
@media (max-width: 760px) { .weekgrid { grid-template-columns: 1fr; grid-auto-rows: auto; } }
.weekgrid .daycard { margin: 0; padding: .7rem .85rem; min-height: 9rem; }
.infocard p { margin: .25rem 0; }
.infocard .big { font-size: 1.5rem; }
.daycard h3 { margin: 0 0 .35rem; font-size: 1rem; display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.daycard .compact { margin: .2rem 0; }
.cmp { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cmp li { display: flex; gap: .4rem; align-items: baseline; padding: .15rem .25rem; border-radius: 6px; line-height: 1.25; }
.cmp li.cancelled { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.cmp li.changed { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.cmp .n { min-width: 1.4rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cmp .tm { min-width: 3rem; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.cmp .room { color: var(--muted); font-size: .85rem; }
.cmp .badge { font-size: .7rem; padding: 0 .4rem; }
.cmp li.club { border-top: 1px dashed var(--border); margin-top: 2px; }
.addrow input.narrow { width: 5.5rem; }

/* Kompaktiškas tvarkaraščio redagavimas */
.editgrid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(17rem, 1fr); gap: .6rem; align-items: start; }
.editside { display: grid; gap: .5rem; }
@media (max-width: 900px) { .editgrid { grid-template-columns: 1fr; } }
.editmain { margin: 0; padding: .7rem .85rem; }
.editmain h3 { margin: 0 0 .2rem; }
.small, .muted.small { font-size: .85rem; }
.row.tight { gap: .3rem; }
.sect { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm, 10px); padding: .4rem .75rem; }
.sect > summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.sect[open] > summary { margin-bottom: .4rem; }
.sect .list { margin: .3rem 0; }
.sect .addrow { gap: .3rem; }
.sect .addrow input, .sect .addrow select { flex: 1 1 8rem; min-width: 0; }
.sect .addrow input.narrow { flex: 0 0 5rem; }
.timegrid { grid-template-columns: 1fr; max-width: none; gap: .3rem; }
.timegrid > div { display: flex; align-items: center; gap: .3rem; flex-wrap: nowrap; }
.timegrid > div > span:first-child { width: 1.5rem; }
.timegrid .timepick select { padding: .15rem .2rem; min-width: 2.7rem; font-size: .85rem; }
.lgrid { grid-template-columns: 1.4rem repeat(5, minmax(5.5rem, 1fr)); gap: .25rem; }
.lgrid .cell { min-width: 0; }
.lgrid input { padding: .2rem .35rem; }

.weekbar { gap: .6rem; margin: .6rem 0; }
.weekbar .btn { margin: 0; white-space: nowrap; }
.timegrid .timepick { white-space: nowrap; display: inline-flex; align-items: center; }

/* Bendri tarpai: formų mygtukų eilė, greta esančios eilės, meniu punktai */
form > .row:last-child:not(.addrow) { margin-top: .8rem; }
form > .row.addrow + .row, .row + .row { margin-top: .6rem; }
form > .error:not(:empty) { margin-top: .5rem; }
.card > h2 + .row, .card > h3 + .row { margin-top: .3rem; }
.card > .row + :not(.row):not(ul):not(table) { margin-top: .6rem; }
.card > :not(.row):not(h2):not(h3) + .row { margin-top: .6rem; }
.topbar .menu-panel .menu-item + .menu-item { margin-top: .15rem; }
.addrow { gap: .5rem; row-gap: .6rem; }
ul.clean li .row, ul.clean li { row-gap: .4rem; }
.card > * + h3, .card form + h3, .card .row + h3 { margin-top: 1.2rem; }
.card > h2 + h3 { margin-top: .3rem; }
.row + label, form + label, .btn + label { margin-top: .8rem; }
form > .row + label { margin-top: .8rem; }
.card > h2 { margin-bottom: .6rem; }

/* Tvarkaraščio lentelė: langeliai ir siauri ekranai */
.lgrid .cell { display: grid; gap: .25rem; }
.editmain { overflow-x: auto; }
@media (max-width: 600px) { .lgrid { grid-template-columns: 1.2rem repeat(5, minmax(3.6rem, 1fr)); gap: .3rem; } .lgrid input { padding: .2rem .25rem; font-size: .8rem; } }
/* Vaiko kortelė: sutraukiami skyreliai */
details:not(.sect) { margin: .35rem 0; }
details:not(.sect) > summary { cursor: pointer; padding: .25rem 0; }
.card > .row.between { margin-bottom: .5rem; }
@media (max-width: 480px) { .weekbar { gap: .4rem; } .weekbar .btn.small { padding: .25rem .45rem; font-size: .85rem; } }
.lgrid .cell { gap: .4rem; }
.lgrid { gap: .4rem .4rem; }
.timegrid { gap: .45rem; }
.sect .addrow { gap: .5rem; row-gap: .55rem; }

/* Transportas */
[role=tablist] { margin: .8rem 0; }
.card [role=tablist] { margin-top: 0; }
.grow > .row > input { flex: 1 1 8rem; min-width: 0; width: auto; }
.card > .row, .card > .grow { margin-bottom: .6rem; }
.card > .row:last-child, .card > .grow:last-child { margin-bottom: 0; }
.card > .row + .grow, .card > .row + label { margin-top: .6rem; }
.citybar { gap: .6rem; } .citybar label { margin: 0; } .citybar select { width: auto; min-width: 12rem; }
