/* Shorts Factory board. Layout: one page, a board of columns like Jira.
   A phone shows one column at about 85% of the width with the next one peeking; a wide screen shows them all.
   White page, system font, one accent colour, no shadows or gradients (owner's words, docs/panel-spec.md section 8). */
:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --soft: #F2F4F7;
  --softer: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #101521;
  --muted: #5B6474;
  --faint: #9AA3B2;
  --line: #E2E6EC;
  --accent: #2160E8;
  --accent-hover: #1A50C7;
  --accent-soft: #EAF0FD;
  --accent-mid: #A9C2F6;
  --accent-ink: #FFFFFF;
  --ok: #167A3E;
  --ok-soft: #E6F4EB;
  --wait: #985A00;
  --wait-soft: #FCF1DF;
  --bad: #BF3328;
  --bad-soft: #FBEAE8;
  --media: #0B0E14;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
p { margin: 0; }
h1, h2, h3 { margin: 0; }
button { font: inherit; color: inherit; }
.i {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i.fill { fill: currentColor; stroke: none; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */
.bar {
  flex: none;
  position: relative;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.bar-in {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-block: 0.4rem 0.55rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.brand {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
}
.mark {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
}
.mark .i { width: 1rem; height: 1rem; }
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sync {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--wait);
  flex: none;
}
.dot[data-state="ok"] { background: var(--ok); }
.dot[data-state="bad"] { background: var(--bad); }
.menu-wrap { flex: none; position: relative; }
.icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}
.menu button {
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.menu button:hover { background: var(--soft); }
.segmented {
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--soft);
}
.segmented button {
  min-height: 2.5rem;
  padding: 0 0.95rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.segmented::-webkit-scrollbar { display: none; }
.add { flex: none; margin-left: auto; }

/* ---------- board ---------- */
.board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-top: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  scroll-padding-left: max(16px, env(safe-area-inset-left, 0px));
  scroll-padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.col {
  flex: 0 0 85%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-radius: 14px;
  background: var(--soft);
}
.col[data-factory] { background: var(--softer); }
.col[data-factory] .col-head h2 { color: var(--muted); }
.col-head {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.75rem 0.85rem 0.55rem;
}
.col-head h2 { font-size: 0.9375rem; font-weight: 700; }
.col-head .n { color: var(--muted); font-weight: 600; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.col-head .link { margin-left: auto; min-height: 1.75rem; white-space: nowrap; }
.col-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 0.6rem 0.6rem;
}
.col-note { padding: 0.25rem 0.35rem; color: var(--muted); font-size: 0.9375rem; }
.col.archive[data-collapsed] .col-body { min-height: 4rem; }

/* ---------- cards ---------- */
.card {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.card:hover { border-color: var(--faint); }
.frame {
  flex: none;
  width: 6rem;
  max-width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 9px;
  overflow: hidden;
  background: var(--media);
}
.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
  pointer-events: none;
}
.tile {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--soft);
  background: color-mix(in srgb, var(--ch, #9AA3B2) 16%, #FFFFFF);
  color: var(--muted);
  color: color-mix(in srgb, var(--ch, #5B6474) 70%, #000000);
}
.tile .i { width: 1.35rem; height: 1.35rem; }
.card-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.card .t {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.card .s {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.8125rem;
}
.card .s.bad { color: var(--bad); }
.plates { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.plate {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
}
.plate.ch::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ch, var(--faint));
  flex: none;
}
.plate[data-tone="ok"], .pill[data-tone="ok"] { background: var(--ok-soft); color: var(--ok); }
.plate[data-tone="wait"], .pill[data-tone="wait"] { background: var(--wait-soft); color: var(--wait); }
.plate[data-tone="bad"], .pill[data-tone="bad"] { background: var(--bad-soft); color: var(--bad); }
.plate[data-tone="work"], .pill[data-tone="work"] { background: var(--accent-soft); color: var(--accent); }
.card.waiting { border-color: var(--accent-mid); }

/* ---------- dragging ---------- */
body.dragging, body.dragging * { cursor: grabbing !important; }
body.dragging .board { scroll-snap-type: none; }
.card.lifted { opacity: 0.35; }
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  pointer-events: none;
  border: 2px solid var(--accent);
  transform-origin: 0 0;
}
body.dragging .col[data-drop="ok"] { background: var(--accent-soft); outline: 2px dashed var(--accent-mid); outline-offset: -2px; }
body.dragging .col[data-drop="ok"][data-over] { outline: 2px solid var(--accent); }
body.dragging .col[data-drop="no"] { opacity: 0.6; }

/* ---------- open card ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(8px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.sheet-head .what { flex: 1; min-width: 0; font-weight: 600; color: var(--muted); font-size: 0.9375rem; }
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-top: 1.1rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.sheet h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.block { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.block > h3 { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.01em; }
.box {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}
.group { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.list > li { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.85rem 1rem; min-width: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.player {
  display: flex;
  justify-content: center;
  background: var(--media);
  border-radius: var(--radius);
  overflow: hidden;
}
.player video {
  display: block;
  height: min(64vh, 36rem);
  max-width: 100%;
  aspect-ratio: 9 / 16;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}
.ch-dot::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--ch, var(--faint));
}
.body { overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 0.9375rem; }
.label { font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.say-ok { color: var(--ok); font-size: 0.9375rem; font-weight: 600; }
.say-wait { color: var(--wait); font-size: 0.9375rem; font-weight: 600; }
.say-bad { color: var(--bad); font-size: 0.9375rem; overflow-wrap: anywhere; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn .i { width: 1.1rem; height: 1.1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.actions .btn { flex: 1 1 8rem; }
.link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  align-self: flex-start;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9375rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link.quiet { color: var(--muted); font-weight: 500; }
.links { display: flex; flex-wrap: wrap; column-gap: 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9375rem;
  font-weight: 600;
}
label.check { flex-direction: row; align-items: center; gap: 0.6rem; min-height: 2.75rem; font-weight: 500; }
label.check input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--accent); }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 400 1rem var(--font);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 4.5rem; resize: vertical; }
select { min-height: 2.75rem; }
.events { list-style: none; margin: 0; padding: 0; }
.events li {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}
.events li:first-child { border-top: 0; }
.events .t { color: var(--muted); font-size: 0.8125rem; padding-top: 0.1rem; font-variant-numeric: tabular-nums; }
.events span:last-child { overflow-wrap: anywhere; }
.day { font-weight: 700; font-size: 0.9375rem; padding-top: 0.5rem; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- sign-in page (hosted site) ---------- */
body.login-page {
  overflow: auto;
  align-items: center;
  justify-content: center;
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.login {
  width: min(100%, 22rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}
.login h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; }
.login form { width: 100%; }
.login .btn { width: 100%; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ---------- wider screens ---------- */
@media (min-width: 700px) {
  .col { flex: 0 0 20rem; }
}
@media (min-width: 1000px) {
  .bar-in { flex-direction: row; align-items: center; gap: 0.9rem; }
  .row { display: contents; }
  .brand { order: 0; flex: 0 0 auto; margin-right: 0.5rem; }
  .segmented { order: 1; }
  .add { order: 2; margin-left: 0; }
  .menu-wrap { order: 3; margin-left: auto; }
  .card.has-frame { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
  .card.has-frame .frame { width: 100%; border-radius: 0; }
  .card.has-frame .card-text { padding: 0.65rem 0.75rem 0.75rem; }
  /* Columns are narrow here: an idea keeps its small tile, but above the text, so the hook gets the full width. */
  .card:not(.has-frame) { flex-direction: column; align-items: stretch; gap: 0.45rem; }
  .card:not(.has-frame) .tile { align-self: flex-start; width: 1.9rem; height: 1.9rem; border-radius: 8px; }
  .card:not(.has-frame) .tile .i { width: 1.05rem; height: 1.05rem; }
  .board { scroll-snap-type: none; }
  .col { flex: 1 0 10.25rem; }
  .col.archive[data-collapsed] { flex: 0 0 9.5rem; }
  .sheet {
    left: auto;
    width: min(34rem, 46vw);
    border-left: 1px solid var(--line);
  }
}
