@font-face {
  font-family: Montserrat;
  src: url("/fonts/Montserrat-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --orange: #EF6C00;
  --burnt: #BF4800;
  --purple: #5D3418;
  --black: #141014;
  --cream: #FFF1DE;
  --gold: #C9A227;
  --line: #E8C8A0;
  --tint: #F6ECE0;
  --tint2: #ECDCC8;
  --white: #FFFaf3;
  --ok: #1AA375;
  --wed: #EB4D5F;
  --shadow: 0 8px 24px rgba(93, 52, 24, 0.12);
  --day-0: #0886E0;
  --day-1: #E9CD41;
  --day-2: #EB4D5F;
  --day-3: #7B5748;
  --day-4: #1AA375;
  --day-5: #F7A763;
  --day-6: #282C33;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--black);
  font-family: Montserrat, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.35;
  min-height: 100%;
}
button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}
button { cursor: pointer; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* LOGIN */
.login-body { min-height: 100vh; min-height: 100dvh; background: var(--cream); }
.login-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 22px calc(28px + var(--safe-bot));
}
.kicker {
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--purple);
}
.hero-title {
  margin: 8px 0 4px;
  font-weight: 900;
  font-size: clamp(2rem, 8vw, 3.1rem);
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--orange);
  -webkit-text-stroke: 2px var(--black);
  paint-order: stroke fill;
  text-transform: uppercase;
}
.subhead { font-weight: 800; color: var(--purple); margin: 0 0 18px; }
.login-card {
  background: var(--white);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.login-card label { display: block; font-weight: 700; margin-bottom: 8px; }
.login-card input[type="password"],
.login-card input[type="text"] {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
  margin-bottom: 14px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid var(--black);
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.btn.secondary { background: var(--white); color: var(--black); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--purple); }
.btn.warn { background: var(--wed); }
.btn.full { width: 100%; }
.login-note { color: #5a4638; font-size: 0.9rem; margin-top: 14px; }
.err { color: #9b1c2c; font-weight: 700; min-height: 1.2em; margin: 0 0 10px; }

/* APP SHELL */
.app { padding-bottom: calc(24px + var(--safe-bot)); }
.topbar {
  background: linear-gradient(#fff 0%, var(--cream) 100%);
  border-bottom: 3px solid var(--gold);
  padding: calc(10px + var(--safe-top)) 14px 10px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.brand { font-weight: 800; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--purple); }
.station { font-weight: 800; font-size: 0.72rem; letter-spacing: 0.14em; color: var(--orange); text-transform: uppercase; }
.date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-weight: 800;
  min-height: 56px;
  background: var(--purple);
}
.date-badge .dow { font-size: 0.85rem; letter-spacing: 0.08em; }
.date-badge .fulldate { font-size: 1.2rem; }
.date-badge.day-0 { background: var(--day-0); }
.date-badge.day-1 { background: var(--day-1); color: var(--black); }
.date-badge.day-2 { background: var(--day-2); }
.date-badge.day-3 { background: var(--day-3); }
.date-badge.day-4 { background: var(--day-4); }
.date-badge.day-5 { background: var(--day-5); color: var(--black); }
.date-badge.day-6 { background: var(--day-6); }
.card-btn { min-height: 148px; }
.card-btn .name { min-height: 2.3em; }
.tabs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.tab {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 800;
  color: var(--purple);
}
.tab[aria-selected="true"] {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* TRAY */
.tray-wrap {
  padding: 12px 14px 6px;
  background: var(--tint);
  border-bottom: 2px solid var(--line);
}
.tray-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tray-head h2 { margin: 0; font-size: 1rem; font-weight: 900; color: var(--purple); }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 700;
  color: var(--purple);
}
.chip[aria-pressed="true"] { background: var(--orange); color: #fff; border-color: var(--black); }
.tray {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.suggest-note { font-size: 0.85rem; font-weight: 700; color: var(--burnt); margin: 0 0 8px; }

/* CARDS (tray + tasks) */
.card-btn, .task {
  scroll-snap-align: start;
  flex: none;
  width: 132px;
  background: #fff;
  border: 2px solid var(--black);
  border-radius: 14px;
  padding: 8px 8px 10px;
  box-shadow: 0 3px 0 var(--purple);
  text-align: center;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.card-btn { cursor: grab; }
.card-btn:active { cursor: grabbing; }
.card-btn .name, .task .name {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.15;
  color: var(--black);
  margin: 0 0 6px;
}
.art {
  width: 86px;
  height: 72px;
  margin: 0 auto 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.art svg, .art img {
  max-width: 86px;
  max-height: 72px;
  width: auto;
  height: auto;
  background: transparent;
}
.meta { font-size: 0.75rem; font-weight: 700; color: #5a4638; }
.assumed { font-size: 0.68rem; font-weight: 800; color: var(--burnt); letter-spacing: 0.04em; }
.badge-suggest {
  position: absolute;
  top: -8px;
  right: -6px;
  background: var(--day-0);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 6px;
}

/* BOARD */
.board {
  padding: 12px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section {
  background: #fff;
  border: 3px solid var(--purple);
  border-radius: 16px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.section.drop-over { outline: 4px dashed var(--orange); outline-offset: -4px; background: #fff4e6; }
.section-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--purple);
  color: #fff;
  padding: 8px 12px;
}
.section-h h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.section-h .add-free {
  min-height: 40px;
  border: 0;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  border-radius: 10px;
  padding: 6px 10px;
}
.wheel {
  overflow-y: auto;
  max-height: 280px;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
}
.task-list { display: flex; flex-direction: column; gap: 8px; min-height: 70px; }
.task {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  touch-action: manipulation;
  box-shadow: none;
}
.check {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 3px solid var(--black);
  background: #fff;
  font-size: 0;
}
.task.done .check { background: var(--ok); }
.qty {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qty button {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid var(--black);
  background: var(--tint);
  font-weight: 900;
  font-size: 1.2rem;
}
.qty .amt {
  min-width: 52px;
  text-align: center;
  font-weight: 900;
  font-size: 1.15rem;
  background: none;
  border: 0;
  padding: 8px 0;
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.quick button, .choice {
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--tint);
  font-weight: 800;
}
.choice[aria-pressed="true"] { background: var(--orange); color: #fff; border-color: var(--black); }
.notes { font-size: 0.85rem; color: #5a4638; margin: 4px 0 0; }
.empty { color: #8a7460; font-weight: 600; padding: 16px 8px; text-align: center; }

.banner {
  margin: 14px 12px;
  background: var(--orange);
  color: #fff;
  border: 3px solid var(--black);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.05rem;
}
.banner[contenteditable="true"] { background: #fff; color: var(--black); }

/* COMPLETED */
.completed {
  margin: 0 12px 20px;
  background: #fff;
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 12px;
}
.completed h2 { margin: 0 0 8px; font-weight: 900; color: var(--purple); }
.toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.done-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.done-item .when { color: #5a4638; font-size: 0.85rem; font-weight: 700; }
.restore { min-height: 40px; }

/* DRIVERS */
.drivers { padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.block {
  background: #fff;
  border: 3px solid var(--purple);
  border-radius: 16px;
  padding: 12px;
}
.block h2 { margin: 0 0 8px; font-weight: 900; color: var(--purple); }
.routine-item, .inv-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.routine-item .t { font-weight: 800; }
.search {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.putaway-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.putaway-row select, .putaway-row input { min-height: 48px; border-radius: 10px; border: 2px solid var(--line); padding: 8px; flex: 1; }

/* MODALS */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 20, 0.45);
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.modal {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: min(90vh, 720px);
  overflow: auto;
  border-radius: 18px 18px 12px 12px;
  border: 3px solid var(--black);
  padding: 16px;
}
.modal h2 { margin: 0 0 10px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 700; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.field textarea { min-height: 90px; }
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 90;
  opacity: 0.92;
  transform: scale(1.04);
}
.toast-msg {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bot));
  transform: translateX(-50%);
  background: var(--black);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 100;
  max-width: 90vw;
}
.hidden { display: none !important; }
.swipe {
  width: 100%;
  accent-color: var(--orange);
  height: 28px;
}

@media (min-width: 900px) {
  .board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    align-items: stretch;
  }
  .section { min-height: 420px; }
  .wheel { max-height: calc(100vh - 420px); min-height: 320px; }
}
