:root {
  --asphalt: #1F2225;
  --asphalt-2: #2A2E33;
  --asphalt-3: #383D43;
  --concrete: #62D2FB;
  /* barvy dlaždic na mapě — záměrně nezávislé na pozadí aplikace */
  --spot-free: #EDEAE4;
  --spot-taken: #474D54;
  --spot-taken-edge: #7A848D;
  --spot-taken-text: #E3E7EA;
  --card: #FFFFFF;
  --concrete-2: #46BFEC;
  --paint: #F0C33C;
  --paint-dark: #8A6B10;
  --rust: #B0463C;
  --ink: #15171A;
  --ink-soft: #35414B;
  --line: #1B6B8F;
  --ok: #3C7A55;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--concrete);
  color: var(--ink);
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; font-size: 16px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 10px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.lang-select {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  color: var(--ink);
}

.icon-btn {
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.icon-btn:active { background: var(--concrete-2); }

/* ---------- day switcher ---------- */

.daybar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 14px;
}

.day-nav {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.day-nav:disabled { opacity: 0.3; }
.day-nav:active:not(:disabled) { background: var(--concrete-2); }

.day-info { flex: 1; text-align: center; min-width: 0; }

.day-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.day-date {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 3px;
}

.day-count {
  font-size: 13px;
  font-weight: 600;
  margin-top: 2px;
}
.day-count.none { color: var(--rust); }

/* ---------- map ---------- */

.map {
  background: var(--asphalt);
  border-radius: 14px;
  padding: 18px 14px;
  position: relative;
}

.map-grid {
  display: grid;
  grid-template-columns: 1fr 46px 1fr;
  gap: 8px 0;
  align-items: stretch;
}

.lane-label {
  grid-column: 2;
  grid-row: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.lane-label::before,
.lane-label::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, #4A5057 0 14px, transparent 14px 26px);
}
.lane-label::before { left: 3px; }
.lane-label::after { right: 3px; }

.lane-gap {
  position: relative;
  min-height: 26px;
}
.lane-gap::before,
.lane-gap::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  background: repeating-linear-gradient(to right, #4A5057 0 14px, transparent 14px 26px);
}
.lane-gap::before { top: 3px; }
.lane-gap::after { bottom: 3px; }

.spot {
  border: 0;
  border-radius: 4px;
  padding: 10px 6px;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--asphalt-2);
  box-shadow: inset 0 0 0 2px #4A5057;
  transition: transform 0.08s ease;
}
.spot:active { transform: scale(0.97); }

.spot-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #8A9199;
}

.spot-who {
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: #8A9199;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot.free {
  background: var(--spot-free);
  box-shadow: inset 0 0 0 2px #FFFFFF;
}
.spot.free .spot-num { color: var(--ink); }
.spot.free .spot-who { color: var(--ink-soft); }

.spot.mine {
  background: var(--paint);
  box-shadow: inset 0 0 0 2px #FFD866;
}
.spot.mine .spot-num,
.spot.mine .spot-who { color: #2E2200; }

.spot.taken {
  background: var(--spot-taken);
  box-shadow: inset 0 0 0 2px var(--spot-taken-edge);
}
.spot.taken .spot-num,
.spot.taken .spot-who { color: var(--spot-taken-text); }

.spot.reserved {
  background: repeating-linear-gradient(45deg, var(--asphalt-2) 0 7px, var(--asphalt-3) 7px 14px);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 14px 2px 0;
  margin-top: 12px;
  border-top: 1px solid #383D43;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #8A9199;
}

.swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.swatch.free { background: var(--concrete); }
.swatch.mine { background: var(--paint); }
.swatch.taken { background: var(--spot-taken); box-shadow: inset 0 0 0 1.5px var(--spot-taken-edge); }

/* ---------- my bookings ---------- */

.section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 26px 0 10px;
}

.booking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.booking-spot {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  background: var(--paint);
  color: #2E2200;
  border-radius: 5px;
  padding: 7px 9px;
  flex-shrink: 0;
}

.booking-when { flex: 1; min-width: 0; }
.booking-day { font-size: 14px; font-weight: 600; }
.booking-time { font-size: 12px; color: var(--ink-soft); }

.empty-note {
  font-size: 14px;
  color: var(--ink-soft);
  padding: 6px 2px 0;
}

/* ---------- sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 23, 26, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  background: var(--card);
  width: 100%;
  max-width: 560px;
  border-radius: 16px 16px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: rise 0.2s ease;
  max-height: 92dvh;
  overflow-y: auto;
}
@keyframes rise { from { transform: translateY(16px); } to { transform: none; } }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-spot {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  background: var(--asphalt);
  color: #EDEAE4;
  border-radius: 7px;
  padding: 10px 12px;
}

.sheet-title { font-size: 15px; font-weight: 600; }
.sheet-status { font-size: 13px; color: var(--ink-soft); }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 0;
  font-size: 16px;
  font-weight: 600;
  margin-top: 10px;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--asphalt); color: var(--concrete); }
.btn-secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger { background: var(--rust); color: #fff; }
.btn:disabled { opacity: 0.5; }

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--concrete-2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 4px;
}

.mode-tab {
  flex: 1;
  padding: 9px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.mode-tab.on { background: #fff; color: var(--ink); }

.dial-readout {
  text-align: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 4px 0 0;
}
.dial-dur { text-align: center; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }

.dial-wrap { display: flex; justify-content: center; }
.dial { width: 100%; max-width: 320px; touch-action: none; }
.dial .handle { cursor: grab; }

.msg {
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 14px;
  margin-top: 12px;
}
.msg-error { background: #F7E4E2; color: #7A2A22; }
.msg-warn { background: #FBEFD2; color: #6B5210; }
.msg-ok { background: #E1EFE6; color: #23543A; }

/* ---------- auth ---------- */

