:root {
  --bg: #f5f5f5; --panel: #ffffff; --ink: #242424; --muted: #616161; --line: #e0e0e0;
  --accent: #5b5fc7; --accent-ink: #ffffff; --accent-soft: #e8ebfa;
  --free: #e7f4e4; --free-ink: #0e700e; --booked: #fdf3e1; --booked-ink: #8a5300;
  --tt: #ececec; --tt-ink: #424242; --closed: #f0f0f0; --danger: #c4314b; --danger-soft: #fde7e9;
  --urgent: #c4314b; --high: #bc4b09; --radius: 6px;
  --mine: #dbe8fd; --mine-ink: #0b4a9e; --mine-edge: #3b82f6;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1f1f1f; --panel: #292929; --ink: #ffffff; --muted: #adadad; --line: #3d3d3d;
  --accent: #7f85f5; --accent-ink: #111111; --accent-soft: #2f2f4a;
  --free: #1b3a1b; --free-ink: #92d18f; --booked: #4a3511; --booked-ink: #f5c26b;
  --tt: #3a3a3a; --tt-ink: #d6d6d6; --closed: #2e2e2e; --danger: #f1707b; --danger-soft: #4a1f26;
  --urgent: #f1707b; --high: #f7a35c; color-scheme: dark;
  --mine: #17345e; --mine-ink: #a9cbff; --mine-edge: #5b9bff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--accent);
  color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 8px 12px; border-radius: var(--radius); text-decoration: none; color: var(--muted); white-space: nowrap; }
.tabs a:hover { background: var(--bg); color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }

.view { padding: 16px; max-width: 1200px; margin: 0 auto; outline: none; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { min-width: 0; }
.grow { flex: 1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 140px; }
label.f.wide { flex: 1 1 280px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; min-height: 34px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; min-height: 34px; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 3px 10px; min-height: 28px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 6px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 760px; table-layout: fixed; }
.grid thead th:first-child { width: 130px; }
.grid th { font-weight: 600; font-size: 12px; color: var(--muted); text-align: left; padding: 2px 4px; }
.grid th small { display: block; font-weight: 400; }
.grid th.rowh { width: 130px; color: var(--ink); font-size: 13px; }
.cell { border-radius: var(--radius); padding: 6px 8px; height: 58px; vertical-align: top; font-size: 12px; line-height: 1.3; }
.cell b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.free { background: var(--free); color: var(--free-ink); }
.cell.booked { background: var(--booked); color: var(--booked-ink); }
.cell.timetabled { background: var(--tt); color: var(--tt-ink); }
.cell.closed { background: var(--closed); color: var(--muted); }
.cell.empty { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.cell.clickable { cursor: pointer; }
.cell.clickable:hover { outline: 2px solid var(--accent); }
.cell.sel { outline: 2px solid var(--accent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }

.periods { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.period { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: flex; gap: 8px; align-items: flex-start; }
.period.free { background: var(--free); color: var(--free-ink); cursor: pointer; }
.period.taken { background: var(--tt); color: var(--tt-ink); }
.period.booked { background: var(--booked); color: var(--booked-ink); }
.period small { display: block; opacity: .85; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.item .main { flex: 1 1 260px; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item.urgent { border-left: 4px solid var(--urgent); }
.item.high { border-left: 4px solid var(--high); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--ink); margin-left: 6px; font-weight: 400; }
.pill.Done { background: var(--free); color: var(--free-ink); }
.pill.Cancelled { background: var(--closed); color: var(--muted); }
.pill.New { background: var(--booked); color: var(--booked-ink); }
.events { font-size: 12px; color: var(--muted); margin: 6px 0 0; padding-left: 16px; }

.notice { border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; background: var(--accent-soft); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.drawer { border: 2px solid var(--accent); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(calc(100% + 40px)); visibility: hidden; background: var(--ink); color: var(--panel);
  padding: 10px 16px; border-radius: 8px; transition: transform .2s; max-width: calc(100% - 32px); z-index: 20; }
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast.err { background: var(--danger); color: #fff; }
code.feed { word-break: break-all; font-size: 12px; background: var(--bg); padding: 6px 8px; border-radius: 4px; display: block; margin: 6px 0; }
table.plain { border-collapse: collapse; width: 100%; }
.plain th, .plain td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.weeks label { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; font-size: 13px; }
.weeks select { min-height: 28px; padding: 2px 6px; }
.weeks .Holiday { background: var(--booked); }
@media (max-width: 640px) {
  .view { padding: 12px; }
  .who { font-size: 12px; margin-left: auto; }
  label.f { min-width: 0; flex: 1 1 100%; }
}

.ask { position: fixed; inset: 0; background: rgb(0 0 0 / .35); display: grid; place-items: center; z-index: 30; padding: 16px; }
.ask-box { background: var(--panel); color: var(--ink); border-radius: 10px; padding: 18px 20px; max-width: 380px; width: 100%; box-shadow: 0 8px 30px rgb(0 0 0 / .25); }
.ask-box p { margin: 0 0 14px; font-size: 15px; }

.edit-hint { float: right; opacity: .7; }
a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
.plain th { width: 130px; color: var(--muted); font-weight: 600; }

.cell.mine, .period.mine { background: var(--mine); color: var(--mine-ink); box-shadow: inset 3px 0 0 var(--mine-edge); }

.plain td .btn { white-space: nowrap; margin: 2px 0; }
