/* The Writing Room. Same family as somastudios.ai: plum dark, marquee gold, neon accents. */
:root {
  --bg: #13091d;
  --panel: #1b1027;
  --panel2: #241634;
  --line: rgba(255, 255, 255, .1);
  --ink: #f8f0e6;
  --muted: #bba9c8;
  --gold: #f6c453;
  --pink: #ff3f73;
  --cyan: #45d6e6;
  --green: #59e3a8;
  --paper: #fbf6ec;
  --paper-ink: #2a2030;
  --body: 'Archivo', system-ui, sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  --hand: 'Caveat', cursive;
  --marquee: 'Limelight', Georgia, serif;
  --rail-l: 280px;
  --rail-r: 120px;
  --chat-w: 360px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hand { font-family: var(--hand); font-size: 1.6rem; color: var(--gold); margin: 0 0 6px; line-height: 1.1; }
.hand.big { font-size: 2.2rem; }

/* ---------- the door ---------- */
.door { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(60% 50% at 20% 0%, rgba(246,196,83,.18), transparent 60%), radial-gradient(50% 45% at 85% 10%, rgba(255,63,115,.16), transparent 60%), var(--bg); }
.door-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; display: grid; gap: 10px; text-align: center; }
.door-mark, .brand-mark { display: grid; place-items: center; font-family: var(--marquee); color: #1d1424; border-radius: 50%; background: conic-gradient(from 200deg, var(--gold), var(--pink), var(--cyan), var(--gold)); }
.door-mark { width: 56px; height: 56px; font-size: 1.8rem; margin: 0 auto 4px; }
.door h1 { margin: 0; font: 400 2rem/1.1 var(--marquee); color: var(--gold); }
.door p { margin: 0 0 8px; color: var(--muted); }
.door label { text-align: left; font-size: .8rem; color: var(--muted); }
.door input { background: #0b0612; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 1rem; }
.door button { border: 0; border-radius: 12px; padding: 12px; background: var(--gold); color: #1d1424; font-weight: 800; }
.door-err { color: var(--pink); min-height: 1.2em; }

/* ---------- the frame: four rails, work area, chat ---------- */
.studio { height: 100dvh; display: grid;
  grid-template-columns: var(--rail-l) minmax(0, 1fr) var(--chat-w) var(--rail-r);
  grid-template-rows: 56px minmax(0, 1fr) 34px;
  grid-template-areas: "top top top top" "left work chat right" "bottom bottom bottom bottom"; }
.rail { background: var(--panel); }
.top-rail { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.left-rail { grid-area: left; border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.work { grid-area: work; overflow: hidden; display: flex; min-width: 0; }
.chat { grid-area: chat; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.right-rail { grid-area: right; border-left: 1px solid var(--line); overflow-y: auto; }
.bottom-rail { grid-area: bottom; display: flex; align-items: center; gap: 14px; padding: 0 14px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; font-size: 1.1rem; flex: none; }
.brand-name { font: 400 1.25rem/1 var(--marquee); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand-sub { font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.camera-btn { border: 0; border-radius: 99px; padding: 10px 18px; background: var(--gold); color: #1d1424; font-weight: 800; display: inline-flex; gap: 8px; align-items: center; box-shadow: 0 0 0 0 rgba(246,196,83,.6); animation: beckon 3s ease-in-out infinite; }
.camera-btn:hover { background: #ffd56f; }
@keyframes beckon { 0%, 70%, 100% { box-shadow: 0 0 0 0 rgba(246,196,83,0); } 80% { box-shadow: 0 0 0 8px rgba(246,196,83,.18); } }
.ghost-btn { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 9px 14px; font-weight: 600; }
.ghost-btn:hover { border-color: rgba(255,255,255,.3); }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; font-size: 1.05rem; }
.icon-btn:hover { background: var(--panel2); }

.rail-head { padding: 14px 14px 8px; font-size: .7rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.count { color: var(--gold); letter-spacing: 0; }

/* ---------- left rail: drafts as a chat-style list ---------- */
.draft-list { display: flex; flex-direction: column; padding: 0 8px 12px; gap: 2px; }
.day { padding: 12px 8px 4px; font-size: .72rem; color: var(--muted); }
.draft-item { text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 9px 10px; display: grid; gap: 2px; }
.draft-item:hover { background: var(--panel2); }
.draft-item.on { background: var(--panel2); box-shadow: inset 3px 0 0 var(--gold); }
.draft-item.fresh { animation: fresh 2.4s ease; }
@keyframes fresh { 0% { background: rgba(246,196,83,.35); } 100% { background: transparent; } }
.draft-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-item .p { font-size: .8rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kind { display: inline-block; font-size: .62rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; margin-right: 6px; vertical-align: 1px; }
.kind.post { background: rgba(246,196,83,.18); color: var(--gold); }
.kind.fragment { background: rgba(69,214,230,.16); color: var(--cyan); }
.kind.list { background: rgba(89,227,168,.16); color: var(--green); }
.kind.note { background: rgba(255,255,255,.08); color: var(--muted); }
.empty { padding: 8px 18px; color: var(--muted); font-size: .9rem; }
.job { margin: 0 12px 10px; padding: 12px; border-radius: 14px; background: linear-gradient(135deg, rgba(246,196,83,.14), rgba(255,63,115,.12)); border: 1px solid rgba(246,196,83,.3); font-size: .85rem; }
.job b { color: var(--gold); }
.job.err { background: rgba(255,63,115,.12); border-color: rgba(255,63,115,.4); }
.job .quip { color: var(--muted); font-style: italic; margin-top: 4px; min-height: 1.3em; }
.job button { margin-top: 8px; border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 5px 12px; font-size: .8rem; }
.dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- work area ---------- */
.no-draft { margin: auto; text-align: center; padding: 24px; }
.editor { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--paper); color: var(--paper-ink); }
.editor-head { display: flex; gap: 10px; align-items: center; padding: 18px 28px 10px; flex-wrap: wrap; }
.title-input { flex: 1 1 260px; min-width: 0; border: 0; background: transparent; font: 600 1.7rem/1.2 var(--serif); color: var(--paper-ink); outline: none; }
.editor-tools { display: flex; gap: 8px; align-items: center; }
.editor-tools select { background: #fff; border: 1px solid #e3d9c8; border-radius: 8px; padding: 6px 8px; color: var(--paper-ink); }
.seg { display: inline-flex; border: 1px solid #e3d9c8; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; color: var(--paper-ink); }
.seg button.on { background: var(--paper-ink); color: var(--paper); }
.editor .icon-btn:hover { background: #efe6d6; }
.notes-banner { margin: 0 28px 8px; padding: 9px 12px; border-radius: 10px; background: #fff3cf; border: 1px solid #f0d98a; font-size: .85rem; color: #5a4310; }
.body-input, .preview { flex: 1; overflow-y: auto; padding: 8px 28px 40px; font: 1.12rem/1.7 var(--serif); color: var(--paper-ink); }
.body-input { border: 0; background: transparent; resize: none; outline: none; }
.preview { max-width: 46em; }
.preview h1, .preview h2, .preview h3 { font-family: var(--serif); line-height: 1.25; }
.preview blockquote { border-left: 3px solid var(--gold); margin-left: 0; padding-left: 14px; color: #5b4d63; }

/* ---------- chat ---------- */
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--marquee); color: #1d1424; background: conic-gradient(from 200deg, var(--cyan), var(--gold), var(--pink), var(--cyan)); flex: none; }
.chat-head b { display: block; font-size: .95rem; }
.chat-head small { color: var(--muted); font-size: .75rem; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: 16px; font-size: .92rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mike { align-self: flex-end; background: var(--gold); color: #1d1424; border-top-right-radius: 4px; font-weight: 600; }
.msg.claude { align-self: flex-start; background: var(--panel2); border-top-left-radius: 4px; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: .8rem; font-style: italic; text-align: center; }
.msg.err { align-self: center; color: var(--pink); font-size: .82rem; }
.proposal { margin-top: 8px; padding: 9px; border-radius: 10px; background: rgba(0,0,0,.25); font-size: .82rem; white-space: normal; }
.proposal .pt { color: var(--muted); }
.proposal button { margin: 8px 6px 0 0; border: 0; border-radius: 99px; padding: 5px 12px; font-weight: 700; font-size: .8rem; background: var(--cyan); color: #0b1a1d; }
.proposal button.alt { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.proposal.done { opacity: .6; }
.chat-compose { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.chat-compose textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; background: #0b0612; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: .95rem; outline: none; }
.chat-compose textarea:focus { border-color: rgba(246,196,83,.5); }
.chat-compose button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--gold); color: #1d1424; font-weight: 800; }
.chat-compose button:disabled { opacity: .45; cursor: default; }
.chat-blank { margin: auto; text-align: center; color: var(--muted); padding: 20px; font-size: .9rem; }

/* ---------- right rail: pages ---------- */
.page-thumbs { padding: 0 10px 14px; display: grid; gap: 10px; }
.page-thumbs p { margin: 0 4px; }
.page-thumb { border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: #000; position: relative; }
.page-thumb img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.page-thumb span { position: absolute; left: 4px; bottom: 4px; font-size: .68rem; font-weight: 800; background: rgba(0,0,0,.7); padding: 1px 6px; border-radius: 6px; }

.badge { padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); }
.badge.live { color: var(--green); border-color: rgba(89,227,168,.4); }
.badge.demo { color: var(--gold); border-color: rgba(246,196,83,.4); }
.save-state.dirty { color: var(--gold); }

/* ---------- camera ---------- */
.camera { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .25s ease-out; }
@keyframes flash { 0% { opacity: .8; } 100% { opacity: 0; } }
.cam-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; text-align: center; color: var(--muted); font-size: 1.05rem; }
.cam-top { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 14px 12px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.cam-pill { border: 0; border-radius: 99px; padding: 9px 15px; background: rgba(0,0,0,.55); color: #fff; font-weight: 700; backdrop-filter: blur(6px); }
.cam-pill.done { background: var(--gold); color: #1d1424; }
.cam-pill.done:disabled { opacity: .4; }
.cam-strip { position: relative; margin-top: auto; display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px; }
.cam-shot { position: relative; flex: none; width: 58px; height: 76px; border-radius: 8px; overflow: hidden; border: 2px solid rgba(255,255,255,.7); padding: 0; background: #222; }
.cam-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-shot .st { position: absolute; right: 2px; top: 2px; font-size: .7rem; background: rgba(0,0,0,.65); border-radius: 6px; padding: 0 4px; color: #fff; }
.cam-shot .num { position: absolute; left: 2px; bottom: 2px; font-size: .68rem; font-weight: 800; background: rgba(0,0,0,.65); border-radius: 6px; padding: 0 5px; color: #fff; }
.cam-shot.failed { border-color: var(--pink); }
.cam-bottom { position: relative; display: flex; align-items: center; justify-content: space-around; padding: 12px 20px calc(22px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: var(--gold); box-shadow: 0 0 0 3px rgba(0,0,0,.4); }
.shutter:active { transform: scale(.93); }
.cam-side { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.4rem; background: rgba(0,0,0,.5); cursor: pointer; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 56px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100vw - 32px); display: flex; gap: 12px; align-items: center; }
.toast button { border: 0; background: transparent; color: var(--gold); font-weight: 800; }

.only-phone { display: none !important; }

/* ---------- mid widths: fold the right rail into a narrow strip ---------- */
@media (max-width: 1280px) { :root { --chat-w: 320px; --rail-l: 240px; --rail-r: 92px; } }

/* ---------- phones and small tablets: one pane at a time ---------- */
@media (max-width: 860px) {
  .only-phone { display: inline-flex !important; }
  .hide-phone, .brand-sub { display: none; }
  .studio { grid-template-columns: 100%; grid-template-rows: 56px minmax(0, 1fr) 50px; grid-template-areas: "top" "work" "bottom"; }
  .left-rail { position: fixed; z-index: 30; top: 56px; bottom: 50px; left: 0; width: min(320px, 86vw); transform: translateX(-100%); transition: transform .25s ease; box-shadow: 10px 0 30px rgba(0,0,0,.4); }
  .studio.drawer .left-rail { transform: none; }
  .chat, .right-rail { grid-area: work; border: 0; }
  .studio:not(.pane-chat) .chat { display: none; }
  .studio:not(.pane-pages) .right-rail { display: none; }
  .studio.pane-chat .work, .studio.pane-pages .work { display: none; }
  .page-thumbs { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .bottom-rail { gap: 8px; padding: 0 8px; }
  .bottom-rail #wordCount, .bottom-rail .badge { display: none; }
  .phone-tabs { margin-left: auto; gap: 4px; }
  .phone-tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 99px; font-weight: 700; color: var(--muted); }
  .phone-tabs button.on { background: var(--panel2); color: var(--gold); }
  .camera-btn { padding: 9px 14px; white-space: nowrap; }
  .ghost-btn { padding: 8px 12px; }
  .brand-name { font-size: 1.1rem; }
  .editor-head { padding: 14px 16px 8px; }
  .title-input { font-size: 1.35rem; }
  .body-input, .preview { padding: 6px 16px 40px; font-size: 1.05rem; }
  .notes-banner { margin: 0 16px 8px; }
}

/* ---------- who answers: team AI or built-in ---------- */
.chat-who { min-width: 0; flex: 1; }
.seat { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; flex: none; }
.seat button { border: 0; background: transparent; padding: 5px 10px; font-size: .74rem; font-weight: 700; color: var(--muted); }
.seat button.on { background: var(--cyan); color: #0b1a1d; }
.msg .who { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.msg.team { border: 1px solid rgba(69,214,230,.35); }
.msg.team .who { color: var(--cyan); }
