/* Pinkit Forms lab. Order: colors and scales, base, side bar, top bar, empty page,
   composer and + menu, chat, form preview, dialogs, narrow screens. */

/* ---------- colors and scales ---------- */
:root {
  /* one neutral gray family; pink is only for the main action and the form */
  --bg: #ffffff;
  --side-bg: #f9f9f9;
  --surface: #ffffff;
  --sunken: #f1f1f2;
  --canvas: #f3f3f4;
  --text: #1f1f22;
  --text-muted: #67676d;
  --border: #e6e6e8;
  --border-strong: #d2d2d6;
  /* same magenta hue as the app icon, darkened so white text on it stays readable */
  --accent: #c2259c;
  --accent-hover: #a51d84;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6f6;
  --bubble: #f1f1f2;
  --danger: #b42318;
  --danger-solid: #c62828; /* filled buttons (delete) */
  --shadow: 0 1px 2px rgba(24, 24, 28, .05), 0 2px 12px rgba(24, 24, 28, .05);
  --shadow-strong: 0 1px 2px rgba(24, 24, 28, .06), 0 6px 22px rgba(24, 24, 28, .09);
  --card-shadow: 0 1px 2px rgba(24, 24, 28, .05), 0 1px 6px rgba(24, 24, 28, .04);
  --pop-shadow: 0 8px 30px rgba(24, 24, 28, .14);
  --backdrop: rgba(16, 16, 20, .45);

  /* type scale: small labels, secondary text, body */
  --fs-xs: 12.5px;
  --fs-sm: 14px;
  --fs-md: 15px;
  /* corner scale: inner items, cards, containers */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --radius: var(--r-md);

  --ease: 150ms ease;
  color-scheme: light;
}
/* dark mode: neutral grays (not tinted), only the accent stays pink */
:root[data-theme="dark"] {
  --bg: #131314;
  --side-bg: #1b1c1d;
  --surface: #1e1f20;
  --sunken: #282a2c;
  --canvas: #131314;
  --text: #e8eaed;
  --text-muted: #a8abb0;
  --border: #303134;
  --border-strong: #44474a;
  --accent: #f07ad6;
  --accent-hover: #f59be2;
  --accent-ink: #1a0a16;
  --accent-soft: rgba(240, 122, 214, .14);
  --bubble: #282a2c;
  --danger: #f28b82;
  --danger-solid: #d93025;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-strong: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 22px rgba(0, 0, 0, .4);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --pop-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --backdrop: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.55 'Heebo', 'Segoe UI', Arial, sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* every button eases its hover and gives a small press */
button, a, .composer {
  transition: background-color var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease), transform 100ms ease;
}
.icon-btn:active:not(:disabled), .send:active:not(:disabled), .btn:active:not(:disabled),
.upgrade-pill:active, .top-upgrade:active, .ghost-btn:active:not(:disabled) { transform: scale(.96); }

.app { display: flex; height: 100dvh; overflow: hidden; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--text-muted);
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }

.btn {
  border: 0; border-radius: var(--r-sm); padding: 9px 20px; cursor: pointer; font-weight: 500;
  background: var(--accent); color: var(--accent-ink);
}
/* Hover colours only where there is a real pointer: on touch screens a tap
   would otherwise leave the button stuck in its hover colour. */
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--accent-hover); }
}
.btn:disabled { cursor: not-allowed; }
/* a disabled main button turns gray (a faded pink looked muddy, mostly in dark mode) */
.btn:not(.ghost):disabled { background: var(--sunken); color: var(--text-muted); }
.btn.ghost:disabled { opacity: .6; }
.btn.ghost { background: none; color: var(--text-muted); border: 1px solid var(--border-strong); }
/* White buttons stay white on hover and after a tap on phones (no pink behind grey text). */
@media (hover: hover) {
  .btn.ghost:hover:not(:disabled) { background: var(--sunken); color: var(--text); }
}

