:root {
  --ink: #18221d;
  --ink-2: #222e28;
  --ink-3: #2e3b34;
  --cream: #eff1ea;
  --paper: #f7f8f3;
  --lime: #c8f06a;
  --pink: #ff8fb0;
  --muted: #5c665f;
  --muted-on-ink: #a9b2ab;
  --line: rgba(24, 34, 29, 0.14);
  --line-strong: #18221d;
  --radius: 14px;
  --display: "Inter Tight", Inter, system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.eyebrow {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- Brand mark ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 34px; height: 24px; flex: none; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.05em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 20px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  background: var(--ink); color: var(--paper);
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-lime { background: var(--lime); color: var(--ink); }
.btn-pink { background: var(--pink); color: var(--ink); }
.btn-ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: inherit;
}
.icon-btn:hover { background: rgba(24, 34, 29, 0.07); }
.icon-btn.active { background: var(--ink); color: var(--lime); }
.icon-btn svg { width: 18px; height: 18px; }

/* =====================================================================
   HOME
   ===================================================================== */
.home-hero { background: var(--ink); color: var(--paper); padding: 0 6vw 96px; position: relative; overflow: hidden; }
.home-nav { display: flex; justify-content: space-between; align-items: center; padding: 32px 0 0; position: relative; z-index: 2; }
.home-nav .eyebrow { color: var(--lime); }
.home-nav .meta { color: var(--muted-on-ink); font-weight: 500; font-size: 15px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 64px; align-items: end; margin-top: 88px; position: relative; z-index: 2; }
.hero-title {
  font-family: var(--display); font-weight: 800; letter-spacing: -0.055em; line-height: 0.9;
  font-size: clamp(56px, 8.6vw, 132px); margin: 0;
}
.hero-title .pink { color: var(--pink); }
.hero-sub { font-size: clamp(18px, 1.6vw, 22px); line-height: 1.4; color: #d9ded8; max-width: 34ch; margin: 28px 0 0; }

.prompt-card { background: var(--paper); color: var(--ink); border-radius: 22px; padding: 22px; box-shadow: 0 30px 60px -30px rgba(0,0,0,0.6); }
.prompt-card label { display: block; margin-bottom: 12px; color: var(--muted); }
.prompt-card textarea {
  width: 100%; min-height: 128px; resize: vertical; border: 0; outline: none; background: transparent;
  font-size: 20px; line-height: 1.35; letter-spacing: -0.01em; font-weight: 500;
}
.prompt-card textarea::placeholder { color: #9aa39c; }
.prompt-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.prompt-actions .hint { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  border: 0; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  background: var(--ink-2); color: var(--paper); box-shadow: inset 0 0 0 1px var(--ink-3);
}
.chip:hover { background: var(--ink-3); }
.form-error { color: #c2335f; font-size: 14px; margin-top: 10px; min-height: 1em; }

.hero-dots { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hero-dots span { position: absolute; border-radius: 50%; }

.home-section { padding: 96px 6vw; }
.home-section h2 { font-family: var(--display); font-size: clamp(40px, 5vw, 72px); letter-spacing: -0.05em; line-height: 0.95; margin: 0 0 40px; font-weight: 800; }
.how-list { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--line-strong); max-width: 1100px; }
.how-list li { display: grid; grid-template-columns: 48px 1fr minmax(0, 1.2fr); gap: 24px; align-items: center; padding: 28px 0; border-bottom: 1.5px solid var(--line-strong); }
.how-list .dot { width: 40px; height: 40px; border-radius: 50%; }
.how-list h3 { margin: 0; font-size: clamp(22px, 2.2vw, 30px); letter-spacing: -0.03em; font-weight: 600; }
.how-list p { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.45; }

.recent { background: var(--lime); }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 28px; }
.recent-card { text-decoration: none; display: block; }
.recent-card .thumb { border-radius: 10px; box-shadow: 0 0 0 1.5px var(--ink); transition: transform 0.15s ease; }
.recent-card:hover .thumb { transform: translateY(-4px) rotate(-0.6deg); }
.recent-card .t { font-weight: 700; margin-top: 12px; letter-spacing: -0.02em; font-size: 17px; }
.recent-card .s { color: #3f4a43; font-size: 13px; margin-top: 2px; }
.thumb-pending { display: grid; place-items: center; background: var(--ink); color: var(--lime); font-weight: 700; aspect-ratio: 3/4; border-radius: 10px; }
.recent-empty { font-size: 18px; color: #3f4a43; }

.home-footer { display: flex; justify-content: space-between; padding: 28px 6vw 40px; border-top: 1.5px solid var(--ink); margin: 0 6vw; padding-left: 0; padding-right: 0; font-weight: 600; }
.home-footer .muted { color: var(--muted); font-weight: 500; }

.thumb { position: relative; overflow: hidden; background: var(--paper); flex: none; }
.thumb .poster { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; margin-top: 56px; gap: 40px; }
  .how-list li { grid-template-columns: 40px 1fr; }
  .how-list p { grid-column: 2; }
}

/* =====================================================================
   POSTER (shared)
   ===================================================================== */
.poster { position: absolute; width: 900px; height: 1200px; overflow: hidden; background: var(--cream); }
.el { position: absolute; transform-origin: 50% 50%; }
.el > svg { display: block; overflow: visible; }
.el-text { width: 100%; white-space: pre-wrap; overflow-wrap: break-word; outline: none; }

/* =====================================================================
   BOARD
   ===================================================================== */
body.board { height: 100vh; overflow: hidden; display: grid; grid-template-rows: 60px 1fr; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px 0 20px;
  background: var(--ink); color: var(--paper); z-index: 20;
}
.topbar .brand-name { font-size: 19px; }
.topbar .sep { width: 1px; height: 24px; background: var(--ink-3); }
.board-title {
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em; border: 0; background: transparent; color: var(--paper);
  padding: 6px 8px; border-radius: 8px; min-width: 0; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.status-pill { font-size: 12px; font-weight: 600; color: var(--muted-on-ink); display: inline-flex; align-items: center; gap: 6px; }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.status-pill.off::before { background: #e0a24a; }
.peers { display: flex; align-items: center; }
.peer {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: var(--ink); border: 2px solid var(--ink); margin-left: -6px; position: relative;
}
.peer.me::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--lime); border: 2px solid var(--ink); }
.topbar .btn-ghost { color: var(--paper); }

.workspace { display: grid; grid-template-columns: 240px 1fr 360px; min-height: 0; }

/* Layers panel */
.panel { background: var(--paper); min-height: 0; display: flex; flex-direction: column; }
.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.panel-head .eyebrow { font-size: 11px; color: var(--muted); }
.add-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 12px 12px; border-bottom: 1px solid var(--line); }
.add-row button {
  border: 0; background: var(--cream); border-radius: 10px; padding: 10px 0 8px; display: grid; justify-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.add-row button:hover { background: #e4e8dc; color: var(--ink); }
.add-row svg { width: 20px; height: 20px; }
.layers { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.layer {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; font-size: 13px; cursor: pointer;
  user-select: none; position: relative;
}
.layer:hover { background: var(--cream); }
.layer.sel { background: var(--ink); color: var(--paper); }
.layer .sw { width: 18px; height: 18px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.layer .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .who { width: 8px; height: 8px; border-radius: 50%; }

/* Canvas */
.stage {
  position: relative; overflow: hidden; min-width: 0; min-height: 0;
  background-color: #e6e9df;
  background-image: radial-gradient(rgba(24,34,29,0.18) 1px, transparent 1.2px);
  background-size: 22px 22px;
  touch-action: none; cursor: default;
}
.stage.panning, .stage.space { cursor: grab; }
.stage.panning:active { cursor: grabbing; }
.viewport { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.viewport .poster { box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 30px 80px -30px rgba(24,34,29,0.45); }
.viewport .el { cursor: move; }
.viewport .el.editing { cursor: text; }
.viewport .el-text[contenteditable="true"] { cursor: text; background: rgba(200, 240, 106, 0.18); }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.sel-box { position: absolute; border: 1.5px solid var(--ink); pointer-events: none; }
.sel-box.mine { border-color: #2a7fff; }
.sel-box .tag {
  position: absolute; left: -1.5px; top: -22px; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px 6px 6px 0;
  white-space: nowrap; color: var(--ink);
}
.handle {
  position: absolute; width: 12px; height: 12px; background: #fff; border: 1.5px solid #2a7fff; border-radius: 3px;
  pointer-events: auto; margin: -6px 0 0 -6px;
}
.handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.handle.ne { left: 100%; top: 0; cursor: nesw-resize; }
.handle.sw { left: 0; top: 100%; cursor: nesw-resize; }
.handle.se { left: 100%; top: 100%; cursor: nwse-resize; }
.handle.rot { left: 50%; top: -30px; border-radius: 50%; cursor: grab; }
.marquee { position: absolute; border: 1px solid #2a7fff; background: rgba(42,127,255,0.08); pointer-events: none; }
.cursor { position: absolute; left: 0; top: 0; pointer-events: none; transition: transform 0.08s linear; z-index: 5; }
.cursor svg { width: 20px; height: 20px; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }
.cursor .label { position: absolute; left: 16px; top: 16px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; color: var(--ink); }

.dock {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  background: var(--paper); border-radius: 14px; padding: 5px; box-shadow: 0 0 0 1px var(--line), 0 10px 30px -12px rgba(24,34,29,0.35);
  z-index: 6;
}
.dock .zoom { font-size: 12px; font-weight: 700; width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.dock .div { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.gen-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 8; pointer-events: none;
}
.gen-card {
  background: var(--ink); color: var(--paper); border-radius: 20px; padding: 28px 32px; max-width: 420px; text-align: center; pointer-events: auto;
  box-shadow: 0 30px 60px -20px rgba(24,34,29,0.6);
}
.gen-card h3 { font-family: var(--display); font-size: 34px; letter-spacing: -0.05em; margin: 18px 0 8px; line-height: 1; }
.gen-card p { color: var(--muted-on-ink); margin: 0 0 4px; line-height: 1.45; }
.gen-card .btn { margin-top: 16px; }
.bubbles { display: flex; gap: 10px; justify-content: center; }
.bubbles span { width: 16px; height: 16px; border-radius: 50%; animation: bob 1s ease-in-out infinite; }
.bubbles span:nth-child(1) { background: var(--pink); }
.bubbles span:nth-child(2) { background: var(--lime); animation-delay: 0.15s; }
.bubbles span:nth-child(3) { background: var(--paper); animation-delay: 0.3s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Right panel: tabs */
.tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 9px 0; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab.active { background: var(--ink); color: var(--paper); }
.tab-body { flex: 1; min-height: 0; display: none; flex-direction: column; }
.tab-body.active { display: flex; }

/* Chat */
.chat-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 92%; }
.msg .who { font-size: 12px; font-weight: 700; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.msg .who i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.msg .body { padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; }
.msg.user .who { justify-content: flex-end; }
.msg.user .body { background: var(--cream); border-bottom-right-radius: 4px; }
.msg.assistant .body { background: var(--ink); color: var(--paper); border-bottom-left-radius: 4px; }
.msg .revert { margin-top: 6px; border: 0; background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); padding: 2px 0; text-decoration: underline; }
.msg .revert:hover { color: var(--ink); }
.typing { font-size: 13px; color: var(--muted); padding: 0 16px 8px; display: flex; gap: 8px; align-items: center; min-height: 26px; }
.typing .bubbles span { width: 8px; height: 8px; }
.chat-empty { color: var(--muted); font-size: 14px; line-height: 1.5; }
.suggests { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.suggests button { border: 0; background: var(--cream); border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 600; }
.suggests button:hover { background: var(--lime); }
.composer { border-top: 1px solid var(--line); padding: 12px; }
.composer .ctx { font-size: 12px; color: var(--muted); margin: 0 4px 8px; display: flex; align-items: center; gap: 6px; }
.composer .ctx b { color: var(--ink); }
.composer form { display: flex; gap: 8px; align-items: flex-end; background: var(--cream); border-radius: 16px; padding: 8px 8px 8px 14px; }
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; outline: none; font-size: 14px; line-height: 1.4; max-height: 140px; padding: 6px 0; }
.composer .btn { padding: 9px 14px; }

/* Inspector */
.inspector { overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.inspector .empty { color: var(--muted); font-size: 14px; line-height: 1.5; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.inp {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; font-size: 14px; outline: none;
}
.inp:focus { border-color: var(--ink); }
textarea.inp { resize: vertical; min-height: 72px; line-height: 1.4; }
.num { position: relative; }
.num em { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11px; color: var(--muted); font-weight: 700; }
.num .inp { padding-left: 28px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18); padding: 0; position: relative; }
.swatch.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.swatch.none { background: repeating-linear-gradient(45deg, #fff 0 4px, #f1c3cf 4px 6px); }
.swatch-pick { position: relative; width: 26px; height: 26px; border-radius: 50%; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18); background: conic-gradient(#ff8fb0, #c8f06a, #6ad1f0, #a36af0, #ff8fb0); }
.swatch-pick input { position: absolute; inset: -6px; width: 40px; height: 40px; opacity: 0; cursor: pointer; }
.seg { display: flex; background: var(--cream); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 0; border-radius: 8px; font-size: 12px; font-weight: 600; }
.seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.insp-actions button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 10px; font-size: 12px; font-weight: 600; }
.insp-actions button:hover { border-color: var(--ink); }
.insp-actions .danger:hover { border-color: #c2335f; color: #c2335f; }
.insp-title { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.04em; margin: 0; }

/* Join dialog + toast */
.modal-back { position: fixed; inset: 0; background: rgba(24, 34, 29, 0.55); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px); }
.modal { background: var(--paper); border-radius: 22px; padding: 28px; width: min(420px, 92vw); }
.modal h2 { font-family: var(--display); font-size: 36px; letter-spacing: -0.05em; line-height: 0.95; margin: 0 0 10px; }
.modal p { color: var(--muted); margin: 0 0 20px; line-height: 1.45; }
.modal .swatches { margin: 14px 0 22px; }
.modal .swatch { width: 32px; height: 32px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 60;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: all 0.2s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.mobile-tabs { display: none; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 0 1fr 340px; }
  .panel-left { display: none; }
}
@media (max-width: 760px) {
  body.board { grid-template-rows: 56px 1fr; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr 46%; }
  .panel-right { border-left: 0; border-top: 1px solid var(--line); }
  .topbar .hide-sm { display: none; }
}
