/* writeaid studio — Notion-like: white, neutral, clean. Serif reserved for prose. */
:root {
  --bg: #FFFFFF;
  --bg-side: #F7F7F5;          /* sidebar / rails */
  --bg-hover: rgba(55, 53, 47, 0.06);
  --bg-code: #F7F7F5;
  --card: #FFFFFF;
  --ink: #37352F;
  --quiet: #787774;
  --faint: #9B9A97;
  --line: #EDEDEC;
  --line-strong: #DFDFDE;
  --blue: #2383E2;             /* primary actions only */
  --blue-hover: #1C74C9;
  --blue-soft: #E7F3F8;
  --green: #448361;
  --green-soft: #EDF3EC;
  --red: #D44C47;
  --red-soft: #FDEBEC;
  --amber: #CB912F;
  --amber-soft: #FBF3DB;
  --purple: #9065B0;
  --purple-soft: #F6F3F9;
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 15, 15, 0.1);
  --serif: 'Lyon Text', Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}
* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }

#app { display: grid; grid-template-columns: 224px 1fr 320px; height: 100vh; }

/* ---------- sidebar ---------- */
#sidebar { border-right: 1px solid var(--line); background: var(--bg-side); padding: 16px 10px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.brand { font-size: 15px; font-weight: 600; padding: 2px 8px; letter-spacing: -0.01em; }
.brand-accent { color: var(--blue); }
.brand-sub { font-size: 11px; color: var(--faint); font-weight: 400; margin-left: 2px; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: 0.03em; color: var(--faint); padding: 2px 8px; display: flex; justify-content: space-between; align-items: center; }
#storyList .story-row { padding: 5px 8px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }
#storyList .story-row:hover { background: var(--bg-hover); }
#storyList .story-row.active { background: var(--bg-hover); font-weight: 600; }
.story-mode { font-size: 10.5px; color: var(--faint); }
.nav-item { display: block; padding: 5px 8px; border-radius: 4px; cursor: pointer; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-hover); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.ai-pill { font-size: 11px; padding: 3px 9px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--card); width: fit-content; color: var(--quiet); }
.ai-pill.on { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.ai-pill.off { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }
.side-hint { font-size: 11px; color: var(--faint); line-height: 1.5; }

/* ---------- main ---------- */
#main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
#topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--bg); min-height: 48px; }
#crumb { font-size: 14px; font-weight: 600; color: var(--ink); }
#content { flex: 1; overflow: auto; padding: 24px 28px; }

/* board */
#boardWrap { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 10px; align-items: start; }
.col { background: var(--bg-side); border-radius: 6px; padding: 8px; min-height: 120px; }
.col-head { font-size: 11.5px; font-weight: 600; color: var(--quiet); margin: 2px 4px 8px; display: flex; justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; margin-bottom: 6px; cursor: pointer; box-shadow: var(--shadow-sm); transition: background .1s; }
.card:hover { background: #FAFAF9; }
.card-nn { font-size: 10.5px; color: var(--faint); }
.card-title { font-size: 13.5px; font-weight: 500; margin: 2px 0 6px; }
.chip { display: inline-block; font-size: 10.5px; font-weight: 500; padding: 1px 7px; border-radius: 4px; margin-right: 4px; }
.chip-pass { background: var(--green-soft); color: var(--green); }
.chip-fail { background: var(--red-soft); color: var(--red); }
.chip-fork { background: var(--amber-soft); color: var(--amber); }
.chip-crit { background: var(--purple-soft); color: var(--purple); }
.banner { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; line-height: 1.5; }
.banner-warn { background: var(--amber-soft); color: #6E5720; border: 1px solid #F0E2B8; }

/* editor + prose */
.editor { width: 100%; min-height: 62vh; border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; font-family: var(--serif); font-size: 15.5px; line-height: 1.65; background: var(--card); resize: vertical; color: var(--ink); }
.editor:focus { outline: none; border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.prose { font-family: var(--serif); font-size: 16px; line-height: 1.7; max-width: 700px; }
.prose h2 { font-size: 20px; margin-bottom: 14px; font-family: var(--sans); font-weight: 700; letter-spacing: -0.01em; }
.prose h3, .prose h4 { font-family: var(--sans); margin: 14px 0 8px; }
.prose p { margin-bottom: 13px; }
.review-box { border: 1px solid var(--line); border-radius: 6px; background: var(--card); margin-top: 12px; max-width: 700px; }
.review-head { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; border-radius: 6px; }
.review-head:hover { background: var(--bg-hover); }
.review-body { display: none; padding: 4px 14px 14px; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; max-height: 420px; overflow: auto; border-top: 1px solid var(--line); color: var(--quiet); }
.review-box.open .review-body { display: block; }

/* buttons */
.btn { font-family: var(--sans); font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); cursor: pointer; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-accent { color: var(--blue); border-color: var(--blue); background: var(--card); }
.btn-accent:hover { background: var(--blue-soft); }
.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn[disabled] { opacity: .45; cursor: default; }
.mini-btn { border: 1px solid transparent; background: transparent; border-radius: 4px; font-size: 12px; cursor: pointer; padding: 2px 6px; color: var(--faint); }
.mini-btn:hover { background: var(--bg-hover); color: var(--ink); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* ---------- rail ---------- */
#rail { border-left: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; }
.rail-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.rail-tab { flex: 1; padding: 11px 0 9px; background: none; border: none; border-bottom: 2px solid transparent; font-size: 12.5px; font-weight: 500; color: var(--quiet); cursor: pointer; }
.rail-tab:hover { color: var(--ink); }
.rail-tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.rail-pane { display: none; flex: 1; min-height: 0; flex-direction: column; overflow-y: auto; padding: 12px; }
.rail-pane.active { display: flex; }

/* agent chat */
.agent-pick-row { display: flex; gap: 6px; margin-bottom: 6px; }
#agentSelect { flex: 1; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--card); font-size: 13px; color: var(--ink); }
#agentDesc { margin-bottom: 8px; }
#chatThread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.chat-msg { border-radius: 8px; padding: 8px 11px; font-size: 13px; line-height: 1.55; max-width: 95%; }
.chat-msg.user { background: var(--blue); color: #fff; align-self: flex-end; }
.chat-msg.assistant { background: var(--bg-side); align-self: flex-start; }
.chat-msg.assistant h2, .chat-msg.assistant h3, .chat-msg.assistant h4 { font-size: 13px; margin: 6px 0 4px; }
.chat-msg.assistant p { margin-bottom: 7px; }
.chat-msg.assistant p:last-child { margin-bottom: 0; }
.chat-msg.thinking { color: var(--faint); font-style: italic; }
.chat-compose { display: flex; gap: 6px; margin-top: 10px; align-items: flex-end; }
#chatText { flex: 1; border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; font-size: 13px; min-height: 54px; resize: vertical; background: var(--card); font-family: var(--sans); }
#chatText:focus { outline: none; border-color: var(--blue); }

/* tools pane */
.tool-btn { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 11px; margin-bottom: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink); }
.tool-btn:hover { background: var(--bg-hover); }
.tool-out { flex: 1; background: var(--bg-code); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.55; overflow: auto; white-space: pre-wrap; margin-top: 8px; min-height: 140px; }

/* artifact tree */
.tree-group { margin-bottom: 2px; }
.tree-file { font-size: 12.5px; padding: 3px 8px 3px 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--quiet); }
.tree-file:hover { color: var(--ink); }
.tree-file.active { color: var(--ink); }
.nav-board, .nav-read { font-weight: 500; }
.li { margin-bottom: 4px !important; }

/* activity log */
#activityLog { display: flex; flex-direction: column; gap: 5px; }
.log-line { font-size: 12px; padding: 6px 10px; border-radius: 6px; background: var(--bg-side); color: var(--quiet); }
.log-line.err { background: var(--red-soft); color: var(--red); }
.log-line.ok { background: var(--green-soft); color: var(--green); }
.rail-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
#directionText { border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; font-family: var(--sans); font-size: 13px; min-height: 56px; resize: vertical; background: var(--card); }
#directionText:focus { outline: none; border-color: var(--blue); }
.rail-foot-row { display: flex; justify-content: space-between; align-items: center; }

/* direction question cards */
.q-card { background: var(--card); border: 1px solid var(--line-strong); border-left: 3px solid var(--blue); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.q-header { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--blue); margin-bottom: 4px; }
.q-text { font-size: 13.5px; font-weight: 500; margin-bottom: 10px; }
.q-opt { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; font-size: 12.5px; color: var(--quiet); }
.q-opt:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.q-opt.picked { border-color: var(--blue); background: var(--blue-soft); color: var(--ink); }
.q-opt b { display: block; font-size: 13px; color: var(--ink); }
.q-other { width: 100%; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 7px 10px; font-size: 12.5px; background: var(--card); }
.q-other:focus { outline: none; border-style: solid; border-color: var(--blue); }

/* modal */
#modalHost:empty { display: none; }
.modal-back { position: fixed; inset: 0; background: rgba(15, 15, 15, .35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 8px; padding: 20px; width: min(420px, 92vw); box-shadow: var(--shadow-md); }
.modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.modal input, .modal select { width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px; margin-bottom: 10px; font-size: 14px; background: var(--card); }
.modal input:focus, .modal select:focus { outline: none; border-color: var(--blue); }
.modal-row { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- FOCUS MODE: only the page ---------- */
body[data-view="focus"] #app { grid-template-columns: 1fr; }
body[data-view="focus"] #sidebar, body[data-view="focus"] #rail { display: none; }
body[data-view="focus"] #topbar {
  border-bottom: none; background: transparent; position: sticky; top: 0;
  padding: 10px 26px; opacity: .4; transition: opacity .2s;
}
body[data-view="focus"] #topbar:hover { opacity: 1; }
body[data-view="focus"] #crumb { font-size: 12.5px; color: var(--faint); font-weight: 400; }
body[data-view="focus"] #content { padding: 12px 24px 12vh; }
body[data-view="focus"] .prose {
  max-width: 700px; margin: 0 auto; padding: 12px 8px;
  font-size: 18px; line-height: 1.8;
}
body[data-view="focus"] .prose h2 { font-size: 23px; margin: 30px 0 18px; }
body[data-view="focus"] .editor {
  max-width: 740px; margin: 0 auto; display: block; min-height: 78vh;
  border: none; box-shadow: none; background: transparent; font-size: 17.5px; line-height: 1.8; padding: 12px 8px;
}
body[data-view="focus"] .editor:focus { outline: none; }
body[data-view="focus"] .review-box, body[data-view="focus"] .banner { display: none; }

/* manuscript (Read view) */
.ms-chapter { margin-bottom: 34px; }
.ms-meta { font-family: var(--sans); font-size: 10.5px; font-weight: 600; color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em; margin: 26px 0 6px; display: flex; gap: 10px; }
.ms-rule { border: none; border-top: 1px solid var(--line); margin: 30px auto; width: 120px; }

@media (max-width: 1100px) { #app { grid-template-columns: 208px 1fr; } #rail { display: none; } }