/* two-option switch (theme, language) */
.lang, .theme { display: flex; gap: 4px; background: var(--sunken); padding: 3px; border-radius: var(--r-sm); }
.lang button, .theme button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: none; padding: 5px 8px; border-radius: calc(var(--r-sm) - 3px); cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-muted);
}
.lang button:hover, .theme button:hover { color: var(--text); }
.lang button[aria-pressed="true"], .theme button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.theme svg { width: 15px; height: 15px; }

/* pop-up menu panels (+ menu, user menu) */
.plus-menu, .user-menu {
  position: absolute; z-index: 15;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--pop-shadow);
}
.plus-menu [role="menuitem"], .user-menu [role="menuitem"] {
  display: flex; align-items: center; width: 100%;
  border: 0; background: none; border-radius: var(--r-sm); padding: 9px 10px;
  text-align: start; cursor: pointer; color: var(--text); text-decoration: none;
}
.plus-menu [role="menuitem"]:hover, .plus-menu [role="menuitem"]:focus-visible,
.user-menu [role="menuitem"]:hover:not(:disabled), .user-menu [role="menuitem"]:focus-visible { background: var(--sunken); outline: 0; }
.plus-menu hr, .user-menu hr { border: 0; border-top: 1px solid var(--border); }

/* small neutral tags (Lab, Soon, test mode) */
.badge, .soon, .mock-flag {
  font-size: var(--fs-xs); font-weight: 500; font-style: normal; line-height: 1.5;
  color: var(--text-muted); background: var(--sunken);
  padding: 1px 7px; border-radius: 6px;
}

/* ---------- side bar ---------- */
.side {
  width: 260px; flex: none;
  background: var(--side-bg);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 10px;
  gap: 4px;
}
.side-collapsed .side { display: none; }
.scrim { display: none; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-weight: 600; }
.brand img { border-radius: 8px; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  border: 0; background: none; border-radius: var(--r-sm);
  text-align: start; cursor: pointer; color: var(--text);
}
.side-item:hover { background: var(--sunken); }
.side-item.primary { font-weight: 500; }
.side-label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); padding: 18px 10px 6px; }
.side-empty { margin: 0; padding: 2px 10px; font-size: var(--fs-sm); color: var(--text-muted); }
.side-foot { margin-top: auto; padding: 10px 2px 0; position: relative; display: flex; flex-direction: column; gap: 10px; }
.note { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); text-wrap: pretty; }

/* user row at the bottom */
.user-row { display: flex; align-items: center; gap: 6px; padding: 6px 2px 2px; border-top: 1px solid var(--border); }
.user-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  border: 0; background: none; padding: 6px; border-radius: var(--r-md); cursor: pointer; text-align: start;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--sunken); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: var(--fs-xs); letter-spacing: .02em;
}
.um-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.um-who b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-who small { font-size: var(--fs-xs); color: var(--text-muted); }
.upgrade-pill {
  flex: none; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; padding: 5px 12px; font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
}
.upgrade-pill:hover { border-color: var(--accent); color: var(--accent); }

/* user menu (opens upwards from the user row) */
.user-menu { bottom: 58px; inset-inline: 2px; padding: 6px; }
.user-menu [role="menuitem"] { gap: 12px; font-size: var(--fs-sm); }
.user-menu [role="menuitem"]:disabled { cursor: default; color: var(--text-muted); }
.user-menu hr { margin: 4px 8px; }
.user-menu .um-head .um-who { flex: 1; }
.user-menu .chev { width: 16px; height: 16px; color: var(--text-muted); }
[dir="rtl"] .user-menu .chev { transform: scaleX(-1); }
.soon { margin-inline-start: auto; }

