/* Worthwork — the application's own look. The resume has its own
   stylesheet and fonts (static/resume/); this file styles the page around it.
   Design tokens as custom properties; the dark theme redefines them. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --text: #18202b;
  --muted: #5a6574;
  --border: #dfe3e9;
  --border-strong: #c6ccd5;
  /* One accent, used sparingly: what acts, and where you are. */
  --accent: #1f5bd8;
  --accent-hover: #1a4cb6;
  --accent-soft: #e8effd;
  --accent-contrast: #ffffff;
  --ok: #17784a;
  --ok-soft: #e3f4ea;
  --warn: #8a5800;
  --warn-soft: #fbf1dc;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --focus: #1f5bd8;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow: 0 1px 3px rgb(16 24 40 / 8%), 0 8px 24px rgb(16 24 40 / 6%);
  --shadow-lg: 0 24px 64px rgb(16 24 40 / 18%);
  --paper: #ffffff;
  --stage: #e9ecf1;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --header-height: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1c212a;
  --surface-3: #252b36;
  --text: #e5e8ed;
  --muted: #9aa4b2;
  --border: #2a303b;
  --border-strong: #3a4250;
  --accent: #7ea6ff;
  --accent-hover: #a2bfff;
  --accent-soft: #1d2a46;
  --accent-contrast: #0e1116;
  --ok: #5fd39a;
  --ok-soft: #173427;
  --warn: #f0bf5a;
  --warn-soft: #3a2e14;
  --bad: #ff8a80;
  --bad-soft: #3d1c1a;
  --focus: #7ea6ff;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow: 0 1px 3px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  --shadow-lg: 0 24px 64px rgb(0 0 0 / 55%);
  --stage: #0a0d11;
  color-scheme: dark;
}

/* ------------------------------------------------------------ base */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Nothing is drawn until the page knows whether someone is signed in. */
body.booting .main { visibility: hidden; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 650; }
h2 { font-size: 1.125rem; font-weight: 620; }
h3 { font-size: 0.95rem; font-weight: 620; }
p { margin: 0; }
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 0.875em; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 8px; box-shadow: var(--shadow); }

.muted { color: var(--muted); }
.small-text { font-size: 0.85rem; }
.tiny-text { font-size: 0.78rem; }
.spacer { flex: 1 1 auto; }

.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon svg { display: block; }

/* ---------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 560;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button.primary { background: var(--accent); color: var(--accent-contrast); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { background: var(--surface); border-color: var(--border-strong); }
.button.secondary:hover:not(:disabled) { background: var(--surface-2); }
.button.ghost:hover:not(:disabled) { background: var(--surface-2); }
.button.danger { background: var(--bad); color: #ffffff; }
.button.small { min-height: 30px; padding: 0 10px; font-size: 0.875rem; }
.button.wide { width: 100%; min-height: 42px; }
.button.icon-button { width: 36px; padding: 0; }

/* A button waiting on the server: a spinner in place of its content. */
.button.busy { position: relative; color: transparent !important; }
.button.busy > * { visibility: hidden; }
.button.busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.button.primary.busy::after, .button.danger.busy::after { border-color: var(--accent-contrast); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- fields */

label { font-size: 0.875rem; font-weight: 560; }

input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}
input[readonly] { background: var(--surface-2); color: var(--muted); }
select.compact { width: auto; min-height: 32px; padding: 3px 8px; font-size: 0.875rem; }

