:root {
  color-scheme: dark;
  --bg: #0c110d;
  --panel: rgba(16, 22, 17, 0.88);
  --panel-solid: #141b16;
  --line: rgba(212, 188, 134, 0.28);
  --line-soft: rgba(197, 214, 161, 0.14);
  --text: #f3f6ef;
  --muted: #b7c0ae;
  --faint: #879280;
  --brass: #d4bc86;
  --olive: #c5d6a1;
  --ink: #1c2416;
  --danger: #e7b1b1;
  --ok: #b7d7c4;
  --sans: Manrope, "Segoe UI", sans-serif;
  --display: Oswald, Manrope, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 12, 9, 0.42), rgba(8, 12, 9, 0.72)),
    url("/magazin/recon.svg") center / cover no-repeat;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(197, 214, 161, 0.35); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  width: min(1240px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
}

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.eyebrow {
  margin: 0;
  color: var(--brass);
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.brand h1, .week-title h2, .dock-head h2, .lock-card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand h1 { font-size: 1.7rem; line-height: 1; }
.logo {
  position: relative;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--brass);
  background: rgba(20, 27, 22, 0.8);
}
.logo::before, .logo::after {
  content: "";
  position: absolute;
  background: var(--brass);
}
.logo::before { left: 6px; right: 6px; top: 20px; height: 1px; }
.logo::after { top: 6px; bottom: 6px; left: 20px; width: 1px; }
.logo i {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 188, 134, 0.7);
  border-radius: 50%;
}

.modes {
  display: flex;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--line);
  background: rgba(12, 17, 13, 0.72);
}
.mode {
  min-width: 132px;
  padding: 12px 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.mode + .mode { border-left: 1px solid var(--line); }
.mode.on { background: var(--brass); color: var(--ink); }

.top-side { text-align: right; }
.clock, .share, .pill { margin: 0; }
.clock {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
.share, .pill { color: var(--muted); font-size: 0.82rem; }
.share { margin-top: 2px; }
.pill {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(183, 215, 196, 0.65);
  animation: pulse 2.4s infinite;
}
.pill.off i { background: var(--faint); animation: none; box-shadow: none; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(183, 215, 196, 0); }
}

.view { display: none; }
#duty-view.on {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100dvh - 112px);
}
#shop-view.on { display: block; }
body.shop-mode { overflow: hidden; height: 100%; }
body.shop-mode .app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}
body.shop-mode #shop-view.on { flex: 1; min-height: 0; }
#shop-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  background: #0c110d;
}

.weekbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.week-title { flex: 1; min-width: 0; }
.week-title h2 { font-size: 1.35rem; }
.step, .today-btn, .dock-head button, .lock-card button, .chip button {
  border: 1px solid var(--line);
  background: rgba(20, 27, 22, 0.9);
  color: var(--text);
}
.step {
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  line-height: 1;
}
.today-btn, .dock-head button, .lock-card button {
  height: 42px;
  padding: 0 14px;
  font-family: var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.today-btn[hidden] { display: none; }
.today-btn:hover, .step:hover, .dock-head button:hover, .mode:hover { border-color: var(--brass); }
.dock-head button, .lock-card button {
  background: var(--brass);
  color: var(--ink);
  border-color: transparent;
  font-weight: 600;
}

.hint, .banner {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.banner {
  padding: 10px 12px;
  border: 1px solid rgba(231, 177, 177, 0.45);
  color: var(--danger);
}
.hidden { display: none !important; }

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  flex: 1;
}
.day {
  min-width: 0;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.day.today { border-color: var(--brass); }
.day-head { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; margin-bottom: 8px; }
.dow {
  margin: 0;
  font-family: var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}
.date { margin: 0; color: var(--muted); font-size: 0.78rem; }
.day.weekend .dow { color: var(--olive); }
.now-mark {
  color: var(--brass);
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.slot {
  min-height: 92px;
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed rgba(197, 214, 161, 0.28);
  background: rgba(8, 12, 9, 0.35);
}
.slot.now {
  border-style: solid;
  border-color: var(--brass);
  background: rgba(212, 188, 134, 0.08);
}
.board.armed .slot { cursor: pointer; }
.slot.over {
  border-style: solid;
  border-color: var(--olive);
  background: rgba(197, 214, 161, 0.12);
}
.slot-label { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.hours {
  margin: 0;
  font-family: var(--display);
  letter-spacing: 0.04em;
  font-size: 0.92rem;
}
.shift-name {
  margin: 0;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.slot-empty {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 0.78rem;
}
.names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip, .drag-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(212, 188, 134, 0.45);
  background: #1b241c;
  color: var(--text);
  user-select: none;
  touch-action: none;
}
.chip { cursor: grab; }
.chip span, .drag-ghost { font-weight: 600; font-size: 0.92rem; }
.chip.on {
  background: var(--brass);
  color: var(--ink);
  border-color: transparent;
}
.chip button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  line-height: 1;
  font-size: 1rem;
}
.drag-ghost {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  transform: translate(-50%, -60%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.dock.over { border-color: var(--olive); }

.dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: auto;
  padding: 12px;
  background: rgba(12, 17, 13, 0.94);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.dock-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}
.dock-head h2 { font-size: 1.15rem; }
#person-form { display: flex; gap: 8px; flex: 1; max-width: 460px; min-width: 0; }
#person-name, .lock-card input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #101610;
}
#person-name { width: auto; flex: 1; min-width: 0; }
.dock-head button { flex: none; white-space: nowrap; }
#person-name:focus, .lock-card input:focus { outline: none; border-color: var(--brass); }
.people { display: flex; flex-wrap: wrap; gap: 8px; max-height: 28vh; overflow: auto; }
.empty {
  margin: 0;
  color: var(--faint);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 14px;
  background: var(--text);
  color: #16130f;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.lock {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 12, 9, 0.86);
}
.lock-card {
  width: min(420px, 100%);
  padding: 22px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
}
.lock-card .logo { margin-bottom: 14px; }
.lock-card h2 { font-size: 1.6rem; margin-top: 4px; }
.lock-card p { color: var(--muted); }
.lock-card input { margin-top: 8px; }
.lock-card button { width: 100%; margin-top: 12px; }
.form-error { min-height: 1.2em; margin: 8px 0 0; color: var(--danger); }

@media (max-width: 980px) {
  .top { grid-template-columns: 1fr auto; }
  .modes { grid-column: 1 / -1; }
  .mode { flex: 1; }
  .board { grid-template-columns: 1fr; }
  .day-shifts, .day { }
  .slots {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .slot { margin-top: 0; min-height: 108px; }
}

@media (max-width: 720px) {
  .app { width: min(100% - 16px, 1240px); }
  .brand h1 { font-size: 1.4rem; }
  .top-side { display: none; }
  .dock-head { flex-direction: column; align-items: stretch; }
  #person-form { max-width: none; }
  .slots { grid-template-columns: 1fr; }
  .slot { min-height: 74px; }
  .week-title h2 { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