/* ---------- main area and top bar ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; container: main / inline-size; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 52px; }
.icon-btn.menu-btn { display: none; }
.side-collapsed .icon-btn.menu-btn { display: inline-grid; }
.tabs { display: none; }
.mock-flag { margin-inline-start: auto; padding: 3px 10px; }
/* the side bar already has an Upgrade button; this one shows only when the side bar is hidden */
.top-upgrade {
  display: none; align-items: center; gap: 6px;
  border: 0; background: none; color: var(--accent); font-weight: 600; font-size: var(--fs-sm);
  padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer;
}
.side-collapsed .top-upgrade { display: inline-flex; }
.top-upgrade:hover { background: var(--accent-soft); }
.top-upgrade svg { width: 17px; height: 17px; fill: currentColor; stroke-width: 1.2; }
.mock-flag:not([hidden]) + .top-upgrade { margin-inline-start: 4px; }
.mock-flag[hidden] + .top-upgrade { margin-inline-start: auto; }

.workspace { flex: 1; min-height: 0; display: flex; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.preview { display: none; }

/* ---------- empty page ---------- */
.opening-form .hero { visibility: hidden; }
.hero {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 16px 12vh; gap: 24px;
}
.hero h1 {
  margin: 0; font-size: clamp(24px, 3.2vw, 32px); font-weight: 600; line-height: 1.2;
  text-align: center; letter-spacing: -.02em; text-wrap: balance;
}
.composer-slot { width: 100%; max-width: 760px; }
.chips { display: flex; flex-direction: column; gap: 2px; width: 100%; max-width: 760px; padding-inline: 8px; }
.chip {
  display: flex; align-items: center; gap: 12px;
  border: 0; background: none; padding: 10px 8px; border-radius: var(--r-sm);
  color: var(--text-muted); cursor: pointer; text-align: start;
}
.chip:hover { background: var(--sunken); color: var(--text); }

/* ---------- composer ---------- */
.composer {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 8px;
}
.composer:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow-strong); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea {
  flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: none;
  padding: 7px 4px; max-height: 200px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--text-muted); }
