:root {
    --bg: #2b1d57; --bg2: #0d0820; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #f4f0ff; --muted: #d2c8f5; --accent: #b197fc; --accent-ink: #1d0f4a; --link: #c5b3ff; --field: rgba(255,255,255,.08);
    --soft: rgba(177,151,252,.17); --good: #69db7c; --bad: #ffa8a8; --warn: #ffd43b; --plan: rgba(177,151,252,.45);
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #f6f3ff; --bg2: #e9e2ff; --card: #fff; --line: #d8cdfa; --ink: #1f1147; --muted: #574a85;
            --accent: #6741d9; --accent-ink: #fff; --link: #5a35c9; --field: #fdfcff; --soft: #efeaff; --good: #2b8a3e; --bad: #c92a2a; --warn: #9a5b00; --plan: #c4b4f7; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #f6f3ff; --bg2: #e9e2ff; --card: #fff; --line: #d8cdfa; --ink: #1f1147; --muted: #574a85;
            --accent: #6741d9; --accent-ink: #fff; --link: #5a35c9; --field: #fdfcff; --soft: #efeaff; --good: #2b8a3e; --bad: #c92a2a; --warn: #9a5b00; --plan: #c4b4f7; color-scheme: light; }
:root[data-theme="dark"] {
    --bg: #2b1d57; --bg2: #0d0820; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #f4f0ff; --muted: #d2c8f5; --accent: #b197fc; --accent-ink: #1d0f4a; --link: #c5b3ff; --field: rgba(255,255,255,.08);
    --soft: rgba(177,151,252,.17); --good: #69db7c; --bad: #ffa8a8; --warn: #ffd43b; --plan: rgba(177,151,252,.45);
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: var(--bg2) linear-gradient(180deg, var(--bg), var(--bg2) 900px) no-repeat; touch-action: manipulation; }
.app { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; }
.col-a, .col-b { display: contents; }
.app > .topbar, .app > .back { order: 0; }
.app > header { order: 1; }
.app > .warn, .app > #top-msg { order: 2; }
#week { order: 3; }
.add { order: 4; }
#shifts-sec { order: 5; }
#hist { order: 6; }
.rule { order: 7; }
.hols { order: 8; }
.tools { order: 9; }
.app > .faq { order: 10; }
.app > footer { order: 11; }
header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; overflow-wrap: anywhere; }
.sub { margin: .4rem 0 0; color: var(--muted); font-size: 1rem; }
h2 { margin: 0 0 .7rem; font-size: 1.15rem; overflow-wrap: anywhere; }
.warn { margin: 0 0 .9rem; padding: .7rem .85rem; border-radius: 12px; border: 1px solid var(--bad); color: var(--bad); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; min-width: 0; }
label { display: block; margin: .9rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; }
input[type=text], input[type=date], input[type=time], select { width: 100%; min-width: 0; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
       background: var(--field); border: 1px solid var(--line); border-radius: 12px; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; display: block; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; }
