/* ECT house style in the manner of ChatGPT / Claude (user's pick, 2026-11-05): white and quiet, a light sidebar, assistant replies as plain
 * text, the user's words in a grey bubble, one rounded input box. ECT green only on buttons and small accents; logo stays.
 * Earlier notes: soft rounded shapes and plenty of air (users found square corners cramped),
 * a faint กากบาท (ballot cross) pattern only on login, Noto Sans Thai. Chat flow: one question per bubble.
 * Gold only for "waits for a person" (review / approve). Noto Serif Thai only for news headlines.
 */
@font-face { font-family: "Noto Sans Thai"; src: url("fonts/NotoSansThai.ttf") format("truetype"); font-weight: 100 900; font-display: optional; }
@font-face { font-family: "Noto Serif Thai"; src: url("fonts/NotoSerifThai.ttf") format("truetype"); font-weight: 100 900; font-display: optional; }

:root {
  --green: #2D8160;
  --green-deep: #10563A;
  --green-ink: #1F4E3A;
  --green-soft: #EAF4EF;
  --bg: #FFFFFF;
  --panel: #F1F5F3;
  --panel-2: #F7F8F7;
  --line: #DCE2DF;
  --line-strong: #C5CFCA;
  --ink: #232323;
  --muted: #5C6762;
  --on-green: #FFFFFF;
  --on-green-muted: #C4DDD1;
  --gold: #8A6417;
  --gold-bright: #D9A93F;
  --gold-on-green: #F2CB6E;
  --gold-line: #ECD9A8;
  --green-line: #CFE3D8;
  --gold-soft: #FBF4E3;
  --danger: #B42318;
  --danger-soft: #FCEBE9;
  --danger-line: #F3C9C4;
  --scrim: rgba(16, 40, 30, .45);
  --focus-ring: rgba(45, 129, 96, .22);
  --shadow: 0 10px 26px -12px rgba(16, 86, 58, .28);
  --font: "Noto Sans Thai", system-ui, sans-serif;
  --serif: "Noto Serif Thai", Georgia, serif;
  --fs-xs: 13px; --fs-sm: 15px; --fs: 17px; --fs-lg: 19px; --fs-xl: 24px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r: 12px;
  --r-sm: 8px;
  --r-lg: 18px;
  --pill: 999px;
  --thread: 780px;
  --side: #F7F8F7;
  --hover: #EDF0EE;
  --user-bubble: #F0F2F1;
  --sidebar-w: 288px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  /* outlined ballot crosses, as on ect.go.th */
  --crosses: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360'%3E%3Cg fill='none' stroke='%23EDF1EE' stroke-width='1.5'%3E%3Cpath transform='translate(70 80) rotate(45)' d='M-7-26H7V-7H26V7H7V26H-7V7H-26V-7H-7Z'/%3E%3Cpath transform='translate(270 60) rotate(45) scale(.6)' d='M-7-26H7V-7H26V7H7V26H-7V7H-26V-7H-7Z'/%3E%3Cpath transform='translate(250 260) rotate(45) scale(1.5)' d='M-7-26H7V-7H26V7H7V26H-7V7H-26V-7H-7Z'/%3E%3Cpath transform='translate(90 300) rotate(45) scale(.8)' d='M-7-26H7V-7H26V7H7V26H-7V7H-26V-7H-7Z'/%3E%3C/g%3E%3C/svg%3E");
  --arrow-green: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232D8160' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
  --arrow-white: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
  --arrow-ne: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M9 7h8v8'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { overflow-x: clip; height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs)/1.65 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-weight: 700; line-height: 1.3; margin: 0; overflow-wrap: anywhere; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
::selection { background: #CDE6D9; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell: ECT-green sidebar, white chat ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100dvh; }
.sidebar { background: var(--side); color: var(--ink); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sb-top { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s2) var(--s3); margin: 0 var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; font-weight: 700; font-size: var(--fs); line-height: 1.3; min-width: 0; color: var(--green-ink); }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img { width: 36px; height: 36px; border-radius: 50%; flex: none; background: #fff; }
.sb-actions { padding: var(--s2) var(--s3) 0; display: grid; gap: var(--s3); }
.btn-new { display: flex; align-items: center; justify-content: flex-start; gap: var(--s2); height: 44px; padding: 0 14px; border-radius: var(--r); background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; transition: background-color 150ms var(--ease); }
.btn-new:hover { background: var(--hover); }
.btn-new svg.i { color: var(--green); }
.search { display: flex; align-items: center; gap: var(--s2); height: 44px; padding: 0 var(--s4); border-radius: var(--r); background: transparent; border: 1px solid transparent; color: var(--muted); }
.search svg.i { width: 18px; height: 18px; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; min-width: 0; font-size: var(--fs-sm); color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search:hover { background: var(--hover); }
.search:focus-within { border-color: var(--line-strong); background: #fff; }
.sb-list { flex: 1; overflow-y: auto; padding: var(--s2) var(--s3) var(--s4); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.sb-group { margin: 0; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding: 18px var(--s3) 6px; }
.sb-list section:first-child .sb-group { padding-top: 6px; }
.sb-list ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.sb-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px var(--s3); border-radius: var(--pill); text-decoration: none; color: var(--ink); transition: background-color 120ms var(--ease); }
.sb-item > .i { width: 16px; height: 16px; flex: none; color: var(--muted); }
.sb-item.is-active > .i { color: var(--green); }
.sb-text { display: grid; min-width: 0; flex: 1; }
.sb-item:hover { background: var(--hover); }
.sb-item.is-active { background: var(--green-soft); color: var(--green-ink); font-weight: 600; }
.sb-title { display: block; font-size: var(--fs-sm); line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-meta { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--gold); }
.sb-meta:has(.failed) { color: var(--danger); }
/* "…" per job: pin, rename, remove. Shown on hover or focus with a pointer; always shown on touch screens. */
.sb-list li { position: relative; }
.sb-list li .sb-item { padding-right: var(--s3); }
.sb-item.is-active, .sb-list li:focus-within .sb-item { padding-right: 44px; }
.sb-list li:hover .sb-more-btn:not(:hover) { background: var(--hover); box-shadow: -14px 0 10px -2px var(--hover); }  /* the title fades under the button */
@media (hover: none) { .sb-list li .sb-item { padding-right: 44px; } }
.sb-list li:hover .sb-item.is-active + .sb-more .sb-more-btn:not(:hover) { background: transparent; box-shadow: none; }
.sb-more { position: absolute; top: 3px; right: 3px; }
.sb-more-btn { list-style: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--muted); cursor: pointer; opacity: 0; }
.sb-more-btn::-webkit-details-marker { display: none; }
.sb-list li:hover .sb-more-btn, .sb-more-btn:focus-visible, .sb-more[open] .sb-more-btn, .sb-item.is-active + .sb-more .sb-more-btn { opacity: 1; }
.sb-more-btn:hover, .sb-more[open] .sb-more-btn { background: rgba(16, 86, 58, .08); color: var(--ink); }
.sb-more-btn:focus-visible { outline: 3px solid var(--focus-ring); }
@media (hover: none) { .sb-more-btn { opacity: 1; } }
.sb-pop { position: absolute; right: 0; top: 38px; z-index: 20; width: 240px; padding: var(--s2); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 2px; }
.sb-pop-row { display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 40px; padding: 0 var(--s3); border: 0; border-radius: 10px; background: none; font: inherit; font-size: var(--fs-sm); color: var(--ink); cursor: pointer; text-align: left; }
.sb-pop-row:hover { background: var(--hover); }
.sb-pop-row.is-danger { color: var(--danger); }
.sb-pop-row.is-danger:hover { background: var(--danger-soft); }
.sb-pop .i { width: 18px; height: 18px; flex: none; }
.sb-rename { display: grid; gap: var(--s2); padding: var(--s2) var(--s3); border-block: 1px solid var(--line); margin-block: 2px; }
.sb-pop-label { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--ink); }
.sb-rename input { min-width: 0; height: 38px; padding: 0 var(--s3); border: 1px solid var(--line-strong); border-radius: 999px; font: inherit; font-size: var(--fs-sm); }
.sb-rename input:focus { outline: 3px solid var(--focus-ring); border-color: var(--green); }
.sb-pop-save { justify-self: start; height: 44px; padding: 0 var(--s4); border: 0; border-radius: 999px; background: var(--green); color: var(--on-green); font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.running, .dot.queued, .dot.waiting_approval { background: var(--gold-bright); }
.dot.done { background: var(--green); }
.dot.failed { background: var(--danger); }
.sb-empty { padding: var(--s4) var(--s3); color: var(--muted); font-size: var(--fs-sm); }
.sb-foot { border-top: 1px solid var(--line); margin: 0 var(--s3); padding: var(--s4) 0; display: flex; align-items: center; gap: var(--s1); }
.who { display: flex; align-items: center; gap: var(--s3); min-width: 0; flex: 1; font-size: var(--fs-sm); font-weight: 600; }
.who span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.initial { width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--panel); color: var(--green-deep); }
.sidebar .icon-btn:hover { background: var(--hover); }
.icon-btn svg.i { width: 19px; height: 19px; }
.nav-close, .scrim { display: none; }
.sidebar { position: relative; }
.sb-resize { position: absolute; top: 0; right: -5px; bottom: 0; width: 10px; z-index: 5; cursor: col-resize; touch-action: none; }
.sb-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: transparent; transition: background-color 150ms var(--ease); }
.sb-resize:hover::after, .sb-resize:focus-visible::after, .sb-resizing .sb-resize::after { background: var(--green); }
.sb-resize:focus-visible { outline: none; }
.sb-resizing, .sb-resizing * { cursor: col-resize !important; user-select: none; }
.sb-mini .sb-resize { display: none; }
.sb-toggle { margin-left: auto; flex: none; width: 36px; height: 36px; margin-right: -6px; }

/* Folded sidebar (desktop): a slim rail of the logo, new job, search and account; the list waits behind "ขยาย". */
@media (min-width: 861px) {
  .sb-mini .shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sb-mini .sb-top { flex-direction: column; gap: var(--s2); margin: 0; padding: var(--s4) 0 var(--s2); }
  .sb-mini .sb-toggle { margin: 0; }
  .sb-mini .brand span, .sb-mini .btn-new span, .sb-mini .search input, .sb-mini .sb-list, .sb-mini .who span:last-child { display: none; }
  .sb-mini .sb-actions { padding: var(--s2) 0 0; justify-items: center; gap: var(--s2); }
  .sb-mini .btn-new { width: 44px; padding: 0; justify-content: center; }
  .sb-mini .search { width: 44px; padding: 0; justify-content: center; cursor: pointer; }
  .sb-mini .sb-foot { flex-direction: column; margin: auto var(--s2) 0; gap: var(--s2); }
  .sb-mini .who { flex: none; }
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s6); background: #fff; }
.topbar .avatar { display: none; }
.topbar .title { flex: 1; min-width: 0; font-size: var(--fs); font-weight: 600; color: var(--muted); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .icon-btn { display: none; }
.scroll { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- thread ---------- */
.thread { max-width: var(--thread); margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); display: grid; gap: 28px; }
.msg-user { display: flex; justify-content: flex-end; align-items: center; gap: var(--s2); }
.bubble { background: var(--user-bubble); color: var(--ink); border-radius: 22px; padding: 10px 18px; max-width: min(80%, 620px); overflow-wrap: anywhere; }
.bubble .pre { white-space: pre-line; }
.bubble strong { font-weight: 700; }
.bubble dl { display: grid; grid-template-columns: minmax(0, 13em) minmax(0, 1fr); gap: 4px var(--s4); margin: var(--s2) 0 0; padding-top: var(--s3); border-top: 1px solid var(--green-line); font-size: var(--fs-sm); }
.bubble dt { color: var(--muted); }
.bubble dd { margin: 0; white-space: pre-line; }
/* the request summary on a job page is reference material, not a fresh message: light, not a green slab */
.bubble:has(dl) { background: var(--user-bubble); color: var(--ink); border: 0; max-width: min(100%, 660px); }
.bubble:has(dl) strong { color: var(--green-ink); }
.msg-ai { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: var(--s3); align-items: start; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.ai-body { scroll-margin-top: var(--s5); display: grid; gap: 10px; justify-items: start; min-width: 0; }
.ai-body > * { max-width: 100%; }
/* the assistant speaks in grey panels with an ECT-green edge, like the list items on ect.go.th */
.ai-body > p:not(.time, .note) { padding-top: 2px; max-width: 680px; }
.time { font-size: var(--fs-xs); color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-user.is-new, .msg-ai.is-new { animation: rise .25s var(--ease); }  /* only a message added after load moves; the first screen is still */

/* topic cards: grey panel, green icon, green corner arrow (ect.go.th card pattern) */
.tasks, .options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.task, .option { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; align-items: center; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px; text-decoration: none; transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.option { grid-template-columns: minmax(0, 1fr); align-content: center; }
.task::after, .option::after { display: none; content: ""; position: absolute; right: 18px; top: 50%; width: 34px; height: 34px; margin-top: -17px; border-radius: 50%; background: var(--green-soft) var(--arrow-green) center / 17px no-repeat; transition: background-color 160ms var(--ease); }
.task:hover, .option:hover { background: var(--side); border-color: var(--line-strong); }
.task:hover::after, .option:hover::after { background-color: var(--green); background-image: var(--arrow-white); }
.task-icon { grid-row: span 2; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--side); border: 1px solid var(--line); color: var(--green); }
.task b, .option b { display: block; font-size: var(--fs); font-weight: 700; line-height: 1.35; }
.task span:not(.task-icon), .option span { display: block; font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; margin-top: 2px; }

/* ---------- home: a new chat ---------- */
.hero { min-height: 100%; max-width: var(--thread); margin: 0 auto; padding: var(--s6) var(--s5) 12vh; display: grid; align-content: center; justify-items: center; gap: var(--s5); text-align: center; }
.hero-logo { width: 56px; height: 56px; }
.hero h1 { font-size: 28px; font-weight: 600; line-height: 1.4; }
.hero .composer { width: 100%; text-align: left; padding-top: 18px; }
.hero .composer textarea { min-height: 56px; }
.fine { font-size: var(--fs-xs); color: var(--muted); margin-top: calc(var(--s2) * -1); }
/* four starting points, each saying what it makes (as on an assistant workspace's welcome screen) */
.suggest { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); text-align: left; margin-top: var(--s3); }
.suggest a { display: grid; align-content: start; gap: 2px; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
.suggest a:hover { background: var(--side); border-color: var(--line-strong); }
.suggest-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); margin-bottom: 8px; }
.suggest svg.i { width: 18px; height: 18px; }
.suggest b { font-size: var(--fs-sm); line-height: 1.4; }
.suggest a > span:last-child { font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }

/* ---------- chat beside the document (the press release is the work; the chat fills it in) ---------- */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); }
.pane { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.split > .chat-pane { max-width: none; margin: 0; padding: var(--s5) var(--s5) var(--s6); align-content: start; border-right: 1px solid var(--line); }
.chat-pane .msg-ai { grid-template-columns: 30px minmax(0, 1fr); }
.chat-pane .fields { grid-template-columns: minmax(0, 1fr); }
.chat-pane .card-head, .chat-pane .card-body, .chat-pane .card-foot { padding-left: var(--s4); padding-right: var(--s4); }
.canvas-pane { background: var(--side); display: flex; flex-direction: column; scrollbar-gutter: stable; }
.canvas-bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: 8px var(--s5);
  background: rgba(247, 248, 247, .94); border-bottom: 1px solid var(--line); }
.canvas-bar b { font-size: var(--fs-sm); }
.canvas-meta { font-size: var(--fs-xs); color: var(--muted); }
.canvas-bar .btn { min-height: 44px; padding: 0 18px; }
.canvas-doc { width: 100%; max-width: 860px; margin: 0 auto; padding: var(--s5) var(--s5) var(--s7); }
.canvas-doc .article { box-shadow: 0 1px 3px rgba(20, 30, 25, .06), 0 12px 32px -24px rgba(20, 30, 25, .3); }
.view-switch { display: none; }
/* the release edited in place: the text looks like the document, a soft field shows only on hover and focus */
.doc-edit { display: block; width: 100%; resize: none; overflow: hidden; margin: 0 -8px 10px; padding: 4px 8px; width: calc(100% + 16px);
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); line-height: 1.8; caret-color: var(--green);
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
.doc-edit:hover { background: var(--side); }
@media (hover: none) { .doc-edit { border-color: var(--line); } }  /* no hover on a phone: a resting edge says the text can be edited */
.doc-edit:focus { outline: 0; background: #fff; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.doc-h { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; line-height: 1.45; color: var(--green-ink); margin-bottom: var(--s4); }
.doc-p { text-indent: 2em; }
.doc-ol { padding-left: 2.5em; }
.doc-list { margin: 0 0 14px; padding-left: 3.5em; line-height: 1.8; }
.doc-list li + li { margin-top: 4px; }
.canvas-bar [hidden] { display: none; }
.chat-pane .msg-user .bubble { max-width: 100%; }
.dock.in-pane { position: sticky; bottom: 0; margin: auto calc(var(--s5) * -1) calc(var(--s6) * -1); padding: var(--s3) var(--s5) var(--s4); background: #fff; }
.chat-pane { display: flex; flex-direction: column; }
.chat-pane > * + * { margin-top: 28px; }
.chat-pane > .dock.in-pane { margin-top: auto; }
/* what to do next: a short list of rows, not loose chips */
.next { display: grid; width: 100%; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.next h3 { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding: 10px 16px 6px; }
.next a, .next button { display: grid; grid-template-columns: 20px minmax(0, 1fr) 16px; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 16px;
  border: 0; border-top: 1px solid var(--line); background: #fff; font: inherit; font-size: var(--fs-sm); color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.next a:hover, .next button:hover { background: var(--side); }
.next svg.i { width: 18px; height: 18px; color: var(--green); }
.next svg.i:last-child { width: 16px; height: 16px; color: var(--muted); }
.canvas-bar form { display: contents; }
/* channels: the release, or the same news as a post for Facebook, X or LINE */
.canvas-pane > * { flex-shrink: 0; }  /* the pane scrolls; nothing in it is squeezed to fit */
.channels { display: flex; gap: 4px; width: fit-content; max-width: calc(100% - 24px); margin: var(--s4) auto 0; padding: 4px; border-radius: var(--pill);
  background: var(--hover); overflow-x: auto; scrollbar-width: none; }
.channels button { flex: none; min-height: 38px; padding: 0 18px; border: 0; border-radius: var(--pill); background: transparent;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); cursor: pointer; }
.channels button:hover { color: var(--ink); }
.channels button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20, 30, 25, .15); }
.channels button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
[data-panel][hidden] { display: none; }
[data-panel] > * + * { margin-top: var(--s3); }
.post { max-width: 600px; margin-inline: auto; padding: var(--s4) var(--s4) var(--s3); background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 1px 3px rgba(20, 30, 25, .06), 0 12px 32px -24px rgba(20, 30, 25, .3); }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s3); }
.post-head img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.post-head b { display: block; font-size: var(--fs-sm); line-height: 1.3; }
.post-head span { font-size: var(--fs-xs); color: var(--muted); }
.post-text { display: block; width: 100%; resize: none; overflow: hidden; padding: 8px 10px; margin: 0 -10px; width: calc(100% + 20px);
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; font: inherit; font-size: var(--fs-sm); line-height: 1.75; color: var(--ink); }
.post-text:hover { background: var(--side); }
.post-text:focus { outline: 0; background: #fff; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.post-foot { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); font-size: var(--fs-xs); color: var(--muted); }
.post-foot form { display: contents; }
.post-foot .over { color: var(--danger); font-weight: 600; }
.post-foot [data-len] { white-space: nowrap; }
.post-note { display: flex; gap: 8px; align-items: flex-start; max-width: 600px; margin-inline: auto; font-size: var(--fs-xs); color: var(--muted); }
.post-note svg.i { flex: none; width: 16px; height: 16px; margin-top: 2px; }
[data-panel] > .notice { max-width: 600px; margin-inline: auto; }
.post-empty { display: grid; gap: var(--s3); justify-items: start; padding: var(--s5); }
.post-empty p { margin: 0; font-size: var(--fs-sm); }

/* ---------- composer ---------- */
.dock { padding: var(--s2) var(--s6) var(--s5); background: #fff; }
/* text on top, a quiet toolbar under it (attach left, send right): every control lines up whatever the text's length */
.composer { display: grid; gap: 4px; max-width: var(--thread); margin: 0 auto; padding: 14px 12px 10px 22px; border: 1px solid var(--line-strong); border-radius: 26px; background: #fff; box-shadow: 0 6px 20px -12px rgba(20, 30, 25, .25); transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease); }
.composer:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.composer.dropping, .intake.dropping textarea { border-color: var(--green); border-style: dashed; background: var(--green-soft); }
.composer-main { min-width: 0; display: grid; gap: 8px; padding-right: 10px; }
.composer textarea { width: 100%; min-width: 0; resize: none; min-height: 30px; max-height: 220px; padding: 2px 0; border: 0; background: transparent; line-height: 1.6; caret-color: var(--green); outline: 0; }
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-left: -10px; }
.attach { position: relative; flex: none; height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px 0 10px; border-radius: var(--pill); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.attach:hover { background: var(--green-soft); color: var(--green-deep); }
.attach:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 2px; }
.attach input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.attach svg.i { width: 18px; height: 18px; }
.file-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.file-pills[hidden] { display: none; }
.file-note { color: var(--muted); font-size: var(--fs-sm); padding: 0 4px; }
.file-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 12px; border-radius: var(--pill); background: var(--green-soft); color: var(--green-deep); font-size: var(--fs-sm); font-weight: 600; }
.file-pill > span { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pill svg.i { width: 16px; height: 16px; flex: none; }
.file-pill button { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; }
.file-pill button:hover { background: rgba(0, 0, 0, .06); }
.intake-foot .file-pills { margin-right: auto; }
.file-pill.reading { animation: reading 1.2s var(--ease) infinite alternate; }
@keyframes reading { from { opacity: 1; } to { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .file-pill.reading { animation: none; } }
.send { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background-color 150ms var(--ease); }
.send:hover { background: var(--green-deep); }
.send:disabled { background: #DCE2DF; cursor: not-allowed; }
.send svg.i { width: 19px; height: 19px; stroke-width: 2.2; transform: rotate(-90deg); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { position: relative; display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 8px 20px; border: 1px solid var(--line-strong); border-radius: var(--pill); background: #fff; text-decoration: none; cursor: pointer; line-height: 1.35; font-size: var(--fs-sm); font-weight: 600; transition: background-color 120ms var(--ease), border-color 120ms var(--ease); }
.chip:hover { border-color: var(--green); background: var(--green-soft); }
.chip input { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.chip:has(input:checked) { background: var(--green); border-color: var(--green); color: #fff; }
.chip:has(input:checked)::before { content: ""; width: 10px; height: 6px; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(-45deg) translateY(-2px); }
.chip:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- tell once: one box, then one review card ---------- */
.intake { width: 100%; max-width: 680px; display: grid; gap: var(--s3); }
.intake textarea { width: 100%; min-height: 168px; resize: vertical; padding: 16px 20px; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: #fff; line-height: 1.65; caret-color: var(--green); transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease); }
.intake textarea:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.intake textarea::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .85; }
.intake-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s2); }
.starters, .cands { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.starters > span, .cands > span { font-size: var(--fs-sm); color: var(--muted); }
.cand { min-height: 40px; padding: 6px 16px; border: 1px solid var(--green-line); border-radius: var(--pill); background: var(--green-soft); color: var(--green-ink); font-size: var(--fs-sm); font-weight: 600; text-align: left; cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
a.cand { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
a.cand svg.i { width: 16px; height: 16px; }
.cand:hover { background: #DDEEE5; border-color: var(--green); }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.examples > span { font-size: var(--fs-sm); color: var(--muted); }
.hero .examples { justify-content: center; margin: 4px 0 0; }
.said summary, .facts summary { list-style: none; cursor: pointer; }
.facts summary::-webkit-details-marker { display: none; }
.facts summary { font-weight: 600; }
.facts[open] .more-link { display: none; }
.said summary::-webkit-details-marker { display: none; }
.said[open] summary { display: none; }
.more-link { display: block; margin-top: 4px; font-size: var(--fs-sm); text-decoration: underline; text-underline-offset: 3px; opacity: .9; }
.pre { white-space: pre-line; }

/* draft-first: the press release being written sits beside the facts it is written from */
.thread.wide { max-width: 1240px; }
.review-wrap { width: 100%; display: grid; gap: var(--s5); }
.review-wrap.has-draft { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.draft-pane { position: sticky; top: var(--s4); display: grid; gap: var(--s3); }
.article.is-draft { background: #fff; }
.article.is-draft .letterhead div span { color: var(--gold); }
.gap { display: inline-block; padding: 0 8px; margin: 0 1px; border-radius: 6px; background: var(--gold-soft); border: 1px dashed var(--gold-bright);
  color: #6B4D10; font-family: var(--font); font-size: .85em; font-weight: 600; text-indent: 0; text-decoration: none; line-height: 1.6; }
.gap:hover { background: #F6E7C1; }
.gap { white-space: nowrap; }
/* a table field as a small spreadsheet: column names once, one quiet line per row; a narrow card stacks each row */
/* a news type built on a table (election areas, results): both tables need the full width, so the card comes first
   and the draft, still updating live, sits under it */

.rows-edit { container-type: inline-size; display: grid; gap: 6px; }
.rows-head, .row-card { display: grid; grid-template-columns: var(--cols); gap: 6px; align-items: center; }
.rows-head { padding: 0 0 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.rows-head span:first-child, .rows-head span:last-child { visibility: hidden; }
.row-n { font-size: var(--fs-xs); color: var(--muted); text-align: center; }
.cell { display: block; min-width: 0; }
.cell > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.field .row-card input[type=text], .field .row-card textarea.cell-wrap { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font-size: var(--fs-sm); text-overflow: ellipsis; }
/* a long name ("สมาชิกสภาองค์การบริหารส่วนตำบลท่าหมื่นราม เขตเลือกตั้งที่ 4") wraps to a second line instead of being cut */
.field .row-card textarea.cell-wrap { display: block; resize: none; overflow: hidden; font-family: inherit; line-height: 1.5; }
.field .row-card input[type=text]:focus, .field .row-card textarea.cell-wrap:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.row-del { width: 40px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
.row-del svg.i { width: 16px; height: 16px; }
.row-del:hover { background: var(--danger-soft); color: var(--danger); }
.add-row { justify-self: start; min-height: 44px; margin-top: 4px; }
.field.needs .row-card input[type=text], .field.needs .row-card textarea.cell-wrap { border-color: var(--gold-bright); background: #FFFDF7; }
/* narrow: each row a light card in three short lines, names shown over the boxes */
@container (max-width: 520px) {
  .rows-head { display: none; }
  .rows-edit { gap: var(--s2); }
  .row-card { position: relative; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 8px 10px; align-items: end;
    padding: 12px 44px 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--side); }
  .row-n { position: absolute; top: 10px; right: 46px; display: none; }
  .cell { display: grid; gap: 2px; }
  .cell > span { position: static; width: auto; height: auto; overflow: visible; clip: auto; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
  .cell-l { grid-column: 1 / -1; }
  .row-del { position: absolute; top: 6px; right: 4px; }
}
/* the review card is a working form, not a poster: compact boxes, tight rhythm, small choices */
.review .card-head { padding: 14px var(--s4) 4px; }
.review .card-head h2 { font-size: var(--fs); }
.review .card-body { gap: var(--s4); padding-top: var(--s3); }
.review .fields { gap: 14px; }
.review .field { gap: 4px; }
.review .field > label { font-size: var(--fs-sm); }
.review .hint, .review .cands > span { font-size: var(--fs-xs); }
.review .field input[type=text], .review .field textarea { min-height: 44px; padding: 9px 14px; border-radius: var(--r-sm); font-size: 16px; line-height: 1.5; }
.review .field textarea { min-height: 72px; }
.review .chips { gap: 6px; }
.review .chip { min-height: 44px; padding: 4px 14px; font-size: var(--fs-sm); }
.review .cand { min-height: 44px; padding: 4px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.review .tag { font-size: var(--fs-sm); padding: 0 8px; }
.review .ask { gap: var(--s2); padding: var(--s3) var(--s3) var(--s4); }
.review .ask h3 { font-size: var(--fs-sm); }
.review .ask .field textarea { min-height: 64px; }
.review .more > summary { min-height: 40px; font-size: var(--fs-sm); }
.review .card-foot { padding-top: 10px; padding-bottom: 10px; }
/* the question card can be taller than the pane: its buttons stay in view while the fields scroll under them */
.split .review { overflow: visible; }  /* a clipped card would hold the sticky foot inside itself */
.split .review .card-foot { position: sticky; bottom: calc(0px - var(--s6)); z-index: 2;  /* the pane's bottom padding counts as inset, so the foot hugs its edge */ border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: 0 -8px 16px -12px rgba(20, 30, 25, .25); }
@media (min-width: 861px) { .split .review .card-foot .btn-primary { display: none; } }  /* side by side: the one primary sits in the canvas bar */

.from { font-size: var(--fs-xs); font-weight: 400; color: var(--muted); margin-left: 4px; }
.from-link { font-size: var(--fs-xs); font-weight: 600; color: var(--green); margin-left: 6px; white-space: nowrap; }
.pick > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); font-size: var(--fs-sm); }
.pick > summary::-webkit-details-marker { display: none; }
.pick > summary b { flex: 1; font-weight: 600; }
.pick > summary span { font-size: var(--fs-xs); color: var(--green); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.pick[open] > summary { border-color: var(--green); }
.pick .chips { padding-top: 8px; }
.review .ask { background: none; padding: var(--s3) 0 0; border-top: 1px solid var(--line); border-radius: 0; }
.review .more > summary .opt { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

/* copilot: up to 3 skippable questions, and a plain list of what the draft changed */
.ask { display: grid; gap: var(--s3); padding: var(--s4) var(--s4) var(--s5); border-radius: var(--r); background: var(--side); }
.ask h3 { font-size: var(--fs); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s2); }
.ask .field input, .ask .field textarea { background: #fff; }
.ask .field textarea { min-height: 88px; }
.changes { padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.changes summary { cursor: pointer; font-weight: 600; color: var(--green-deep); min-height: 32px; }
.changes ul { margin: var(--s1) 0 0; padding-left: var(--s5); display: grid; gap: 2px; }
/* live draft: the sentence that just changed glows briefly so the eye finds it */
.article-body > .fresh { animation: settle 900ms ease-out; border-radius: 4px; }
@keyframes settle { from { background-color: #DDF0E5; } to { background-color: transparent; } }
.worth { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: var(--s3) var(--s5); border-top: 1px dashed var(--green-line); font-size: var(--fs-sm); color: var(--muted); }
.gap.soft { background: transparent; border-color: var(--green-line); color: var(--green); font-weight: 500; }
.gap.soft:hover { background: var(--green-soft); }

/* review card: found facts are quiet, filled inputs; what is missing or uncertain carries a gold tag */
.review { max-width: 760px; }
.has-draft .review { max-width: none; }
.has-draft .fields { grid-template-columns: minmax(0, 1fr); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 20px; }
.field.wide { grid-column: 1 / -1; }
.tag { display: inline-block; margin-left: 6px; padding: 0 10px; border-radius: var(--pill); background: var(--gold-soft); border: 1px solid var(--gold-line); color: #6B4D10; font-size: var(--fs-sm); font-weight: 700; vertical-align: 2px; }
.field.needs input, .field.needs textarea { border-color: var(--gold-bright); background: #FFFDF7; }
.more { border-top: 1px solid var(--line); padding-top: var(--s2); }
.more > summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; gap: var(--s2); list-style: none; font-weight: 600; color: var(--green-deep); }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: ""; width: 8px; height: 8px; border: solid var(--green); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform 150ms var(--ease); margin: 0 4px 0 2px; }
.more[open] > summary::before { transform: rotate(45deg); }
.more > .fields { padding: var(--s3) 0 var(--s2); }
.link { padding: 0; border: 0; background: none; color: var(--green); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
button.task, button.option { width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; }

/* ---------- cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; width: 100%; }
.card-head { padding: var(--s4) var(--s5) var(--s2); }
.card-head h2 { font-size: var(--fs-lg); }
.card-head.row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px var(--s4); }
.card-note { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.card-body { padding: var(--s5); display: grid; gap: var(--s5); }
.card-body > * { min-width: 0; }  /* a long note or name never widens the form past its pane */
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: #fff; }
.card-foot .spacer, .spacer { flex: 1; }
.price { font-size: var(--fs-sm); color: var(--muted); }

/* fields */
.field { display: grid; gap: var(--s2); border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { font-weight: 600; padding: 0; }
.opt { color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }
.hint { font-size: var(--fs-sm); color: var(--muted); white-space: pre-line; }
.err { font-size: var(--fs-sm); color: var(--danger); font-weight: 600; }
.input, .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=date], .field input[type=url], .field textarea, select.input {
  width: 100%; min-height: 52px; padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; caret-color: var(--green); transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease); }
.field input[type=text], .field input[type=url], .field input[type=date] { border-radius: var(--pill); padding: 12px 20px; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.input:focus, .field input:focus, .field textarea:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.invalid input, .invalid textarea, .invalid .chip { border-color: var(--danger); }
.field input[list]::-webkit-calendar-picker-indicator { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: 0 24px; border-radius: var(--pill); border: 1px solid transparent; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color 120ms var(--ease), border-color 120ms var(--ease); }
.btn svg.i { width: 18px; height: 18px; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--line-strong); cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--green); background: var(--green-soft); }
.btn-text { background: transparent; color: var(--muted); font-weight: 600; }
.btn-text:hover { color: var(--green-deep); background: var(--panel); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.actions .btn-text { border-color: var(--line-strong); background: #fff; color: var(--ink); }

/* notices: the left edge carries the meaning */
.notice { display: flex; gap: var(--s3); align-items: flex-start; width: 100%; font-size: var(--fs-sm); padding: 12px 16px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--line); }
.notice svg.i { margin-top: 2px; }
.notice.warn { background: var(--gold-soft); border-color: var(--gold-line); }
.notice.warn svg.i { color: var(--gold); }
.notice.lost { margin: 0 var(--s5) var(--s4); width: auto; }
.notice.lost p { margin: 4px 0 8px; color: var(--muted); }
.notice .check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; min-height: 36px; cursor: pointer; }
.notice.bad { background: var(--danger-soft); border-color: var(--danger-line); }
.notice.bad svg.i { color: var(--danger); }
.notice.good { background: var(--green-soft); border-color: var(--green-line); }
/* demo-mode remarks: say it once, quietly */
.note { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--muted); }
.note svg.i { width: 17px; height: 17px; }
.notice.good svg.i { color: var(--green); }
.notice ul { margin: var(--s1) 0 0; padding-left: var(--s5); }

/* progress */
.progress { width: min(100%, 560px); display: grid; gap: var(--s2); padding: 4px 0; }
.progress b { font-weight: 700; }
.bar { height: 4px; border-radius: 4px; background: var(--hover); overflow: hidden; position: relative; }
.bar::after { content: ""; position: absolute; inset: 0; width: 35%; background: var(--green); animation: slide 1.4s var(--ease) infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* ---------- results ---------- */
.article { border-color: var(--line); box-shadow: 0 1px 2px rgba(20, 30, 25, .04); }
.letterhead { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 2px solid var(--green); }
.letterhead img { width: 44px; height: 44px; flex: none; }
.letterhead div { flex: 1; min-width: 0; line-height: 1.35; }
.letterhead b { display: block; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.letterhead div span { font-size: var(--fs-xs); color: var(--green); font-weight: 700; }
.letterhead p { text-align: right; font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; }
.letterhead p span { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
.article-body { padding: var(--s5) var(--s5) var(--s3); }
.article h2 { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; line-height: 1.45; margin-bottom: var(--s4); color: var(--green-ink); }
.article p { margin-bottom: var(--s3); text-indent: 2em; line-height: 1.8; }
.table-wrap { overflow-x: auto; margin: var(--s2) 0 var(--s4); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { border: 1px solid var(--line); padding: var(--s2) var(--s3); text-align: left; vertical-align: top; }
th { background: var(--green-soft); font-weight: 700; color: var(--green-ink); }
.images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); width: 100%; }
.images figure { margin: 0; }
.images img { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: var(--r); }
.images figcaption { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s1); }
video { display: block; max-width: 100%; max-height: 70vh; background: #000; border-radius: 16px; }
.lyrics { padding: var(--s5); display: grid; gap: var(--s4); }
.lyrics h2 { font-family: var(--serif); font-size: var(--fs-xl); color: var(--green-ink); }
.lyrics h3 { font-size: var(--fs-sm); color: var(--green); }
.lyrics p { white-space: pre-line; }
.scene { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: var(--s3); }
.scene-n { width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; }

/* approval: gold = waits for a person, green = approved */
.approve { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); width: 100%; padding: 10px 10px 10px 22px; border-radius: var(--pill); background: var(--gold-soft); border: 1px solid var(--gold-line); }
.approve p { flex: 1; min-width: 220px; font-size: var(--fs-sm); font-weight: 600; color: #5E440F; }
.approve.done { background: var(--green-soft); border-color: var(--green-line); }
.approve.done p { color: var(--green-ink); display: flex; align-items: center; gap: var(--s2); }

/* ---------- plain pages (login, admin) ---------- */
.page { max-width: 960px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); display: grid; gap: var(--s6); }
.page h1 { font-size: 30px; }
.page > section > h2 { font-size: var(--fs-lg); margin-bottom: var(--s3); }
.stats { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pill { display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3); border: 1px solid var(--line); background: #fff; font-size: var(--fs-sm); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--s3); align-items: end; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); background: var(--side); }
.login .card { max-width: 420px; box-shadow: 0 12px 32px -20px rgba(20, 30, 25, .3); }
.login .card-head { padding: var(--s5) var(--s5) 0; }
.login-brand { display: flex; align-items: center; gap: var(--s3); font-weight: 700; line-height: 1.35; }
.login-brand img { width: 56px; height: 56px; }
.login .btn-primary { width: 100%; }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .review-wrap.has-draft { grid-template-columns: minmax(0, 1fr); }
  .draft-pane { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 320px); z-index: 20; transform: translateX(-100%); transition: transform 180ms var(--ease); }
  .shell.nav-open .sidebar { transform: none; }
  .nav-close { display: inline-grid; margin-left: auto; }
  .sb-toggle { display: none; }
  .sb-resize { display: none; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 15; background: var(--scrim); }
  .topbar { padding: var(--s1) var(--s2) var(--s1) var(--s1); min-height: 56px; gap: var(--s2); border-bottom: 1px solid var(--line); }
  .topbar .icon-btn { display: inline-grid; }
  .topbar .icon-btn { color: var(--ink); }
  .hero { padding: var(--s5) 16px 8vh; gap: var(--s4); }
  .hero h1 { font-size: 22px; }
  .hero-logo { width: 48px; height: 48px; }
  .thread { padding: var(--s5) 14px var(--s6); }
  .msg-ai { grid-template-columns: 28px minmax(0, 1fr); gap: var(--s2); }
  .msg-ai > .avatar { width: 28px; height: 28px; }
  .fields { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .article .table-wrap table { min-width: 560px; }
  .split { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .split[data-view="chat"] > .canvas-pane, .split[data-view="canvas"] > .chat-pane { display: none; }
  .view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 8px 12px; padding: 4px; border-radius: var(--pill); background: var(--hover); }
  .view-switch button { min-height: 40px; border: 0; border-radius: var(--pill); background: transparent; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); cursor: pointer; }
  .view-switch button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20, 30, 25, .15); }
  .split > .chat-pane { padding: var(--s3) 14px var(--s6); border-right: 0; }
  .canvas-bar { padding: 6px 12px; min-height: 52px; }
  .canvas-meta { display: none; }
  .canvas-bar b { white-space: nowrap; }
  .canvas-bar .btn { padding: 0 14px; }
  .canvas-doc { padding: var(--s3) 10px var(--s6); }
  .suggest { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* scroll a wide table sideways instead of crushing it to one word per line */
  .review-wrap.has-draft { grid-template-columns: minmax(0, 1fr); }
  .draft-pane { position: static; }
  .intake-foot { justify-content: stretch; }
  .intake-foot .btn { flex: 1; }
  .bubble dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .bubble dd { margin-bottom: 6px; }
  .actions { flex-wrap: nowrap; }
  .actions > *, .actions form .btn { flex: 1; min-width: 0; }
  .actions .btn { padding: 0 12px; font-size: var(--fs-sm); }
  .bubble { max-width: 90%; }
  .tasks, .options, .images { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .task, .option { padding: 14px 58px 14px 14px; }
  .task::after, .option::after { right: 14px; }
  .thread { gap: var(--s4); }
  .dock { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .composer { padding-left: 18px; }
  .composer textarea { font-size: 16px; }
  .card-head, .card-body, .article-body, .lyrics, .letterhead { padding-left: var(--s4); padding-right: var(--s4); }
  .article h2 { font-size: 21px; }
  .approve { border-radius: 16px; }
  .approve .btn { flex: 1; }
}
@media (max-width: 420px) {
  .letterhead p { display: none; }
  .channels { margin-top: var(--s3); }
  .channels button { padding: 0 12px; min-height: 44px; font-size: var(--fs-xs); }
  .post { padding: var(--s3) var(--s3) var(--s2); }
}
@media (max-width: 360px) {  /* status on its own line so copy and approve both stay on screen */
  .brand { font-size: var(--fs-sm); gap: var(--s2); }
  .brand img { width: 32px; height: 32px; }
  .canvas-bar { flex-wrap: wrap; row-gap: 6px; }
  .canvas-bar b { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .bar::after { width: 100%; opacity: .35; }
}

form.inline { display: inline; }

/* Election calendar (admin), in the manner of a calendar printed with an official letter: black on white, hairline
 * rules, words instead of colour. The only colour is the ECT green of links and the current day's numeral. */
#calendar { padding: var(--s5); display: grid; gap: var(--s4); overflow: visible; }
.cal-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3); }
.cal-head h2 { font-size: var(--fs-lg); }
.cal-nav { display: flex; align-items: baseline; gap: var(--s5); font-size: var(--fs-sm); }
.cal-nav a, .cal-today { color: var(--muted); text-decoration: none; }
.cal-nav a:hover, .cal-today:hover { color: var(--green-deep); text-decoration: underline; text-underline-offset: 3px; }
.cal-month { font-size: var(--fs-lg); font-weight: 700; color: var(--ink); }
.cal-today { justify-self: end; font-size: var(--fs-sm); }
.cal-table { width: 100%; table-layout: fixed; border-collapse: collapse; border: 1px solid var(--ink); }
.cal-table th { padding: 6px 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink); text-align: center;
  border: 1px solid var(--ink); background: #fff; }
.cal-table td { position: relative; height: 96px; padding: 4px 6px 6px; vertical-align: top; border: 1px solid #9AA39F; }
.cal-table td.out .cal-num { color: #B4BBB8; }
.cal-num { display: block; text-align: right; color: var(--ink); text-decoration: none; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.cal-num:hover { text-decoration: underline; text-underline-offset: 3px; }
.cal-table td.today .cal-num { color: var(--green-deep); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.cal-ev > summary { list-style: none; cursor: pointer; display: grid; margin-top: 2px; line-height: 1.35; }
.cal-ev > summary::-webkit-details-marker { display: none; }
.cal-ev-kind { font-size: 11px; color: var(--muted); }
.cal-ev-name { font-size: var(--fs-xs); font-weight: 700; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; max-height: 2.7em; }
.cal-ev > summary:hover .cal-ev-name { text-decoration: underline; text-underline-offset: 3px; }
.cal-win { display: block; margin-top: 3px; padding-top: 1px; border-top: 1px solid var(--ink); font-size: 11px; color: var(--muted);
  line-height: 1.3; min-height: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pop { position: absolute; z-index: 5; top: calc(100% - 4px); left: -1px; width: 260px; padding: var(--s3) var(--s4); background: #fff;
  border: 1px solid var(--ink); box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .25); display: grid; gap: 4px; }
.cal-table td:nth-child(7) .cal-pop, .cal-table td:nth-child(6) .cal-pop { left: auto; right: -1px; }
.cal-pop-name { font-weight: 700; }
.cal-pop-meta { font-size: var(--fs-sm); color: var(--muted); }
.cal-pop-meta a, .cal-notes a { color: var(--green-deep); text-underline-offset: 3px; }
.cal-pop-act { display: flex; gap: var(--s4); margin-top: 4px; }
.cal-link { border: 0; background: none; padding: 0; font: inherit; font-size: var(--fs-sm); color: var(--muted); text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; }
.cal-link.strong { color: var(--green-deep); font-weight: 700; }
.cal-link:hover { color: var(--ink); }
.cal-notes { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--s4); font-size: var(--fs-sm); margin: 0; }
.cal-notes dt { font-weight: 700; color: var(--ink); }
.cal-notes dd { margin: 0; color: var(--muted); }
.cal-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr); gap: var(--s3) var(--s4);
  padding: var(--s4); border: 1px solid var(--line-strong); background: #fff; }
.cal-form-title { grid-column: 1 / -1; font-weight: 700; }
.cal-form-foot { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: var(--s2); }
.cal-form select.input { border-radius: var(--pill); padding: 12px 20px; }
.cal-short { display: none; }
@media (max-width: 640px) {
  #calendar { padding: var(--s4) var(--s3); }
  .cal-word { display: none; }
  .cal-short { display: inline; }
  .cal-nav a { font-size: var(--fs-lg); padding: 0 var(--s3); }
  .cal-head { grid-template-columns: 1fr auto; }
  .cal-nav { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .cal-table th { font-size: 10px; padding: 4px 0; }
  .cal-table td { height: 64px; padding: 2px 3px; }
  .cal-ev-kind { display: none; }
  .cal-ev-name { font-size: 10px; -webkit-line-clamp: 2; }
  .cal-win { font-size: 0; }
  .cal-pop { position: fixed; left: var(--s4); right: var(--s4); top: auto; bottom: var(--s4); width: auto; }
  .cal-notes { grid-template-columns: minmax(0, 1fr); }
  .cal-form { grid-template-columns: minmax(0, 1fr); }
}
#calendar > * { min-width: 0; }
/* picture tab: pick a template and places, check the words, make the pictures */
.pgroup { border: 0; padding: 0; margin: 0; min-width: 0; }
.pgroup legend { font-size: var(--fs-sm); font-weight: 700; margin-bottom: var(--s2); }
.pills { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.pill-opt { position: relative; display: block; cursor: pointer; }
.pill-opt input { position: absolute; opacity: 0; }
.pill-opt span { display: grid; gap: 2px; height: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.pill-opt b { font-size: var(--fs-sm); }
.pill-opt small { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }
.pill-opt input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 1px var(--green); }
.pill-opt input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.pfields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px 14px; }
.pf { display: grid; gap: 4px; min-width: 0; font-size: var(--fs-xs); color: var(--muted); }
.pf.wide { grid-column: 1 / -1; }
.pf input:not([type=file]), .pf textarea { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); font: inherit; font-size: var(--fs-sm); color: var(--ink); background: #fff; }
.pf input:focus, .pf textarea:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.pf input[type=file] { font-size: var(--fs-xs); max-width: 100%; }
.prow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pthumb { width: 120px; max-width: 100%; border-radius: var(--r-sm); border: 1px solid var(--line); }
.pactions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.pactions small { font-weight: 400; color: var(--muted); margin-left: 4px; }
/* picture tab: the pictures first, every choice folded away */
.pstart { display: grid; gap: var(--s3); justify-items: start; padding: var(--s5); border-radius: var(--r-lg); background: var(--green-soft); }
.pstart p { margin: 0; font-size: var(--fs-sm); }
.pstart small, .prow small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--green-deep); text-decoration: underline; cursor: pointer; }
.post-pic { margin: var(--s3) calc(-1 * var(--s4)) 0; display: grid; gap: 6px; }
.post-pic img { width: 100%; display: block; border-block: 1px solid var(--line); background: #fff; }
.post-pic a { justify-self: start; margin-left: var(--s4); display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--green-deep); }
.psource { margin: 0; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psource a { color: var(--green-deep); font-weight: 600; }
form.inline { display: inline; }

/* ---------- the picture studio: one picture with channel tabs; the edit panel beside it on a wide pane, a sheet on a phone ---------- */
.canvas-pane { container-type: inline-size; }
.studio-wrap { max-width: 1120px; display: grid; gap: var(--s4); }
.studio { display: grid; gap: var(--s5); grid-template-areas: "stage"; }
.stage { grid-area: stage; display: grid; gap: var(--s4); justify-items: center; align-content: start; min-width: 0; }
.chtabs { display: flex; gap: 2px; max-width: 100%; padding: 4px; border-radius: var(--pill); background: var(--hover); overflow-x: auto; scrollbar-width: none; }
.chtabs::-webkit-scrollbar { display: none; }
.chtabs button { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 38px; padding: 0 14px; border: 0; border-radius: var(--pill); background: transparent;
  font: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); cursor: pointer; transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.chtabs button svg.i { width: 17px; height: 17px; }
.chtabs button:hover { color: var(--ink); }
.chtabs button[aria-selected="true"] { background: #fff; color: var(--green-deep); box-shadow: 0 1px 3px rgba(20, 30, 25, .14); }
.chtabs button:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
@media (max-width: 420px) { .chtabs button { min-height: 44px; } }  /* a thumb-sized tab on a phone */
.frame[hidden] { display: none; }
.frame { position: relative; margin: 0; width: 100%; max-width: 480px; display: grid; gap: var(--s2); justify-items: center; }
.frame.story { max-width: 300px; }
.frame.fb45 { max-width: 400px; }
.frame.web, .frame.x { max-width: 600px; }
.frame img { width: 100%; height: auto; display: block; border-radius: var(--r); background: #fff; box-shadow: 0 1px 3px rgba(20, 30, 25, .08), 0 18px 40px -22px rgba(16, 86, 58, .35); }
.frame .stamp { position: absolute; top: 12px; right: 12px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px 4px 8px; border-radius: var(--pill);
  background: var(--gold-bright); color: #2E2208; font-size: var(--fs-xs); font-weight: 700; box-shadow: 0 2px 8px -2px rgba(80, 60, 10, .4); }
.frame .stamp svg.i { width: 15px; height: 15px; stroke-width: 2.4; }
.frame figcaption { font-size: var(--fs-xs); color: var(--muted); }
.frame figcaption small { font-variant-numeric: tabular-nums; }
.stage-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.stage-actions em { font-style: normal; }
.stage-actions form { display: contents; }
.stage-note, .doc-hint { font-size: var(--fs-xs); color: var(--muted); text-align: center; }
.doc-hint { margin: var(--s3) var(--s4) 0; }
@media (hover: hover) { .doc-hint { display: none; } }
.btn-quiet { background: none; border-color: transparent; color: var(--green-deep); }
.btn-quiet:hover { background: var(--green-soft); }
/* one soft place to put a photo: a dashed pill, the cost said on it (never a native file field) */
.drop { position: relative; display: flex; align-items: center; gap: 10px; width: min(100%, 520px); margin: 0 auto; padding: 12px 18px; border: 1.5px dashed var(--line-strong); border-radius: var(--pill); background: #fff; color: var(--ink); cursor: pointer; text-align: left; }
.drop:hover, .drop:focus-within { border-color: var(--green); background: var(--green-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop svg.i { width: 20px; height: 20px; flex: none; color: var(--green-deep); }
.drop .t { display: grid; gap: 2px; min-width: 0; }
.drop b { font-size: var(--fs-sm); }
.drop small { font-size: var(--fs-xs); color: var(--muted); }
.drop .pthumb { width: 56px; height: 56px; object-fit: cover; border-radius: 50%; flex: none; }
.drop.small { width: 100%; margin: 0; padding: 10px 14px; }
.plinks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; font-size: var(--fs-sm); }
.plinks small { font-weight: 400; color: var(--muted); }
@media (max-width: 420px) { .stage-actions > *, .stage-actions .btn { width: 100%; } }
.stage .psource { max-width: 100%; text-align: center; white-space: normal; }
.studio.empty .stage { justify-items: stretch; }
/* the edit panel */
.studio-edit { grid-area: edit; display: grid; gap: var(--s5); align-content: start; min-width: 0; }
.studio-edit > * { min-width: 0; }
.edit-head { display: flex; align-items: center; justify-content: space-between; }
.edit-head b { font-size: var(--fs); }
.edit-head .icon-btn { display: none; }
.edit-label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); margin-bottom: var(--s2); }
.tpl-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; scroll-snap-type: x proximity; }
.tpl { position: relative; flex: none; width: 108px; display: grid; gap: 6px; justify-items: center; cursor: pointer; scroll-snap-align: start; }
.tpl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tpl img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: var(--r-sm); border: 2px solid transparent; background: var(--panel); transition: border-color 120ms var(--ease), transform 150ms var(--ease); }
.tpl span { font-size: var(--fs-xs); color: var(--muted); text-align: center; line-height: 1.3; }
.tpl:hover img { transform: translateY(-2px); }
.tpl input:checked + img { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.tpl input:checked ~ span { color: var(--green-deep); font-weight: 700; }
.tpl input:focus-visible + img { outline: 2px solid var(--green); outline-offset: 2px; }
.studio-edit .pfields { grid-template-columns: minmax(0, 1fr); }
.studio-edit .pactions { justify-content: flex-start; }
.sheet-scrim { display: none; }
/* narrow pane (a phone, or the chat beside it on a laptop): the picture first, the edit panel slides up as a sheet */
.studio-edit { display: none; }
.studio.editing .studio-edit { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: min(84vh, 84dvh); overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s3) max(16px, env(safe-area-inset-left, 0px)) max(var(--s5), env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-right, 0px));
  border-radius: 20px 20px 0 0; background: #fff; box-shadow: 0 -12px 40px -16px rgba(16, 40, 30, .45); animation: sheet-up 220ms var(--ease); }
.studio.editing .edit-head { position: sticky; top: calc(var(--s3) * -1); margin-top: calc(var(--s3) * -1); padding: var(--s3) 0 var(--s2); background: #fff; z-index: 1; }
.studio.editing .edit-head .icon-btn { display: inline-grid; }
.studio.editing .sheet-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
body.sheet-open { overflow: hidden; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 700px) {
  .studio.editing .studio-edit { left: auto; top: 0; bottom: 0; width: min(440px, 92vw); max-height: none; border-radius: 20px 0 0 20px;
    padding: var(--s4) var(--s5) max(var(--s5), env(safe-area-inset-bottom, 0px)); box-shadow: -12px 0 40px -16px rgba(16, 40, 30, .45); animation: drawer-in 220ms var(--ease); }
  .studio.editing .edit-head { top: calc(var(--s4) * -1); margin-top: calc(var(--s4) * -1); padding-top: var(--s4); }
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .studio.editing .studio-edit { animation: none !important; } .tpl:hover img { transform: none; } }
/* wide pane: the panel stands beside the picture, always open, no sheet */
@container (min-width: 1000px) {
  .studio { grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: "edit stage"; gap: var(--s6); }
  .studio.empty { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage"; }
  .studio.empty .studio-edit { display: none; }
  .studio-edit, .studio.editing .studio-edit { display: grid; position: static; max-height: none; padding: 0; border-radius: 0; background: transparent; box-shadow: none; animation: none; }
  .studio.editing .edit-head { position: static; margin: 0; padding: 0; }
  .studio.editing .edit-head .icon-btn, .edit-open, .studio.editing .sheet-scrim { display: none; }
  .tpl-row { flex-wrap: wrap; overflow: visible; padding: 0; }
  .tpl { width: calc(50% - 5px); }
}
.btn.upload { position: relative; overflow: hidden; }
.btn.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.btn.upload:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.studio-edit .hint { font-size: var(--fs-xs); color: var(--muted); }