.attach { border-radius: 50%; }
.attach .i-close { display: none; }
.attach.open { background: var(--sunken); color: var(--text); }
.attach.open .i-plus { display: none; }
.attach.open .i-close { display: block; }
.send {
  width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { background: var(--sunken); color: var(--text-muted); cursor: default; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  margin: 2px 4px 6px; padding: 6px 6px 6px 10px; border-radius: var(--r-md);
  background: var(--sunken); font-size: var(--fs-sm);
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { border: 0; background: none; cursor: pointer; color: var(--text-muted); display: grid; padding: 2px; border-radius: calc(var(--r-sm) - 4px); }
.file-chip button:hover { color: var(--text); }
.file-chip svg { width: 16px; height: 16px; }

/* + menu (below the composer on the empty page, above it under the chat) */
.plus-menu {
  top: calc(100% + 8px); inset-inline-start: 0;
  width: min(320px, calc(100vw - 32px));
  padding: 8px;
}
.dock .plus-menu { top: auto; bottom: calc(100% + 8px); }
.plus-menu [role="menuitem"] { gap: 14px; }
.plus-menu span { display: flex; flex-direction: column; min-width: 0; }
.plus-menu b { font-weight: 500; }
.plus-menu small { font-size: var(--fs-xs); color: var(--text-muted); }
.plus-menu hr { margin: 6px 10px; }

/* ---------- chat ---------- */
.thread { display: none; flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.dock { display: none; padding: 0 16px 16px; }
.msg { max-width: 720px; margin: 0 auto 18px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty; }
.msg.user .bubble { background: var(--bubble); padding: 9px 15px; border-radius: var(--r-lg); max-width: 85%; }
.msg.assistant .bubble { padding: 2px; max-width: 100%; }
.msg.error .bubble { color: var(--danger); }
.msg .file-tag { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 2px; }
.typing { display: inline-flex; align-items: center; gap: 10px; color: var(--text-muted); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); opacity: .3; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 40% { opacity: 1; } }

/* after the first message: chat and preview side by side */
.started .hero { display: none; }
.started .thread, .started .dock { display: block; }
.started .chat { flex: 0 0 clamp(340px, 38%, 480px); border-inline-end: 1px solid var(--border); }
.started .preview { display: flex; flex-direction: column; flex: 1; min-width: 0; background: var(--canvas); container: preview / inline-size; }
.started .msg { max-width: none; }

/* ---------- form preview ---------- */
.preview-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; min-height: 52px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.preview-title { font-weight: 600; }
.version { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: var(--fs-sm);
}
.ghost-btn:hover:not(:disabled) { background: var(--sunken); }
.ghost-btn svg { width: 16px; height: 16px; }
.view-toggle { display: inline-flex; gap: 2px; background: var(--sunken); padding: 3px; border-radius: var(--r-sm); }
.view-toggle button { border: 0; background: none; padding: 4px 12px; border-radius: calc(var(--r-sm) - 3px); cursor: pointer; color: var(--text-muted); font-size: var(--fs-sm); }
.view-toggle button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.count-badge { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.count-badge:empty { display: none; }

.responses-view { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.resp-head { display: flex; align-items: center; gap: 10px; }
.resp-total { font-weight: 600; margin-inline-end: auto; }
.btn.ghost.resp-csv { text-decoration: none; padding: 5px 14px; font-size: var(--fs-sm); color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.resp-csv svg { width: 16px; height: 16px; }
.resp-ask { display: flex; gap: 8px; }
.resp-ask input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.resp-ask input:focus { outline: 0; border-color: var(--accent); }
/* Chat about the responses: its own small thread, separate from the form builder. */
.resp-chat { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; }
.resp-chat-head { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); }
.resp-chat-head .link-btn { font-size: var(--fs-xs); }
.resp-thread { display: flex; flex-direction: column; gap: 8px; max-height: min(320px, 45vh); overflow-y: auto; }
.resp-thread:empty { display: none; }
.resp-msg { max-width: 90%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; line-height: 1.55; font-size: var(--fs-sm); }
.resp-msg.user { align-self: flex-end; background: var(--bubble); }
.resp-msg.ai { align-self: flex-start; background: var(--canvas); border: 1px solid var(--border); }
.resp-msg.error { color: var(--danger); }
.resp-msg.waiting { color: var(--text-muted); font-style: italic; }
.resp-msg .resp-msg-label { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 4px; font-style: normal; }
.resp-empty { color: var(--text-muted); margin: 8px 0; }
.resp-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.resp-table-wrap:has(table:empty) { display: none; }
.resp-table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: var(--fs-sm); }
.resp-table th, .resp-table td { padding: 8px 12px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--border); max-width: 320px; overflow-wrap: anywhere; white-space: normal; }
/* Every row stays one or two lines high; a long answer opens on tap. */
.resp-table .cell-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-width: 320px; }
.resp-table td.long { cursor: pointer; }
.resp-table td.long.open .cell-text { display: block; -webkit-line-clamp: unset; white-space: pre-wrap; }
.resp-table thead th { position: sticky; top: 0; background: var(--sunken); font-weight: 500; white-space: normal; min-width: 120px; }
.resp-table th.deleted { color: var(--text-muted); font-style: italic; }
.resp-table td.when { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.resp-table tbody tr:last-child td { border-bottom: 0; }
.resp-pages { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: var(--fs-sm); color: var(--text-muted); }
.resp-pages:empty { display: none; }

/* Report: how the answers are spread, per question. One series per chart,
   so one hue (the brand accent) and no legend; numbers in text colours. */
.report-view { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
/* Items keep their size and the view scrolls (they must not squeeze together). */
.report-view > *, .responses-view > * { flex-shrink: 0; }
.rep-head { display: flex; align-items: center; gap: 10px; }
.rep-list { display: flex; flex-direction: column; gap: 12px; }
.rep-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; }
.rep-card h3 { margin: 0 0 2px; font-size: var(--fs-md); font-weight: 600; }
.rep-sub { margin: 0 0 12px; font-size: var(--fs-xs); color: var(--text-muted); }
.rep-avg { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; }
.rep-avg b { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rep-avg span { color: var(--text-muted); font-size: var(--fs-sm); }
.rep-bar { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; align-items: center; gap: 10px; padding: 3px 0; font-size: var(--fs-sm); }
.rep-bar-label { overflow-wrap: anywhere; }
.rep-bar-label.other { color: var(--text-muted); font-style: italic; }
.rep-track { height: 10px; background: var(--sunken); border-radius: 4px; overflow: hidden; }
.rep-fill { height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.rep-fill.zero { min-width: 0; }
.rep-value { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 64px; text-align: end; }
.rep-value b { color: var(--text); font-weight: 600; }
.rep-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rep-tile { background: var(--sunken); border-radius: var(--r-sm); padding: 8px 10px; }
.rep-tile small { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
.rep-tile b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rep-tile b.small { font-size: 15px; }
.rep-matrix-wrap { overflow-x: auto; }
.rep-matrix { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.rep-matrix th, .rep-matrix td { padding: 6px 8px; text-align: center; border: 2px solid var(--surface); }
.rep-matrix thead th { font-weight: 500; font-size: var(--fs-xs); color: var(--text-muted); }
.rep-matrix tbody th { text-align: start; font-weight: 400; }
.rep-matrix td { font-variant-numeric: tabular-nums; border-radius: 4px;
  background: color-mix(in srgb, var(--accent) calc(var(--p, 0) * .55%), var(--sunken)); }
.rep-analyze { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rep-analyze .btn { padding: 6px 14px; font-size: var(--fs-sm); }
.rep-analyze-note { font-size: var(--fs-xs); color: var(--text-muted); }
.rep-note { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.rep-label { margin: 10px 0 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
/* Tone: a diverging scale (positive, neutral grey, negative), labelled with text. */
.rep-tone { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); }
.rep-tone span { display: block; min-width: 0; }
.rep-tone .pos, .rep-tone-legend .pos { background: #1f9d75; }
.rep-tone .neu, .rep-tone-legend .neu { background: #a3a3ad; }
.rep-tone .neg, .rep-tone-legend .neg { background: #d64545; }
.rep-tone-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.rep-tone-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 5px; vertical-align: 0; }
.rep-tone-legend b { color: var(--text); font-weight: 600; }
.rep-texts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rep-texts li { background: var(--sunken); border-radius: var(--r-sm); padding: 7px 10px; font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.rep-more { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }

/* Two modes for a saved form: building (chat + preview) and results
   (responses and analysis, full width, no building chat). */
.results-mode .chat, .results-mode .tabs { display: none !important; }
.results-mode .preview { display: flex !important; flex: 1; }
.back-btn svg { width: 16px; height: 16px; }
[dir="rtl"] .back-btn svg { transform: scaleX(-1); }
.preview-bar .results-btn { color: var(--accent); border-color: var(--accent); }
.results-btn svg { width: 16px; height: 16px; }

.profile-usage { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 0 0 16px; text-align: start; }
.profile-usage:empty { display: none; }
.usage-row { font-size: var(--fs-sm); }
.usage-row .usage-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.usage-row .usage-top span:last-child { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.usage-row .rep-track { height: 8px; }
.usage-row .rep-fill.full { background: var(--danger-solid); }
.resp-limit { font-size: var(--fs-xs); color: var(--text-muted); margin-inline-end: auto; }
.resp-limit.warn, .share-limit.warn { color: #b26a00; }
.resp-limit.full, .share-limit.full { color: var(--danger); font-weight: 500; }
.resp-total { margin-inline-end: 0 !important; }
.share-limit { margin: -6px 0 12px; font-size: var(--fs-sm); }

/* Version, saved state and undo sit together; the share action stands alone at the far end. */
.preview-meta { display: inline-flex; align-items: center; gap: 6px; }
.preview-meta .saved-flag:not([hidden])::before { content: '·'; margin-inline-end: 6px; }
.preview-bar .ghost-btn { padding: 3px 10px; font-size: var(--fs-xs); }
/* Nothing in the bar may squeeze or wrap; the share button always stays visible. */
.preview-bar > * { flex: none; white-space: nowrap; }
.preview-bar { overflow: hidden; }
@container preview (max-width: 560px) {
  .preview-bar { padding-inline: 12px; gap: 8px; }
  .preview-meta .version, .preview-meta .saved-flag > span { display: none; }
  .preview-meta .saved-flag:not([hidden])::before { content: none; }
  #undoBtn > span { display: none; }
  #undoBtn { padding: 4px 7px; }
}
@container preview (max-width: 440px) {
  .view-toggle button { padding: 4px 8px; font-size: var(--fs-xs); }
  .preview-meta { display: none; }
  .publish-btn { padding: 6px 11px; }
}
.publish-btn { padding: 6px 16px; font-size: var(--fs-sm); margin-inline-start: auto; }
.publish-btn.closed::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 1.5px #fff; margin-inline-end: 6px; vertical-align: 1px; }
.publish-btn.live::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2fbf71; margin-inline-end: 6px; vertical-align: 1px; }

.share-status { margin-bottom: 12px; }
.share-link { display: flex; gap: 8px; }
.share-link input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--bg); color: var(--text); }
.share-note { margin: 10px 0 18px; font-size: var(--fs-xs); }
.share-thanks { margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--sunken); font-size: var(--fs-sm); line-height: 1.5; }
.share-thanks-label { color: var(--text-muted); margin-inline-end: 4px; }
.share-thanks-text { white-space: pre-wrap; font-weight: 500; unicode-bidi: isolate; }
.share-thanks .link-btn { margin-inline-start: 6px; font-size: var(--fs-sm); }
.share-thanks-edit { margin-top: 8px; }
.share-thanks-edit textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical; }
.share-thanks-edit textarea:focus { outline: 0; border-color: var(--accent); }
.share-thanks-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.share-thanks-actions .btn { padding: 5px 14px; font-size: var(--fs-sm); }
.share-thanks-error { color: var(--danger); font-size: var(--fs-xs); }
/* A coloured secondary button (light brand tint). */
.btn.soft { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
@media (hover: hover) { .btn.soft:hover:not(:disabled) { background: var(--accent-soft); filter: brightness(.95); } }
.share-actions { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.share-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.live-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #2fbf71; box-shadow: 0 0 0 3px rgba(47, 191, 113, .18); margin-inline: 2px 6px; }
.live-dot.closed { background: #e5484d; box-shadow: 0 0 0 3px rgba(229, 72, 77, .18); }
.saved-flag { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); color: var(--text-muted); }
.saved-flag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }

.side-forms { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; }
.side-form { display: flex; align-items: center; border-radius: var(--r-sm); }
.side-form:hover, .side-form.active { background: var(--sunken); }
.side-form-open { flex: 1; min-width: 0; border: 0; background: none; padding: 7px 10px; text-align: start; font: inherit; font-size: var(--fs-sm); color: var(--text); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-form-del { opacity: 0; width: 28px; height: 28px; flex: none; }
.side-form:hover .side-form-del, .side-form.active .side-form-del, .side-form-del:focus-visible { opacity: 1; }
.side-form-del svg { width: 15px; height: 15px; }
@media (hover: none) { .side-form-del { opacity: 1; } }
.ghost-btn:disabled { opacity: .45; cursor: default; }
[dir="rtl"] .ghost-btn svg { transform: scaleX(-1); }
.preview-scroll { flex: 1; overflow-y: auto; padding: 28px 20px 56px; }

/* the form is a sheet on a tinted canvas: cards have no border, only a soft shadow */
.form-sheet { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.f-card {
  background: var(--surface); box-shadow: var(--card-shadow);
  border-radius: var(--radius); padding: 20px 22px; transition: box-shadow .6s;
}
.f-card.changed { box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--accent-soft); }
.f-head { border-top: 8px solid var(--accent); padding-top: 22px; }
.f-head h2 { margin: 0 0 6px; font-size: 26px; font-weight: 600; line-height: 1.25; letter-spacing: -.015em; text-wrap: balance; }
.f-head p { margin: 0; color: var(--text-muted); white-space: pre-wrap; }
.f-head .req-note { margin-top: 14px; font-size: var(--fs-xs); color: var(--danger); }
.f-q-title { font-weight: 500; margin: 0 0 2px; }
.f-q-title .star { color: var(--danger); margin-inline-start: 3px; }
.f-help { font-size: var(--fs-sm); color: var(--text-muted); margin: 0 0 6px; }
.f-body { margin-top: 12px; }
.f-input {
  width: 100%; max-width: 420px; border: 0; border-bottom: 1px solid var(--border-strong);
  background: none; padding: 6px 0; outline: 0; transition: border-color var(--ease);
}
.f-input:focus { border-bottom-color: var(--accent); }
textarea.f-input { max-width: none; resize: vertical; min-height: 34px; }
select.f-input { border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 8px 10px; background: var(--surface); }
.f-option { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; }
.f-option input, .f-scale-points input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.f-scale { display: flex; align-items: flex-end; gap: 6px; flex-wrap: wrap; }
.f-scale-label { font-size: var(--fs-xs); color: var(--text-muted); padding-bottom: 8px; }
.f-scale-points { display: flex; gap: 2px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.f-scale-points label { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 8px; font-size: var(--fs-xs); cursor: pointer; }
.f-stars { display: flex; gap: 4px; }
.f-stars button { border: 0; background: none; padding: 2px; cursor: pointer; color: var(--border-strong); }
.f-stars button:hover { color: var(--accent); }
.f-stars button.on { color: var(--accent); }
.f-stars svg { width: 28px; height: 28px; stroke-width: 1.5; }
.f-stars button.on svg { fill: currentColor; }
.f-section { background: none; box-shadow: none; border: 0; padding: 18px 4px 2px; }
.f-section .f-q-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.f-matrix-wrap { overflow-x: auto; margin: 4px 0; }
.f-matrix { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.f-matrix th, .f-matrix td { padding: 8px 6px; text-align: center; }
.f-matrix thead th { font-weight: 500; color: var(--text-muted); font-size: var(--fs-xs); vertical-align: bottom; }
.f-matrix tbody th { text-align: start; font-weight: 400; min-width: 120px; }
.f-matrix tbody tr:nth-child(odd) { background: var(--sunken); }
.f-matrix input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.f-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 2px; }
.btn.f-submit, .btn.f-submit:hover { background: var(--accent); cursor: not-allowed; }
.btn.f-submit:active { transform: none; }
.f-foot span { font-size: var(--fs-xs); color: var(--text-muted); }
.f-thanks-note { margin: 0 2px; font-size: var(--fs-xs); color: var(--text-muted); white-space: pre-wrap; }
.f-thanks-note span { color: var(--text); }
.skeleton {
  height: 90px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--sunken) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
.skeleton.tall { height: 130px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- dialogs (settings, plans, access code) ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  padding: 24px; width: min(380px, calc(100vw - 32px)); box-shadow: var(--pop-shadow);
}
dialog::backdrop { background: var(--backdrop); }
dialog h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
dialog p { margin: 0 0 14px; color: var(--text-muted); font-size: var(--fs-sm); text-wrap: pretty; }
dialog input[type="text"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--bg); outline: 0; transition: border-color var(--ease);
}
dialog input[type="text"]:focus { border-color: var(--accent); }
dialog.wide { width: min(460px, calc(100vw - 32px)); padding: 20px 22px 24px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dlg-head h2 { margin: 0; }

.settings { display: flex; flex-direction: column; gap: 6px; }
.set-label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); margin-top: 8px; }

.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan { border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.plan.pro { border-color: var(--accent); background: var(--accent-soft); }
.plan h3 { margin: 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.plan.pro h3 svg { color: var(--accent); fill: currentColor; stroke-width: 1.2; width: 18px; height: 18px; }
.plan p { margin: 0 0 6px; flex: 1; }

dialog .signin-error { color: var(--danger); }

.confirm-dialog h2 { overflow-wrap: anywhere; }
.confirm-dialog p { margin-bottom: 20px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.danger { background: var(--danger-solid); color: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--danger-solid); filter: brightness(.9); }

.quota { margin: 8px 4px 0; font-size: var(--fs-xs); color: var(--text-muted); text-align: center; }
.quota.empty { color: var(--danger); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.profile { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding-top: 4px; }
.avatar.avatar-lg { width: 88px; height: 88px; font-size: 32px; font-weight: 500; margin-bottom: 8px; background: var(--accent); color: var(--accent-ink); }
.profile-name { font-size: 19px; font-weight: 600; }
.profile-email { color: var(--text-muted); font-size: var(--fs-sm); word-break: break-all; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 16px 0; border: 1px solid var(--border); border-radius: var(--r-md); }
.profile-stats div { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; }
.profile-stats div + div { border-inline-start: 1px solid var(--border); }
.profile-stats b { font-weight: 500; }
.profile-stats small { color: var(--text-muted); font-size: var(--fs-xs); }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; margin-top: 8px; }
.google-btn svg { width: 18px; height: 18px; background: #fff; border-radius: 50%; padding: 2px; box-sizing: content-box; }

/* ---------- narrow screens (keep last so these win) ---------- */
/* not enough room beside the side bar: chat and form become tabs */
@container main (max-width: 720px) {
  .started .tabs { display: flex; gap: 2px; background: var(--sunken); padding: 3px; border-radius: var(--r-sm); margin-inline: auto; }
  .tabs button { border: 0; background: none; padding: 5px 16px; border-radius: calc(var(--r-sm) - 3px); cursor: pointer; color: var(--text-muted); font-size: var(--fs-sm); }
  .tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
  .started .chat { flex: 1; border: 0; }
  .started .preview { display: none; }
  .started.show-form .chat { display: none; }
  .started.show-form .preview { display: flex; }
  .preview-scroll { padding: 16px 12px 40px; }
  .f-card { padding: 16px; }
  .hero { padding-bottom: 8vh; }
}
/* phones: the side bar slides over the page instead of taking space */
@media (max-width: 640px) {
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  [dir="rtl"] .side { transform: translateX(105%); }
  .side-open .side { transform: none; }
  .side-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: var(--backdrop); }
  .side-collapsed .side { display: flex; }
  .icon-btn.menu-btn { display: inline-grid; }
  .top-upgrade { display: inline-flex; }
}
@media (max-width: 480px) {
  .plans { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Stage 6: recently deleted, feedback, account deletion, policy links, toast. */
.side-link { margin: 4px 0 0; padding: 6px 10px; border: 0; background: none; color: var(--text-muted); font: inherit;
  font-size: var(--fs-xs); text-align: start; cursor: pointer; border-radius: var(--r-sm, 8px); }
.side-link:hover { color: var(--text); background: var(--hover, rgba(127,127,127,.08)); }
.side-legal { margin: 0; padding: 0 10px; font-size: var(--fs-xs); color: var(--text-muted); }
.side-legal a { color: inherit; }
.dlg-note { display: block; margin: 0 0 12px; font-size: var(--fs-sm); color: var(--text-muted); }
.deleted-list { display: flex; flex-direction: column; gap: 8px; }
.deleted-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); }
.deleted-words { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.deleted-words b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deleted-words small { color: var(--text-muted); font-size: var(--fs-xs); }
#feedbackText { width: 100%; font: inherit; font-size: var(--fs-sm); padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); resize: vertical; box-sizing: border-box; }
.fb-error { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--danger); }
.dlg-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.danger-link { color: var(--danger); font-size: var(--fs-sm); margin-top: 10px; }
.toast { position: fixed; inset-inline: 16px; bottom: 24px; margin: 0 auto; max-width: 460px; z-index: 50; padding: 12px 16px;
  border-radius: var(--r-md); background: var(--text); color: var(--bg); font-size: var(--fs-sm); box-shadow: 0 8px 24px rgba(0,0,0,.18); text-align: center; }
