:root {
  --maroon: #6b1d2a;
  --maroon-2: #8a2a3a;
  --turmeric: #e8a317;
  --bg: #f7f1e8;
  --card: #fffdf9;
  --ink: #2a1d17;
  --muted: #7a6a5f;
  --line: #e6dccd;
  --red: #b3261e;
  --amber: #a86400;
  --green: #2e7d32;
  --radius: 12px;
  --col-w: 100vw;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 12px; min-height: 40px; }
button.primary { background: var(--maroon); color: #fff; border-color: var(--maroon); font-weight: 600; }
button.danger { color: var(--red); border-color: #e7b8b4; }
button.ghost { background: transparent; border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
.icon-btn { padding: 6px 10px; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; min-height: 40px; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: var(--maroon); color: #fff; }
.top h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.top h1::before { content: "🪔 "; }
.top-actions { display: flex; gap: 6px; }
.top .primary { background: var(--turmeric); border-color: var(--turmeric); color: #2a1d17; }

/* lane tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line);
  scrollbar-width: none; position: sticky; top: 0; z-index: 2; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border-radius: 999px; padding: 6px 12px; min-height: 34px; font-size: 14px; white-space: nowrap; }
.tab .n { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--bg); font-size: 12px; }
.tab.active { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.tab.active .n { background: rgba(255,255,255,.2); }

/* board: one lane per screen on phones, swipe between */
.board { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-behavior: smooth; }
.col { flex: none; width: var(--col-w); scroll-snap-align: start; display: flex; flex-direction: column; min-height: 0; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 6px; }
.col-head h2 { font-size: 16px; margin: 0; }
.col-head small { color: var(--muted); }
.col-list { flex: 1; overflow-y: auto; padding: 4px 12px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 10px; }
.col.drop-target .col-list { background: rgba(232,163,23,.12); border-radius: var(--radius); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { padding: 30px; color: var(--muted); }

@media (min-width: 900px) {
  :root { --col-w: 290px; }
  .tabs { display: none; }
  .board { scroll-snap-type: none; padding: 8px; gap: 8px; }
  .col { background: #efe6d8; border-radius: var(--radius); }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: 0 1px 2px rgba(60,30,10,.06); cursor: pointer; }
.card.blocked { border-left: 4px solid var(--red); }
.card.dragging { opacity: .4; }
.card-title { font-weight: 650; margin: 0 0 2px; font-size: 15px; }
.card-sub { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.chip.overdue { background: #fbe4e2; color: var(--red); font-weight: 600; }
.chip.soon { background: #fdf0d8; color: var(--amber); font-weight: 600; }
.chip.running { background: #e3f2e4; color: var(--green); font-weight: 600; }
.chip.block { background: #fbe4e2; color: var(--red); }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.card-foot .move { min-height: 34px; padding: 4px 10px; font-size: 13px; }

/* sheet (dialog) — bottom sheet on phones, centered panel on desktop */
dialog#sheet { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; background: var(--bg); color: var(--ink); }
dialog#sheet::backdrop { background: rgba(30,15,10,.45); }
@media (min-width: 700px) { dialog#sheet { margin: auto; max-width: 640px; border-radius: 16px; } }
.sheet-inner { padding: 0 16px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; max-height: 92vh; }
.sheet-head { position: sticky; top: 0; background: var(--bg); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 0 10px; z-index: 1; border-bottom: 1px solid var(--line); }
.sheet-head h3 { margin: 0; font-size: 18px; }
section.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
section.block h4 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--maroon); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.timer-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timer-box .big { font-size: 28px; font-variant-numeric: tabular-nums; font-weight: 700; }
.timer-box button { min-width: 110px; min-height: 48px; font-size: 16px; }
.btn-stop { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.list .meta { color: var(--muted); font-size: 12px; }
.x { border: 0; background: none; color: var(--muted); min-height: 32px; padding: 4px 8px; }
.piece { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.piece input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--maroon); }
.piece span { flex: 1; }
.piece.done span { text-decoration: line-through; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.lane-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; }
.lane-pick button.current { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.photos figcaption { font-size: 11px; color: var(--muted); }
.photos .fail img { outline: 3px solid var(--red); }
.muted { color: var(--muted); font-size: 13px; }
.money { font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%) translateY(120px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; transition: transform .25s; z-index: 1000; max-width: 90vw; font-size: 14px; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

a { color: var(--maroon); }
a > button { color: var(--ink); }

/* board switcher */
.board-switch { display: flex; gap: 0; padding: 0 14px 10px; background: var(--maroon); }
.board-switch button { flex: 1; min-height: 36px; border-radius: 0; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #fff; font-weight: 600; }
.board-switch button:first-child { border-radius: 8px 0 0 8px; }
.board-switch button:last-child { border-radius: 0 8px 8px 0; }
.board-switch button.active { background: #fff; color: var(--maroon); border-color: #fff; }
.board-switch .n { font-weight: 400; opacity: .8; margin-left: 4px; }
@media (min-width: 900px) { .board-switch { justify-content: flex-start; } .board-switch button { flex: none; min-width: 140px; } }
.chip.waiting { background: #e8eaf6; color: #303f9f; font-weight: 600; }
.chip.link { background: #e8eaf6; color: #303f9f; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 14px; color: var(--ink); }
.check input { width: 22px; height: 22px; min-height: 22px; accent-color: var(--maroon); }
