/* COTOTF crew: a quiet, monotone take on the cototf.xyz look.
   Same square boxes, uppercase Oswald labels and layout, but greys only, no background art,
   and white is the one "accent". Layout: slim top bar, episode progress panel, then the task columns. */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500&family=Inter:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;
  --bg: #121212;
  --panel: #181818;
  --panel-2: #1e1e1e;
  --line: #2a2a2a;
  --line-2: #363636;
  --text: #e4e4e4;
  --soft: #b4b4b4;
  --dim: #858585;
  --faint: #5c5c5c;
  --white: #f5f5f5;
  --head: 'Oswald', 'Arial Narrow', sans-serif;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--white); }
a:hover { color: #fff; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--white); color: var(--bg); }
:focus-visible { outline: 1px solid var(--white); outline-offset: 2px; }

/* ---------- top bar */
.calm-top {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.calm-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.calm-brand img { height: 26px; width: auto; display: block; opacity: .92; }
.calm-brand span { font: 400 .8rem var(--head); letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
.calm-nav { display: flex; gap: 4px; margin-left: auto; }
.calm-nav a, .calm-nav button {
  background: none; border: 0; padding: 6px 10px; font: 400 .8rem var(--head); letter-spacing: 1px; text-transform: uppercase;
  color: var(--dim); text-decoration: none; cursor: pointer;
}
.calm-nav a:hover, .calm-nav button:hover, .calm-nav a.on { color: var(--white); }
#nav-user { font-size: .78rem; color: var(--faint); }

/* ---------- page */
.page-main { flex: 1; padding: 22px 0 40px; }
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.page-main.narrow .wrap { max-width: 420px; }
.crew-wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.page-title, .section-title { font: 500 1rem var(--head); letter-spacing: 1px; text-transform: uppercase; color: var(--white); margin-bottom: 8px; }
.section-title { font-size: .85rem; color: var(--soft); margin: 0; }
.page-sub { font-size: .82rem; color: var(--dim); margin-bottom: 16px; }
.small { font-size: .8rem; }
.muted { color: var(--dim); }

.box { background: var(--panel); border: 1px solid var(--line); }
.box + .box { margin-top: 14px; }
.box-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); font: 400 .78rem var(--head); letter-spacing: 1px; text-transform: uppercase; color: var(--soft); }
.box-head small { font: 400 .72rem var(--font); letter-spacing: 0; text-transform: none; color: var(--faint); }
.box-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.box-body.center { align-items: center; text-align: center; padding: 28px 18px; }

/* ---------- forms + buttons */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font: 400 .7rem var(--head); text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.field input, .field textarea, .field select, .input {
  background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 8px 10px; font-size: .88rem; outline: none; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus, .input:focus { border-color: var(--dim); }
.field textarea { min-height: 84px; resize: vertical; }
::placeholder { color: var(--faint); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--soft); cursor: pointer; }
.check input, .ep-item input { accent-color: #d8d8d8; width: 15px; height: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px;
  background: transparent; border: 1px solid var(--line-2); color: var(--soft); cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 400 .76rem var(--head); letter-spacing: 1px; text-transform: uppercase;
}
.btn:hover { border-color: var(--dim); color: var(--white); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--white); border-color: var(--white); color: var(--bg); }
.btn.primary:hover { background: #fff; }
.btn.danger:hover { border-color: var(--soft); }
.btn.sm { height: 27px; padding: 0 10px; font-size: .7rem; }
.btn.full { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; color: var(--dim); font-size: .78rem; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover { color: var(--white); }
.msg { font-size: .8rem; min-height: 1em; color: var(--soft); }
.msg.err { color: var(--white); }
.msg.err:not(:empty)::before { content: '! '; font-weight: 600; }
.notice-line { padding: 9px 12px; font-size: .82rem; border: 1px dashed var(--line-2); color: var(--soft); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- episode progress */
.ep-panel { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 12px; }
.ep-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ep-label { font: 400 .72rem var(--head); letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.ep-name { font: 500 clamp(1.6rem, 4vw, 2.3rem)/1.1 var(--head); text-transform: uppercase; letter-spacing: 1px; color: var(--white); }
.ep-pct { font: 500 clamp(1.6rem, 4vw, 2.3rem)/1 var(--head); color: var(--white); font-variant-numeric: tabular-nums; }
.ep-bar { height: 26px; background: var(--bg); border: 1px solid var(--line-2); overflow: hidden; }
.ep-fill {
  height: 100%; width: 0; background: var(--white);
  background-image: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(0, 0, 0, .07) 10px 20px);
  transition: width .6s ease;
}
.ep-sub { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--dim); }
.ep-admin { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.ep-admin .input { width: 110px; height: 27px; padding: 0 8px; }
.ep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 18px; margin-top: 6px; }
.ep-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: .88rem; color: var(--text); cursor: pointer; min-width: 0; }
.ep-item .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ep-item.done .txt { color: var(--faint); text-decoration: line-through; }
.ep-item .by { font-size: .7rem; color: var(--faint); white-space: nowrap; }
.ep-item .x { background: none; border: 0; color: var(--faint); font-size: 1rem; line-height: 1; padding: 0 2px; cursor: pointer; visibility: hidden; }
.ep-item:hover .x { visibility: visible; }
.ep-item .x:hover { color: var(--white); }
.ep-add { display: flex; gap: 8px; }
.ep-add .input { flex: 1; min-width: 0; }

/* ---------- tasks */
.crew-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 28px 0 10px; }
.crew-top .grow { flex: 1; }
.crew-filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crew-filterbar .input { width: auto; height: 30px; padding: 0 8px; font-size: .8rem; }
.crew-filterbar #f-q { flex: 1; min-width: 150px; }
.crew-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: .76rem; color: var(--dim); font-variant-numeric: tabular-nums; margin-left: auto; }
.crew-stats b { color: var(--text); font-weight: 500; }
.crew-board-wrap { overflow-x: auto; margin-top: 12px; padding-bottom: 6px; }
.crew-board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 10px; min-width: min-content; }
.box.crew-col { min-width: 0; display: flex; flex-direction: column; margin-top: 0; background: transparent; }
.crew-col .n { color: var(--faint); font-variant-numeric: tabular-nums; }
.crew-col .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--faint); }
.crew-col[data-status="doing"] .dot { background: var(--soft); }
.crew-col[data-status="review"] .dot { background: transparent; border: 1px solid var(--soft); }
.crew-col[data-status="done"] .dot { background: var(--white); }
.crew-col .add { margin-left: auto; background: none; border: 0; color: var(--faint); font-size: 1rem; line-height: 1; padding: 0 2px; cursor: pointer; }
.crew-col .add:hover { color: var(--white); }
.crew-cards { display: flex; flex-direction: column; gap: 6px; padding: 8px; flex: 1; min-height: 140px; }
.crew-col.drop { outline: 1px dashed var(--soft); outline-offset: -3px; }
.crew-empty { color: var(--faint); font-size: .76rem; text-align: center; padding: 14px 4px; }