.stack { display: flex; flex-direction: column; gap: 8px; }
.stack > label { margin-top: 6px; }
.narrow { max-width: 420px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.message { min-height: 1.25em; font-size: 0.875rem; }
.message.error { color: var(--bad); }
.message:empty { min-height: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.applied { border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip .icon svg { width: 14px; height: 14px; }

/* ----------------------------------------------------------- header */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-height);
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand-mark { color: var(--accent); }
.brand-mark svg path { stroke: var(--accent-contrast); }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }

.version-tag {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.nav { display: flex; gap: 2px; margin-left: 12px; }
.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 560;
  cursor: pointer;
}
.nav-button:hover { background: var(--surface-2); color: var(--text); }
.nav-button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.segment {
  min-width: 34px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
.segment[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.who { max-width: 180px; overflow: hidden; color: var(--muted); font-size: 0.875rem; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  left: 50%;
  z-index: 30;
  max-width: min(560px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  cursor: pointer;
  transform: translateX(-50%);
}
.toast:not(.shown) { display: none; }
.toast.ok { background: var(--ok); color: #ffffff; }
.toast.error { background: var(--bad); color: #ffffff; }

/* ------------------------------------------------------------- main */

.main { outline: none; }
.view.page { max-width: 1120px; margin: 0 auto; padding: 32px 16px 48px; }
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.page-head p { margin-top: 6px; }

/* ---------------------------------------------------------- landing */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 56px;
  align-items: center;
  max-width: 1080px;
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  padding: 48px 24px;
}
.eyebrow { color: var(--accent); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.landing h1 { margin-top: 12px; font-size: clamp(2rem, 4.5vw, 3.1rem); font-weight: 720; letter-spacing: -0.03em; }
.lead { margin-top: 16px; color: var(--muted); font-size: 1.12rem; line-height: 1.6; }
.promise-list { display: grid; gap: 10px; margin: 28px 0 0; padding: 0; list-style: none; }
.promise-list li { display: flex; gap: 10px; align-items: flex-start; }
.promise-list .icon { margin-top: 2px; color: var(--ok); }
.landing-card { display: flex; flex-direction: column; gap: 14px; padding: 28px; box-shadow: var(--shadow); }
.landing-card h2 { font-size: 1.2rem; }
.sent { align-items: flex-start; }
.sent-icon { display: inline-flex; padding: 10px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.divider { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 0.82rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------- resumes */

.resume-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.resume-card { position: relative; display: flex; flex-direction: column; overflow: hidden; transition: box-shadow 0.15s, border-color 0.15s; }
.resume-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.resume-open {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 0 14px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.resume-open:focus-visible { outline-offset: -2px; border-radius: var(--radius-lg); }

/* A page, drawn: what a resume card stands for. */
.resume-thumb {
  display: flex;
  flex-direction: column;
  gap: 7px;
  height: 128px;
  margin-bottom: 10px;
  padding: 22px 22% 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.resume-thumb span { display: block; height: 6px; border-radius: 3px; background: var(--border-strong); }
.resume-thumb span:first-child { width: 55%; height: 9px; background: var(--accent); opacity: 0.7; }
.resume-thumb span:nth-child(2) { width: 80%; }
.resume-thumb span:nth-child(3) { width: 90%; }
.resume-thumb span:nth-child(4) { width: 65%; }
.resume-card-title { padding: 0 14px; font-weight: 620; overflow-wrap: anywhere; }
.resume-card-meta { padding: 0 14px; color: var(--muted); font-size: 0.82rem; }
.card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.card-actions .button { background: var(--surface); box-shadow: var(--shadow-sm); }
.resume-card:hover .card-actions, .resume-card:focus-within .card-actions { opacity: 1; }
@media (hover: none) { .card-actions { opacity: 1; } }

.empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 48px 24px; text-align: center; }
.empty-icon { padding: 14px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.empty-icon svg { width: 28px; height: 28px; }

/* ----------------------------------------------------------- editor */

body.editing { overflow: hidden; }
.editor { display: flex; flex-direction: column; height: calc(100vh - var(--header-height)); height: calc(100dvh - var(--header-height)); }

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.title-input {
  width: auto;
  min-width: 0;
  max-width: 340px;
  flex: 0 1 340px;
  border-color: transparent;
  background: none;
  font-size: 1.05rem;
  font-weight: 620;
}
.title-input:hover { border-color: var(--border); }

.save-status { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.save-status.saved::before { content: "✓ "; color: var(--ok); }
.save-status.error { max-width: 280px; overflow: hidden; color: var(--bad); text-overflow: ellipsis; cursor: pointer; }
.save-status.titleNeeded { color: var(--warn); }
.downloads { display: inline-flex; gap: 4px; align-items: center; }

.editor-tabs { display: none; }

/* Wide: three panes side by side, in five columns — pane, gutter, pane,
   gutter, pane. The script sets each column's width (a share of the room
   with a floor, or 0 for a hidden pane and the gutter beside it); the
   fallbacks here are the defaults. */
.editor-panes {
  --col-markdown: minmax(260px, 1fr);
  --col-gutter-0: 9px;
  --col-preview: minmax(260px, 1.15fr);
  --col-gutter-1: 9px;
  --col-chat: minmax(300px, 0.8fr);
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: var(--col-markdown) var(--col-gutter-0) var(--col-preview) var(--col-gutter-1) var(--col-chat);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane-markdown { grid-column: 1; }
.pane-preview { grid-column: 3; }
.pane-chat { grid-column: 5; }
.gutter[data-gutter="0"] { grid-column: 2; }
.gutter[data-gutter="1"] { grid-column: 4; }
.pane.pane-off, .gutter.gutter-off { display: none; }

/* A 1px rule with room around it to grab; the grip shows on hover and focus. */
.gutter {
  position: relative;
  z-index: 1;
  background: var(--surface);
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}
.gutter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: var(--border);
  transition: background-color 0.15s, width 0.15s, left 0.15s;
}
.gutter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 5px;
  height: 36px;
  margin-top: -18px;
  border-radius: 3px;
  background: var(--border-strong);
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s;
}
.gutter:hover::after, .gutter:focus-visible::after, .gutter.dragging::after { opacity: 1; }
.gutter:hover::before, .gutter.dragging::before { left: 3px; width: 3px; background: var(--accent-soft); }
.gutter.dragging::after { background: var(--accent); }
.gutter:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 0; }
/* While a gutter is dragged, nothing else reacts to the pointer — the
   preview's frame would otherwise swallow it. */
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .preview-frame, body.resizing .markdown-input { pointer-events: none; }

.pane-toggles .segment { display: inline-flex; align-items: center; justify-content: center; }
.pane-toggles .segment:disabled { cursor: default; }
.pane-toggles .icon svg { width: 16px; height: 16px; }
.pane-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.pane-head h2 { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.pane-markdown { background: var(--surface); }
.markdown-input {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 20px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  /* Set from the page's text-size buttons; 14px until then. */
  font: var(--markdown-font-size, 14px)/1.65 var(--mono);
  tab-size: 4;
  resize: none;
}
.markdown-input:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.warnings { flex: none; max-height: 30%; overflow: auto; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--warn-soft); }
.warnings-title { display: flex; gap: 6px; align-items: center; color: var(--warn); font-size: 0.85rem; }
.warning-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 0.85rem; }
.warning-list li { padding: 2px 0; }
.warning-link { padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; text-decoration: underline; text-decoration-color: var(--warn); text-underline-offset: 3px; cursor: pointer; }
.warning-link:hover { color: var(--warn); }

.pane-preview { container-type: inline-size; background: var(--stage); }
/* One line: the page's name gives way first, then the words of the zoom. */
.pane-preview .pane-head { flex-wrap: nowrap; }
.pane-preview .pane-head h2, .zoom { flex: none; }
.preview-page { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.zoom { display: inline-flex; gap: 2px; align-items: center; }
.zoom-modes { margin-right: 4px; }
.zoom-modes .segment { display: inline-flex; gap: 5px; align-items: center; padding: 0 8px; white-space: nowrap; }
.zoom .icon svg { width: 16px; height: 16px; }
.button.zoom-step { width: 30px; min-height: 30px; }
.zoom-level { min-width: 44px; color: var(--muted); font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }

/* The page is laid out at its real size and scaled by --page-scale; the
   paper around it takes the scaled size, so the stage scrolls the scaled
   page. The scrollbar's room is kept, so fitting to the width never makes
   the scrollbar come and go. */
.preview-stage {
  --page-width: 794px;
  --page-height: 1123px;
  /* The whole document: one page or more. */
  --doc-height: 1123px;
  --page-scale: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  scrollbar-gutter: stable;
}
.preview-stage.fit-width { overflow-x: hidden; }
.preview-paper {
  width: calc(var(--page-width) * var(--page-scale));
  height: calc(var(--doc-height) * var(--page-scale));
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border-radius: 2px;
  box-shadow: var(--shadow);
  transition: opacity 0.2s;
}
.preview-frame {
  display: block;
  width: var(--page-width);
  height: var(--doc-height);
  border: 0;
  background: var(--paper);
  transform: scale(var(--page-scale));
  transform-origin: 0 0;
}
.preview-stage.loading .preview-paper { opacity: 0.6; }

.pane-chat { background: var(--surface); }
.callout { margin: 12px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.callout p { margin-bottom: 10px; font-size: 0.9rem; }
.chat-log { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 14px 12px; list-style: none; }
.bubble { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.bubble-text { padding: 9px 12px; border-radius: 14px; font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.from-user { align-self: flex-end; align-items: flex-end; }
.from-user .bubble-text { background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: 4px; }
.from-assistant { align-self: flex-start; align-items: flex-start; }
.from-assistant .bubble-text { background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.pending { opacity: 0.7; }
.thinking { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.dots { display: inline-flex; gap: 4px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-intro { display: flex; gap: 10px; align-items: flex-start; margin: auto 4px 0; padding: 14px; border-radius: var(--radius); background: var(--accent-soft); font-size: 0.9rem; }
.chat-intro-icon { color: var(--accent); }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
/* The form stays at the foot of the pane, one fixed size: three lines. */
.chat-form { display: flex; flex: none; gap: 8px; align-items: flex-end; margin-top: auto; padding: 10px 12px 4px; border-top: 1px solid var(--border); }
.chat-form textarea { height: calc(4.5em + 16px); min-height: 0; max-height: none; line-height: 1.5; resize: none; overflow-y: auto; }
.chat-form .button { flex: none; width: 42px; min-height: 42px; }
.pane-chat > .tiny-text { padding: 0 12px 10px; }

/* Wide: three panes side by side. Narrower: one at a time, under tabs. */
@media (max-width: 1099px) {
  .editor-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  /* One pane at a time: the widths, the gutters and the toggles are for
     wide screens only. */
  .editor-panes { grid-template-columns: minmax(0, 1fr); }
  .editor-panes > .pane { grid-column: 1; }
  .pane.pane-off { display: flex; }
  .gutter, .pane-toggles { display: none; }
  .editor-panes[data-pane="markdown"] .pane-preview,
  .editor-panes[data-pane="markdown"] .pane-chat,
  .editor-panes[data-pane="preview"] .pane-markdown,
  .editor-panes[data-pane="preview"] .pane-chat,
  .editor-panes[data-pane="chat"] .pane-markdown,
  .editor-panes[data-pane="chat"] .pane-preview { display: none; }
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 580;
  cursor: pointer;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.editor-tabs .tab { flex: 1; justify-content: center; }

/* --------------------------------------------------------- settings */

.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-tabs { display: flex; flex-direction: column; gap: 2px; }
.settings-tabs .tab { justify-content: flex-start; }
.settings-panel { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.settings-version { margin-top: 24px; text-align: right; }
.consent-state { padding: 12px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-weight: 560; }
.consent-state.given { background: var(--ok-soft); color: var(--ok); }
/* Nothing is pending: an agreement only platform models will ask for. */
.consent-state.neutral { background: var(--surface-2); color: var(--muted); font-weight: 400; }
#tab-privacy .button { align-self: flex-start; }

.items { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 4px; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item.current { background: var(--accent-soft); border-radius: var(--radius-sm); }
.item-icon { margin-top: 2px; padding: 7px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); }
.item-text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 3px; min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: 0.84rem; overflow-wrap: anywhere; }
.item-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.item-actions { display: flex; flex: none; flex-wrap: wrap; gap: 2px; align-items: center; justify-content: flex-end; }
.empty-line { padding: 14px 4px; }
.version-number { min-width: 40px; padding-top: 2px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }

.login-steps { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); font-size: 0.88rem; }
.login-steps .button { align-self: flex-start; }
.login-url { display: block; max-height: 4.5em; overflow: auto; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.login-code { display: flex; gap: 8px; align-items: center; }
.login-code code { padding: 4px 10px; border-radius: var(--radius-sm); background: var(--surface); font-size: 1.05rem; font-weight: 700; letter-spacing: 0.08em; }
.login-paste { display: flex; gap: 8px; }

/* ----------------------------------------------------------- modals */

/* A modal owns a fixed frame: its size never follows its content, which
   scrolls inside it (coding recipe §2.13). */
.modal {
  width: min(560px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal.modal-small { width: min(460px, calc(100vw - 32px)); height: min(380px, calc(100dvh - 32px)); }
.modal.modal-large { width: min(780px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 32px)); }
.modal::backdrop { background: rgb(10 14 20 / 50%); backdrop-filter: blur(2px); }
.modal[open] { display: block; animation: rise 0.16s ease-out; }
.modal-frame { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
.modal-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; padding: 6px 20px 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal.nudge { animation: nudge 0.3s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.guide-rules { display: grid; gap: 6px; margin: 0; padding-left: 20px; font-size: 0.9rem; }
.guide-example-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.code-block { margin: 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: 0.82rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ------------------------------------------------------- small screens */

@media (max-width: 900px) {
  .landing { grid-template-columns: minmax(0, 1fr); gap: 32px; min-height: 0; padding: 32px 16px; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-tabs { flex-direction: row; overflow-x: auto; }
}

@media (max-width: 720px) {
  .nav-label { display: none; }
  .nav { margin-left: 4px; }
  .nav-button { padding: 0 10px; }
  .who { display: none; }
  .settings-tabs .tab span:not(.icon) { display: none; }
  .settings-tabs .tab { flex: 1; justify-content: center; }
  .settings-panel { padding: 16px; }
  .view.page { padding-top: 20px; }
  h1 { font-size: 1.45rem; }
  .title-input { flex: 1 1 140px; max-width: none; }
  .downloads .button.ghost { padding: 0 8px; }
}

/* The version stays in the header, minimized. */
@media (max-width: 560px) {
  .header { gap: 4px; padding: 0 10px; }
  .brand-name { display: none; }
  .version-tag { padding: 0 4px; border: 0; font-size: 0.62rem; }
  .resume-grid { grid-template-columns: minmax(0, 1fr); }
  .item { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-start; }
  .editor-bar { padding: 8px 10px; }
  #style-versions span:not(.icon) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ------------------------------------------------------ attachments */

/* Files waiting to go, and files sent: chips with a thumbnail or an icon. */
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pending-attachments { flex: none; max-height: 160px; overflow: auto; padding: 8px 12px 0; border-top: 1px solid var(--border); }
.from-user .attachment-list { justify-content: flex-end; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  min-height: 40px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
}
button.attachment-chip { cursor: pointer; }
button.attachment-chip:hover { border-color: var(--accent); }
.attachment-thumb { flex: none; width: 32px; height: 32px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); }
.attachment-chip.sent .attachment-thumb { width: 56px; height: 56px; }
.attachment-icon { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); }
.attachment-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { flex: none; color: var(--muted); }
.attachment-remove { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.attachment-remove:hover { background: var(--surface-2); color: var(--bad); }
.attachment-remove .icon svg { width: 14px; height: 14px; }
.attachment-chip.busy { opacity: 0.6; }

/* A file dragged over the chat: the whole pane says it will take it. */
.pane-chat { position: relative; }
.pane-chat.dropping { outline: 2px dashed var(--accent); outline-offset: -6px; }
.chat-drop {
  position: absolute;
  inset: 6px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-soft) 92%, transparent);
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.chat-drop .icon svg { width: 32px; height: 32px; }

/* The image preview: the frame is the modal's, the image fits inside it. */
.attachment-view-title { min-width: 0; overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.attachment-view-body { align-items: center; justify-content: center; overflow: hidden; background: var(--stage); }
.attachment-view-image { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.pending-attachments + .chat-form { border-top: 0; }
