:root {
  --paper: #f3eee4; --paper-2: #ebe4d6; --card: #fffdf8; --ink: #2a2520; --ink-2: #6d655b; --line: #d9d0bf;
  --accent: #b84a2b; --accent-ink: #fff; --good: #2f7a4f; --bad: #b3372f; --info: #2c6a8f;
  --yellow: #fbefb0; --pink: #f9d5d8; --green: #d5ecd0; --blue: #d3e6f5; --purple: #e3d9f3;
  --shadow: 0 1px 2px rgba(60,45,20,.12), 0 6px 16px rgba(60,45,20,.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.45 var(--sans); overscroll-behavior: none; }
#app { height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 12px; }
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { border-color: transparent; background: transparent; }
button.danger { color: var(--bad); }
button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
input, textarea, select { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; width: 100%; }
select { width: auto; }
textarea { resize: vertical; min-height: 70px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
a { color: var(--info); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

/* top bar */
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--paper); flex-wrap: wrap; }
.bar h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--card); }
.tabs button { border: 0; border-radius: 0; padding: 6px 12px; background: transparent; }
.tabs button.on { background: var(--ink); color: var(--paper); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
.brief { padding: 8px 14px; background: var(--paper-2); border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 15px; cursor: pointer; white-space: pre-wrap; max-height: 4.6em; overflow: hidden; }
.brief.open { max-height: 40vh; overflow: auto; }
.brief:empty::before, .brief.empty::before { content: "What are we trying to pull off? Tap to write the brief."; color: var(--ink-2); font-style: italic; }

.main { flex: 1; min-height: 0; display: flex; position: relative; }
.stage { flex: 1; min-width: 0; display: flex; position: relative; }
.pane { flex: 1; min-width: 0; overflow: auto; }

/* canvas */
.canvas { flex: 1; min-width: 0; position: relative; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background-image: radial-gradient(circle, #cfc5b1 1px, transparent 1.4px); }
.canvas:active { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.card { position: absolute; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer; border: 1px solid rgba(60,45,20,.08); }
.card.sel { outline: 3px solid var(--accent); }
.card.lifted, .group.lifted { box-shadow: 0 12px 30px rgba(60,45,20,.28); z-index: 5; }
.card img.pic { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--paper-2); pointer-events: none; }
.card .in { padding: 9px 11px 10px; }
.card h3 { font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.card .site { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.card .body { font-size: 13px; color: var(--ink-2); margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.card.note .body { color: var(--ink); -webkit-line-clamp: 8; font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; align-items: center; font-size: 12px; }
.chip { padding: 1px 7px; border-radius: 10px; background: rgba(60,45,20,.08); white-space: nowrap; }
.chip.pro { background: #dff0e3; color: var(--good); } .chip.con { background: #f6dcd9; color: var(--bad); }
.chip.todo { background: #fff; border: 1px solid var(--accent); color: var(--accent); }
.chip.st-shortlist { background: var(--ink); color: var(--paper); }
.chip.st-chosen { background: var(--good); color: #fff; }
.chip.st-rejected { background: transparent; border: 1px solid var(--line); }
.card.st-rejected { opacity: .55; } .card.st-rejected h3 { text-decoration: line-through; }
.card.st-chosen { border: 2px solid var(--good); }
.c-yellow { background: var(--yellow); } .c-pink { background: var(--pink); } .c-green { background: var(--green); }
.c-blue { background: var(--blue); } .c-purple { background: var(--purple); }
.group { position: absolute; border: 2px dashed rgba(60,45,20,.28); border-radius: 16px; background: rgba(255,255,255,.35); }
.group.c-yellow { background: rgba(251,239,176,.5); } .group.c-pink { background: rgba(249,213,216,.5); } .group.c-green { background: rgba(213,236,208,.5); }
.group.c-blue { background: rgba(211,230,245,.5); } .group.c-purple { background: rgba(227,217,243,.5); }
.group-title { position: absolute; left: 12px; top: -15px; background: var(--ink); color: var(--paper); padding: 3px 12px; border-radius: 12px; font-family: var(--serif); font-size: 15px; cursor: grab; max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resize { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; cursor: nwse-resize; border-right: 4px solid rgba(60,45,20,.4); border-bottom: 4px solid rgba(60,45,20,.4); border-radius: 0 0 14px 0; }
.zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 38px; height: 38px; padding: 0; font-size: 18px; box-shadow: var(--shadow); }
.empty-hint { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--ink-2); pointer-events: none; padding: 30px; font-family: var(--serif); font-size: 18px; }

/* add bar */
.addbar { position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(620px, calc(100% - 24px)); display: flex; gap: 6px; background: var(--card); padding: 7px; border-radius: 14px; box-shadow: 0 4px 22px rgba(60,45,20,.22); border: 1px solid var(--line); z-index: 6; }
.addbar input { border: 0; background: transparent; }
.addbar button { white-space: nowrap; }
.rec { background: var(--bad) !important; color: #fff !important; border-color: var(--bad) !important; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .6; } }

/* list + tasks */
.pane.pad { padding: 14px 14px 110px; }
.wrap { max-width: 760px; margin: 0 auto; }
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 20px 0 8px; font-family: var(--sans); font-weight: 600; }
.lrow { display: flex; gap: 12px; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 10px; margin-bottom: 8px; cursor: pointer; align-items: flex-start; }
.lrow img { width: 72px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; background: var(--paper-2); }
.lrow h3 { font-size: 16px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.task input[type=checkbox] { width: 20px; height: 20px; flex: none; margin: 2px 0 0; accent-color: var(--good); }
.task.done .ttext { text-decoration: line-through; color: var(--ink-2); }
.task .result { margin-top: 4px; padding: 6px 9px; background: var(--paper-2); border-radius: 6px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task .who { font-size: 12px; color: var(--ink-2); }
.linkish { color: var(--info); cursor: pointer; text-decoration: underline; }

/* detail panel */
.detail { width: 420px; flex: none; border-left: 1px solid var(--line); background: var(--paper); overflow: auto; padding: 14px 16px 120px; z-index: 7; }
.detail > * + * { margin-top: 12px; }
.detail .title { font-family: var(--serif); font-size: 21px; font-weight: 600; border-color: transparent; background: transparent; padding: 4px 6px; margin-left: -6px; }
.detail .title:hover, .detail .title:focus { border-color: var(--line); background: #fff; }
.detail img.hero { width: 100%; max-height: 240px; object-fit: cover; border-radius: 10px; display: block; }
.detail label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; padding: 0; background: var(--card); }
.swatch.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pc { list-style: none; margin: 0 0 6px; padding: 0; }
.pc li { padding: 5px 8px; border-radius: 6px; margin-bottom: 4px; font-size: 14px; display: flex; gap: 6px; overflow-wrap: anywhere; }
.pc li span.t { flex: 1; min-width: 0; white-space: pre-wrap; }
.pc li small { display: block; color: var(--ink-2); font-size: 11px; }
.pc.pro li { background: #dff0e3; } .pc.con li { background: #f6dcd9; } .pc.finding li { background: var(--blue); } .pc.comment li { background: var(--paper-2); }
.x { border: 0; background: transparent; padding: 0 4px; color: var(--ink-2); line-height: 1; }
audio { width: 100%; height: 36px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 84px; height: 64px; object-fit: cover; border-radius: 6px; }

/* home */
.home { max-width: 860px; margin: 0 auto; padding: 28px 16px 60px; width: 100%; }
.home h1 { font-size: 34px; }
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 20px 0 28px; }
.bcard { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; cursor: pointer; border: 1px solid transparent; }
.bcard:hover { border-color: var(--accent); }
.bcard h2 { font-size: 20px; }
.bcard p { margin: 6px 0 10px; color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.newboard { background: var(--paper-2); border-radius: 12px; padding: 16px; display: grid; gap: 8px; max-width: 520px; }

/* dialogs */
dialog { border: 0; border-radius: 14px; padding: 20px; width: min(560px, calc(100vw - 24px)); background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(40,30,15,.45); }
dialog > * + * { margin-top: 12px; }
.linkbox { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 12px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; user-select: all; }
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }

/* TV */
.tv { flex: 1; display: grid; grid-template-columns: 1.15fr 1fr; gap: 3vw; padding: 3vw; min-height: 0; font-size: clamp(16px, 1.5vw, 30px); }
.tv img.hero { width: 100%; height: 100%; object-fit: cover; border-radius: 1.2vw; min-height: 0; }
.tv .side { overflow: hidden; display: flex; flex-direction: column; gap: 1.2vw; min-height: 0; }
.tv h1 { font-size: 2.6em; line-height: 1.08; }
.tv .pc li { font-size: 1em; padding: .35em .6em; }
.tv .cols { gap: 1.5vw; }
.tv-wait { flex: 1; display: grid; place-items: center; text-align: center; padding: 6vw; }
.tv-wait .code { font: 600 clamp(48px, 11vw, 180px)/1 ui-monospace, monospace; letter-spacing: .12em; margin: .3em 0; }
.tv-wait h1 { font-size: clamp(26px, 4vw, 64px); }
.tv-wall { flex: 1; padding: 2vw; display: grid; grid-template-columns: repeat(auto-fill, minmax(18vw, 1fr)); gap: 1.4vw; align-content: start; overflow: hidden; }
.tv-wall .card { position: static; font-size: clamp(14px, 1.1vw, 22px); }
.tv-wall .card h3 { font-size: 1.25em; }
.tv-head { padding: 1.5vw 2vw 0; }
.tv-head h1 { font-size: clamp(24px, 3vw, 54px); }

@media (max-width: 760px) {
  .detail { position: fixed; inset: 0; width: auto; border: 0; padding-top: 10px; }
  .bar h1 { font-size: 18px; flex: 1 1 calc(100% - 60px); }
  .bar .tabs { flex: 1 0 auto; } .bar .tabs button { flex: 1; }
  .tv { grid-template-columns: 1fr; }
  .addbar .lbl { display: none; }
}