.crew-card { width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; cursor: grab; }
.crew-card:hover { border-color: var(--line-2); background: var(--panel-2); }
.crew-card.dragging { opacity: .4; }
.crew-card .t { font-size: .88rem; font-weight: 500; color: var(--text); line-height: 1.3; overflow-wrap: anywhere; }
.crew-card.is-done .t { color: var(--faint); text-decoration: line-through; }
.crew-card .note { font-size: .76rem; color: var(--dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.crew-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .72rem; color: var(--dim); }
.crew-chip { color: var(--dim); font-size: .7rem; white-space: nowrap; }
.crew-chip + .crew-chip::before { content: '·'; margin-right: 6px; color: var(--faint); }
.crew-chip.late { color: var(--bg); background: var(--white); padding: 0 5px; font-weight: 600; }
.crew-chip.late::before { display: none; }
.crew-chip.soon { color: var(--text); }
.crew-person { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; max-width: 55%; }
.crew-person span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crew-person.none { color: var(--faint); font-style: italic; }
.crew-initial { width: 17px; height: 17px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; background: var(--line-2); color: var(--text); font-size: .62rem; font-weight: 600; text-transform: uppercase; }

/* ---------- dialogs, lists, toast */
dialog.crew-dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); padding: 0; width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 24px); margin: auto; }
dialog.crew-dlg::backdrop { background: rgba(0, 0, 0, .65); }
.crew-list { border: 1px solid var(--line); max-height: 210px; overflow-y: auto; }
.crew-list > div { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-bottom: 1px solid var(--line); min-width: 0; font-size: .8rem; }
.crew-list > div:last-child { border-bottom: 0; }
.crew-list code { font-family: Consolas, monospace; letter-spacing: 1px; color: var(--white); }
.crew-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.crew-list .who { color: var(--text); }
.crew-toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50; background: var(--white); color: var(--bg); padding: 8px 14px; font-size: .82rem; }

.crew-code { text-transform: uppercase; letter-spacing: 3px; text-align: center; font-size: 1.05rem !important; }
.crew-secret { font-family: Consolas, monospace; letter-spacing: 2px; font-size: 1rem; color: var(--white); background: var(--bg); border: 1px solid var(--line); padding: 10px; text-align: center; word-break: break-all; user-select: all; }
.crew-steps { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: .86rem; color: var(--soft); }

.site-footer.crew-foot { padding: 16px; text-align: center; border-top: 1px solid var(--line); }
.footer-copy { font-size: .72rem; color: var(--faint); }

@media (max-width: 700px) {
  .crew-board { grid-template-columns: repeat(4, minmax(78vw, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .ep-panel { padding: 16px; }
  .crew-stats { margin-left: 0; }
  .calm-nav { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .ep-fill { transition: none; } }