input[aria-invalid="true"] { border-color: var(--bad); }
select option { color: #111; background: #fff; }
input:focus-visible, textarea:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .75; }
textarea { width: 100%; min-width: 0; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 12px; resize: vertical; }
.hint { margin: .45rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.hint.bad { color: var(--bad); font-weight: 600; }
.hint.warn { color: var(--warn); font-weight: 600; border: 0; padding: 0; margin: .45rem 0 0; }
.hint.good { color: var(--good); font-weight: 600; }
[hidden] { display: none !important; }
.sub-box { margin: .4rem 0 0; padding: .1rem .9rem .9rem; border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 .6rem; min-width: 0; }
.two > div { min-width: 0; }
.len { margin: .6rem 0 0; font-weight: 700; color: var(--accent); overflow-wrap: anywhere; }
.len:empty { margin: 0; }
.len.over { color: var(--bad); }
.emp-chips { margin-top: .5rem; }
.rule-sum { margin: .6rem 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* buttons */
.primary, .secondary { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: .5rem .8rem; border-radius: 12px;
       font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; line-height: 1.2; overflow-wrap: anywhere; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); }
.secondary { border: 1px solid var(--line); background: var(--field); color: var(--ink); font-weight: 600; }
.secondary:disabled { opacity: .5; cursor: default; }
.secondary.del { color: var(--bad); }
.danger { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; border-radius: 12px; font: inherit; cursor: pointer;
       border: 1px solid var(--bad); background: transparent; color: var(--bad); font-weight: 600; margin-top: .9rem; }
.link { display: block; min-height: 44px; margin-top: .3rem; padding: 0 .1rem; border: 0; background: none; color: var(--link); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.link.inline { display: inline; min-height: 0; margin: 0; padding: .3rem .1rem; text-decoration: underline; }
.row-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.row-btns > * { flex: 1 1 8rem; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-top: .9rem; }
.tool-grid .wide { grid-column: 1 / -1; }
.chip { min-height: 44px; padding: 0 .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: .45rem; min-width: 0; }
#brk-chips { margin-top: .6rem; }

.err { margin: .4rem 0 0; color: var(--bad); font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.err:empty { margin: 0; }
.msg { margin: 0; color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.msg.show { margin-top: .8rem; padding: .6rem .75rem; border-radius: 12px; background: var(--soft); color: var(--ink); }
.msg.bad.show { border: 1px solid var(--warn); }
#top-msg.show { margin: 0 0 .9rem; }

/* week answer */
.sum { border-top: 6px solid var(--accent); }
.week-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: .4rem; margin-bottom: .9rem; }
.week-nav > button { min-height: 44px; font-size: .93rem; padding: .3rem .4rem; }
.sum h2 { margin-bottom: .25rem; font-size: 1rem; color: var(--muted); }
.sum h2 #week-name { color: var(--ink); }
.range { font-weight: 600; }
.big { margin: 0; font-size: 2.2rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.big.good { color: var(--good); }
.big.bad { color: var(--bad); }
.big.warn { color: var(--warn); }
.bar { position: relative; height: 14px; margin: .7rem 0 .2rem; border-radius: 999px; background: var(--field); border: 1px solid var(--line); overflow: hidden; }
.bar span, .bar i { position: absolute; top: 0; bottom: 0; left: 0; width: 0; }
.bar span { background: var(--accent); }
.bar i { background: var(--plan); }
.bar.over span { background: var(--bad); }
.s-sub { margin: .3rem 0 0; color: var(--muted); overflow-wrap: anywhere; }
.stats { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.stats li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 .8rem; padding: .45rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; min-width: 0; }
.stats li span:first-child { color: var(--muted); min-width: 0; }
.stats li b { text-align: right; min-width: 0; }
.stats li.over b { color: var(--bad); }
.stats li.note b { font-weight: 600; color: var(--warn); text-align: left; }
.stats li.head span:first-child { color: var(--ink); font-weight: 700; }
.stats li.emp span:first-child { padding-left: .8rem; }
.over-box { margin-top: .8rem; padding: .6rem .8rem; border: 1px solid var(--bad); border-radius: 12px; }
.o-h { margin: 0; font-weight: 700; color: var(--bad); overflow-wrap: anywhere; }
.over-box ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.over-box li { overflow-wrap: anywhere; }
.rule-line { margin: .8rem 0 0; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }

/* shifts */
.list-sec { margin-bottom: .9rem; min-width: 0; }
.list-sec > h2 { margin: .3rem 0 .6rem; }
.i-list { display: grid; gap: .7rem; min-width: 0; }
.empty { margin: 0 0 .3rem; padding: .9rem 1rem; border: 1px dashed var(--line); border-radius: 14px; }
.item { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: 14px; padding: .9rem 1rem 1rem; min-width: 0; scroll-margin-top: 1rem; }
.item.worked { border-left-color: var(--accent); }
.item.planned { border-left-color: var(--plan); border-style: solid solid solid solid; }
.item.editing { border-color: var(--accent); border-width: 2px 2px 2px 6px; }
.it-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .1rem .8rem; min-width: 0; }
.it-name { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; min-width: 0; }
.it-hours { font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.item p { margin: .25rem 0 0; overflow-wrap: anywhere; }
.it-meta { color: var(--muted); font-size: .92rem; }
.it-meta.strong { color: var(--ink); font-weight: 600; font-size: 1rem; }
.it-note { font-size: .95rem; padding-left: .6rem; border-left: 3px solid var(--line); white-space: pre-line; }
.tag { display: inline-block; padding: 0 .5rem; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.t-done { background: var(--accent); color: var(--accent-ink); }
.t-plan { border: 1px dashed var(--accent); color: var(--ink); }
.it-btns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr); gap: .4rem; margin-top: .7rem; }
.it-btns.one { grid-template-columns: minmax(0, 1fr); max-width: 10rem; }
.it-btns > * { min-height: 44px; font-size: .93rem; padding: .3rem .4rem; }
.hol-list { margin: .8rem 0; }
.hol-list:empty { margin: .4rem 0 0; }
.item.hol { border-left-color: var(--good); padding: .7rem .9rem .8rem; }

/* every week */
.weeks { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .4rem; }
.wk { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .1rem .8rem; width: 100%; min-height: 44px; padding: .55rem .8rem; border: 1px solid var(--line); border-left: 5px solid var(--good); border-radius: 10px;
      background: var(--field); color: var(--ink); font: inherit; font-size: .95rem; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.wk b { text-align: right; }
.wk.over { border-left-color: var(--bad); }
.wk.over b { color: var(--bad); }
.wk.plan-over { border-left-color: var(--warn); }
.wk.plan-over b { color: var(--warn); }
.wk[aria-current="true"] { border-color: var(--accent); border-left-width: 5px; }
.wk-range { min-width: 0; }
#hist-more { margin-top: .6rem; }

/* questions */
.faq { margin-top: 1.2rem; }
.faq details { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 .5rem; background: var(--card); }
.faq summary { cursor: pointer; padding: .75rem .9rem; font-weight: 600; min-height: 44px; }
.faq details p { margin: 0; padding: 0 .9rem .8rem; color: var(--muted); }
footer { margin-top: 1.4rem; text-align: center; font-size: .9rem; }
footer a { color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }

/* narrow phones */
@media (max-width: 400px) {
    .card { padding: .95rem .85rem; }
    .item { padding: .8rem .75rem .9rem; }
    .sub-box { padding: .1rem .6rem .8rem; }
    .chip { padding: 0 .75rem; }
    .it-btns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .it-btns > :nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
}
@media (max-width: 359px) {
    .tool-grid { grid-template-columns: minmax(0, 1fr); }
    .two { grid-template-columns: minmax(0, 1fr); }
    .big { font-size: 1.9rem; }
}
@media (max-width: 360px) {
    .topbar .theme-toggle { padding: 0; width: 44px; justify-content: center; }
    .topbar .theme-toggle span { display: none; }
}

/* laptops and desktops: adding a shift and the settings on the left, the week answer and the shifts on the right */
@media (min-width: 900px) {
    .app { width: min(1160px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; }
    .col-a, .col-b { display: block; min-width: 0; }
    .app > .topbar { grid-row: 1; }
    .app > header { grid-row: 2; }
    .app > .warn { grid-row: 3; }
    .app > #top-msg { grid-row: 4; }
    .app > .col-a { grid-column: 1; grid-row: 5; }
    .app > .col-b { grid-column: 2; grid-row: 5; }
    .app > .faq { grid-row: 6; width: min(760px, 100%); justify-self: center; }
    .app > footer { grid-row: 7; width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.2rem; }
    header .sub { max-width: 760px; margin-left: auto; margin-right: auto; }
    .big { font-size: 2.6rem; }
    .item { padding: 1rem 1.2rem 1.1rem; }
}