.auth {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 0;
  max-width: 380px;
  width: 100%;
  margin: 0 auto;
}
.auth-top {
  position: absolute;
  top: 14px;
  right: 16px;
}

.auth-brand {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 46px;
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.auth-sub { color: var(--ink-soft); font-size: 15px; margin: 6px 0 26px; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input {
  width: 100%;
  padding: 13px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.field input:focus { outline: 2px solid var(--asphalt); outline-offset: -1px; border-color: transparent; }
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.row-2 { display: flex; gap: 10px; }
.row-2 .field { flex: 1; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--ink-soft);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.link-btn {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: underline;
  padding: 16px 0 0;
}

.spinner {
  text-align: center;
  padding: 60px 0;
  color: var(--ink-soft);
  font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- admin ---------- */

.admin-select {
  width: 100%;
  padding: 13px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 4px;
  font-size: 15px;
}
.check-row input { width: 20px; height: 20px; accent-color: var(--asphalt); }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
}
.tag-admin { background: var(--paint); color: #2E2200; }
.tag-blocked { background: var(--rust); color: #fff; }

/* žádosti nahoře — ať je jasné, že čekají na reakci */
#incomingTitle { margin-top: 10px; }
#incomingList .booking-row {
  border-color: var(--paint-dark);
  border-left: 4px solid var(--paint);
  background: #FDF6E3;
}

/* ---------- kalendář ---------- */

.day-info { cursor: pointer; border-radius: var(--radius); padding: 2px 6px; }
.day-info:active { background: var(--concrete-2); }
.day-label::after { content: ' ▾'; font-size: 15px; opacity: 0.45; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-month {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 4px;
}
.cal-day {
  aspect-ratio: 1;
  border: 0;
  background: transparent;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.cal-day:disabled { opacity: 0.25; }
.cal-day.other { opacity: 0.3; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--line); }
.cal-day.sel { background: var(--asphalt); color: var(--card); }
.cal-free {
  font-size: 10px;
  font-weight: 600;
  color: var(--ok);
  line-height: 1;
}
.cal-day.sel .cal-free { color: #9BD6B0; }
.cal-free.none { color: var(--rust); }
.cal-day.sel .cal-free.none { color: #F0A9A2; }

/* ---------- bonzlist ---------- */

.board-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.board-tab {
  flex: 1;
  padding: 9px;
  border: 1.5px solid var(--line);
  background: transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.board-tab.on { background: var(--asphalt); border-color: var(--asphalt); color: var(--card); }

.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.board-rank {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 20px;
  width: 34px;
  text-align: center;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.board-rank.medal { font-size: 22px; }
.board-plate {
  flex: 1;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 0.09em;
  background: #fff;
  border: 2px solid var(--asphalt);
  border-radius: 5px;
  padding: 5px 10px;
  text-align: center;
}
.board-count {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.board-row.top1 { border-color: var(--paint-dark); background: #FDF6E3; }

.plate-input {
  width: 100%;
  padding: 13px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.plate-input:focus { outline: 2px solid var(--asphalt); outline-offset: -1px; }

.code-input {
  width: 100%;
  padding: 14px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
}
.code-input:focus { outline: 2px solid var(--asphalt); outline-offset: -1px; }

.btn-note {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 5px;
}

/* bílé plochy na sytější modré potřebují zřetelný okraj */
.booking-row, .board-row { border-color: #1B6B8F; }
.field input, .admin-select, .plate-input, .code-input { border-color: #1B6B8F; }
.icon-btn, .lang-select, .day-nav, .board-tab { border-color: #1B6B8F; }
.sheet, .cal-head + #calGrid { background: var(--card); }

/* prasátka */
.pig-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  line-height: 0;
}
.pig-title { display: inline-flex; align-items: center; gap: 8px; }
.pig-title svg { flex-shrink: 0; }
.board-rank.pig { display: flex; align-items: center; justify-content: center; }
.board-rank.pig svg { display: block; }

/* ---------- upozornění ---------- */

.push-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 24px;
  font-size: 15px;
  font-weight: 600;
}
.push-row .btn { width: auto; margin: 0; padding: 9px 16px; font-size: 14px; }
.push-row .hint { width: 100%; font-size: 12px; color: var(--ink-soft); font-weight: 400; }

/* hlavička po přesunu nastavení — zůstávají jen dvě ikony */
.brand-mark { max-width: none; }
.push-row .lang-select { margin-left: auto; }
.push-row > span:first-child { margin-right: auto; }
#settingsBtn svg { color: var(--ink); }

/* místo obsazené jen část dne — volné, ale s upozorněním */
/* zčásti volné = pruhy volného a obsazeného místa */
.spot.partial {
  background-color: var(--spot-free);
  background-image: repeating-linear-gradient(135deg,
    var(--spot-taken) 0 7px, transparent 7px 16px);
  box-shadow: inset 0 0 0 2px var(--spot-taken-edge);
}
.spot.partial .spot-num { color: var(--ink); }
.spot.partial .spot-who { color: #2E343A; font-weight: 600; }

.swatch.partial {
  background-color: var(--spot-free);
  background-image: repeating-linear-gradient(135deg,
    var(--spot-taken) 0 4px, transparent 4px 9px);
}

.mode-tab-off { opacity: 0.35; }

/* zpět na přehled aplikací */
.brand-back {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 26px;
  line-height: 1;
  padding: 0 6px 0 0;
  align-self: center;
}
.brand { align-items: center; }
