:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a64;
  --line: #e2e0d8;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe8;
  --mine: #2f8a5c;
  --mine-off: #f3dede;
  --danger: #b3261e;
  --heat-0: #eeede8;
  --lv1: #fbeeb0;
  --lv2: #dfe98f;
  --lv3: #a6d77f;
  --lv4: #5fb878;
  --all: #16723f;
  --lv-ink: #2b3a1c;
  --all-ink: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --card: #1d1f1c;
    --ink: #ecebe6;
    --muted: #9c9b94;
    --line: #2f312d;
    --accent: #6cc59a;
    --accent-ink: #0f1a14;
    --accent-soft: #20352a;
    --mine: #4fb27f;
    --mine-off: #3a2626;
    --danger: #f2a49e;
    --heat-0: #262825;
    --lv1: #4d4521;
    --lv2: #4f5d22;
    --lv3: #3f7a33;
    --lv4: #3d9c56;
    --all: #7ee8a4;
    --lv-ink: #f0f3e6;
    --all-ink: #0b2615;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 640px; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 16px 16px 0;
}
.logo { font-weight: 700; font-size: 20px; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.logo span { color: var(--accent); }

h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 8px 0 8px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 20px; }

label.field { display: block; }
label.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=password], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
  padding: 10px 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 500; }

.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 8px 0 0; }

/* ---------- Kalendarz wyboru dni ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head strong { text-transform: capitalize; }
.cal-head button { padding: 6px 12px; }
.cal {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal .day {
  aspect-ratio: 1 / 1; max-height: 52px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: var(--bg); cursor: pointer; font-size: 15px; border: 1px solid transparent;
}
.cal .day.past { color: var(--muted); opacity: .45; cursor: default; }
.cal .day.today { border-color: var(--accent); }
.cal .day.sel { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cal .day.blank { background: none; cursor: default; }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------- Strona wydarzenia ---------- */
.event-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share input { width: min(340px, 70vw); font-size: 14px; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .panels { grid-template-columns: 1fr; } }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }

.tabs { display: none; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; border: none; background: none; padding: 8px; }
.tabs button.on { background: var(--accent-soft); color: var(--ink); }
@media (max-width: 860px) {
  .tabs { display: flex; }
  .panels > [data-tab]:not(.show) { display: none; }
}

.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.grid {
  display: grid; user-select: none; -webkit-user-select: none;
  font-size: 12px; min-width: min-content;
}
.grid .corner, .grid .colh, .grid .rowh { background: var(--card); }
.grid .colh { text-align: center; padding: 0 2px 6px; line-height: 1.2; position: sticky; top: 0; }
.grid .colh b { display: block; font-size: 13px; }
.grid .colh small { color: var(--muted); text-transform: capitalize; }
.grid .rowh {
  text-align: right; padding-right: 6px; color: var(--muted); font-variant-numeric: tabular-nums;
  position: sticky; left: 0; z-index: 1; transform: translateY(-.65em); height: 0; overflow: visible;
}
.grid .cell {
  height: 20px; min-width: 44px; border-right: 1px solid var(--line); background: var(--heat-0);
}
.grid .cell.hour { border-top: 1px solid var(--line); }
.grid .cell.half { border-top: 1px dotted var(--line); }
.grid .cell.first { border-left: 1px solid var(--line); }
.grid .cell.last-row { border-bottom: 1px solid var(--line); }
.grid.mine .cell { touch-action: none; }
.grid.mine .cell { cursor: pointer; background: var(--mine-off); }
.grid.mine .cell.on { background: var(--mine); }
/* Mapa grupy: wyraźne stopnie kolorów + liczba osób w polu */
#gridAll .cell {
  border: 0; box-shadow: inset 0 0 0 1px var(--card);
  font-size: 11px; line-height: 20px; text-align: center; font-weight: 600;
  color: var(--lv-ink); font-variant-numeric: tabular-nums; cursor: default;
}
#gridAll .cell.hour { box-shadow: inset 0 2px 0 var(--card), inset 0 0 0 1px var(--card); }
#gridAll .cell.lv1, .sw.lv1 { background: var(--lv1); }
#gridAll .cell.lv2, .sw.lv2 { background: var(--lv2); }
#gridAll .cell.lv3, .sw.lv3 { background: var(--lv3); }
#gridAll .cell.lv4, .sw.lv4 { background: var(--lv4); }
#gridAll .cell.all, .sw.all { background: var(--all); }
#gridAll .cell.all { color: var(--all-ink); font-weight: 800; }
.sw.lv0 { background: var(--heat-0); }
#gridAll.picking .cell:not(.pick) { opacity: .4; filter: grayscale(.6); }
#gridAll .cell.pick { outline: 2px solid var(--ink); outline-offset: -2px; position: relative; z-index: 2; }
.legend .lg-item { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); }
.legend .sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.best li { cursor: pointer; border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.best li.on { background: var(--accent-soft); }
.grid .cell.hl { outline: 2px solid var(--ink); outline-offset: -2px; position: relative; z-index: 2; }
.grid.locked { opacity: .5; pointer-events: none; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.legend .bar { display: flex; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.legend .bar i { width: 18px; height: 12px; display: block; }

.who { margin-top: 12px; font-size: 14px; min-height: 3em; }
.who .ok { color: var(--accent); }
.who .no { color: var(--muted); text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); }

.best { margin-top: 16px; }
.best ol { margin: 6px 0 0; padding-left: 20px; }
.best li { margin: 2px 0; }

.login-box { max-width: 380px; }
.status { font-size: 13px; color: var(--muted); }
.status.saving { color: var(--muted); }
.status.saved { color: var(--accent); }
.status.err { color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 16px; }
