/* Palette follows the illy logo: dark ink, coral accent, flat surfaces.
   Every colour that moves is one light-dark() pair, so the dark theme is
   this block and nothing else. Without data-theme the page follows the
   operating system; the rail's toggle sets the attribute to override it. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f2f2f2, #1a1a1a);
  --surface: light-dark(#ffffff, #242424);
  --panel: light-dark(#ffffff, #242424);
  --line: light-dark(#eaeaf1, #343434);
  --text: light-dark(#495057, #c9cacd);
  --heading: light-dark(#2b2b2b, #f5f5f5);
  --muted: light-dark(#797c8c, #8b8e96);
  --accent: #ec606e;
  --accent-soft: light-dark(rgba(236, 96, 110, 0.12), rgba(236, 96, 110, 0.18));
  --rail-bg: light-dark(#2b2b2b, #101010);
  --rail-icon: #8b8e96;
  --logo-ink: light-dark(#2b2b2b, #ffffff);
  --logo-dot: #ec606e;
  --shadow: 0 2px 4px light-dark(rgba(15, 34, 58, 0.12), rgba(0, 0, 0, 0.45));
  --error-bg: light-dark(#fdf1f1, #3a2226);
  --error-line: light-dark(#e6b7b7, #6e3b42);
  --done: light-dark(#2f7d4f, #7fcf9a);
  --hover-ink: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12));
  /* The deck and document pages: a deeper page and flatter controls. */
  --editor-page: light-dark(#f2f2f2, #0e0e0e);
  --editor-panel: light-dark(#ffffff, #141414);
  --editor-border: light-dark(#dedee6, #1f1f1f);
  --editor-text: light-dark(#2b2b2b, #e8e8e8);
  --editor-muted: light-dark(#797c8c, #8b8b8b);
  --editor-accent: #ec606e;
  --editor-accent-soft: light-dark(rgba(236, 96, 110, 0.12), rgba(236, 96, 110, 0.16));
  --editor-field: light-dark(#ffffff, #1a1a1a);
  --editor-field-hover: light-dark(#f7f7f9, #242424);
  --editor-bubble: light-dark(#f0f0f3, #242424);
  --editor-ink: light-dark(#2b2b2b, #ffffff);
  --tag-pdf: light-dark(#c73848, #f59ca6);
  --tag-word: light-dark(#1a5fc2, #8ab4f8);
  --rail-width: 52px;
  --panel-width: 300px;
  --head-height: 42px;
  /* Every square-cornered text button is this tall; phones raise it to a touch target. */
  --button-height: 32px;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* The toggle shows where a click takes you: a moon on a light page, a sun
   on a dark one. Done in CSS so the icon is right before any script runs. */
.sun { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun { display: block; }
  :root:not([data-theme="light"]) .moon { display: none; }
}

:root[data-theme="dark"] .sun { display: block; }
:root[data-theme="dark"] .moon { display: none; }
:root[data-theme="light"] .sun { display: none; }
:root[data-theme="light"] .moon { display: block; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1 { color: var(--heading); }

.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }

/* -- login / forbidden ----------------------------------------------------- */

.centred {
  max-width: 26rem;
  margin: 12vh auto;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--button-height);
  padding: 0.25rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}

/* Every .button variant sets display, which beats the browser's own [hidden] rule. */
.button[hidden] { display: none !important; }

.link {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 0.8125rem;
}

/* -- shell ----------------------------------------------------------------- */

.layout { display: flex; height: 100vh; }

.rail {
  width: var(--rail-width);
  flex: none;
  background: var(--rail-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0 1.25rem;
}

/* Centred on the top bar's height, so it sits level with the logo beside it. */
.rail-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  margin: calc((var(--head-height) - 14px) / 2) 0 1.25rem;
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.rail-button {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--rail-icon);
  cursor: pointer;
}

.rail-button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.rail-button[aria-current="page"] { background: rgba(255, 255, 255, 0.08); color: #fff; }
.rail-button.primary { background: var(--accent); color: #fff; }
.rail-button.primary:hover { background: #e14a5a; }

.rail-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-button svg.brand-mark-icon {
  fill: #fff;
  stroke: none;
}

/* -- conversation panel ---------------------------------------------------- */

.panel {
  width: var(--panel-width);
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

/* The logo keeps its centre on the head (the rail dot lines up with it) and
   New Chat sits on the logo's bottom edge. 30.5px is the logo's height at 45px. */
.panel-head {
  height: var(--head-height);
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0 1rem calc((var(--head-height) - 30.5px) / 2) 1.5rem;
}
.panel-head .icon-button { align-self: center; margin-bottom: calc((30.5px - var(--head-height)) / 2); }

.logo { width: 45px; height: auto; display: block; }
.logo-link { display: block; flex: none; line-height: 0; }
.topbar {
  height: var(--head-height);
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.new-chat-button {
  display: flex;
  align-items: flex-end;
  gap: 0.3rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--heading);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.new-chat-button:hover { color: var(--accent); }
.new-chat-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.topbar-title,
.chat-title {
  margin: 0;
  color: var(--heading);
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversations {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.conversations .row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.conversations .row:hover { background: var(--bg); }
.conversations .row.active { background: var(--accent); color: #fff; }

.row-text { flex: 1; min-width: 0; }
.row-heading { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }

.row-title {
  display: block;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-date { display: block; font-size: 0.75rem; color: var(--muted); }
.row.active .row-date { color: rgba(255, 255, 255, 0.8); }

.conversation-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem 0.25rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* New project: the label keeps its height; the button overhangs it. */
.conversation-section-label .row-action { width: 22px; height: 22px; margin: -0.3rem -0.3rem -0.3rem 0; }

/* A project folder: one line, no date; its open chats sit indented under it. */
.conversations .project-row { padding-top: 0.4rem; padding-bottom: 0.4rem; }
.conversations .in-project .row { padding-left: 2rem; }

.project-mark {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--muted);
}

.project-count { flex: none; font-size: 0.75rem; color: var(--muted); }

.project-empty { padding: 0.15rem 0.75rem 0.4rem 2rem; font-size: 0.75rem; color: var(--muted); }

.pinned-mark {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--muted);
}

.pinned-mark svg,
.project-mark svg,
.writer-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row.active .pinned-mark { color: rgba(255, 255, 255, 0.8); }

.row-actions { display: none; gap: 0.15rem; flex: none; }
.row:hover .row-actions, .row.active .row-actions { display: flex; }

.row-action {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 4px;
  background: none;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
}

.row-action:hover { opacity: 1; background: var(--hover-ink); }
.row.active .row-action:hover { background: rgba(255, 255, 255, 0.25); }
.row-action[aria-pressed="true"] svg { fill: currentColor; }
.new-chat-button:focus-visible,
.row-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rename {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.panel-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
  border-top: 1px solid var(--line);
}

.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.panel-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--heading);
}

.account-area { min-width: 0; display: grid; gap: 0.1rem; }

/* -- chat column ----------------------------------------------------------- */

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

.chat-floating-head {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  left: 0;
  height: 72px;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.5rem 1.5rem;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--bg) 35%, transparent);
}

.chat-floating-head > * { pointer-events: auto; }

.chat-title-menu { position: relative; min-width: 0; max-width: 60%; }

.chat-title-trigger {
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--heading);
  font: inherit;
  cursor: pointer;
}

.chat-title-trigger:hover { background: var(--hover-ink); }
.chat-title-trigger:disabled { cursor: default; }
.chat-title-trigger:disabled:hover { background: transparent; }
.chat-title-trigger:focus-visible,
.chat-title-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chat-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 600;
}

.chat-title-chevron {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-title-trigger:disabled .chat-title-chevron { display: none; }

.chat-title-actions {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 1;
  width: 12rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-title-actions[hidden] { display: none; }

.chat-title-actions button {
  width: 100%;
  min-height: 36px;
  display: block;
  padding: 0.4rem 0.55rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--heading);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.chat-title-actions button:hover { background: var(--hover-ink); }

/* Add to project lists every project: long names end in an ellipsis, a long list scrolls. */
.chat-title-actions { max-height: 60vh; overflow-y: auto; }
.chat-title-actions button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title-actions .project-menu-new { color: var(--muted); }
.chat-title-actions .project-menu-new:not(:first-child) { border-top: 1px solid var(--line); border-radius: 0 0 5px 5px; }

/* The right-click menu sits at the pointer, above the phone drawer. */
.context-menu { position: fixed; top: 0; left: 0; z-index: 30; }

/* -- Today panel ---------------------------------------------------------- */

.today {
  width: 300px;
  flex: none;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.today-head {
  height: var(--head-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.today-head h2 {
  margin: 0;
  color: var(--heading);
  font-size: 1rem;
  font-weight: 600;
}

.today-head-actions { display: flex; gap: 0.2rem; }
.today-head .icon-button { display: grid; margin-left: 0; }
.today-head .tablet-only { display: none; }

/* Hiding a side panel is desktop only; tablet and phone already use drawers.
   A hidden panel comes back from the chat header: ☰ on the left, the calendar on the right. */
#collapse-panel, #collapse-today, #expand-today { display: none; }
.panel-head #collapse-panel { margin-left: auto; }

@media (min-width: 992px) {
  #collapse-panel, #collapse-today { display: grid; }
  .layout.panel-collapsed .panel, .layout.today-collapsed .today { display: none; }
  .layout.panel-collapsed #open-panel { display: grid; }
  .layout.today-collapsed #expand-today { display: grid; margin-left: auto; }
}

.today-section { padding: 1rem 1rem 0; }
.today-section:last-child { padding-bottom: 1.25rem; }
.today-section h3 { margin: 0; color: var(--heading); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.today-section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.today-toggle { border: 0; background: none; color: var(--accent); font: inherit; font-size: 0.6875rem; cursor: pointer; }
.today-toggle:hover { text-decoration: underline; }
.today-items { display: grid; gap: 0.25rem; margin-top: 0.55rem; }
.today-status { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.45; }
.today-item-link { min-width: 0; padding: 0.55rem 0.5rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.today-item-link:hover { background: var(--bg); }
.today-item-link strong, .today-item-link > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.today-item-link strong { color: var(--heading); font-size: 0.8125rem; line-height: 1.35; }
.today-muted { color: var(--muted); font-size: 0.75rem; line-height: 1.4; }
.today-location { overflow-wrap: anywhere; }
.today-task > span:first-child { color: var(--heading); font-size: 0.8125rem; line-height: 1.4; }
.today-mail-row { position: relative; display: grid; min-width: 0; }
.today-mail-row.unread .today-item-link { color: var(--heading); }
.today-mail-row.unread .today-mail-subject { font-weight: 600; }
.today-mail-time { position: absolute; right: 0.5rem; top: 0.55rem; color: var(--muted); font-size: 0.6875rem; }
.today-mail-row .today-item-link { position: relative; min-height: 4.25rem; padding-right: 3.3rem; padding-left: 1.5rem; }
.today-unread-dot { position: absolute; top: 0.9rem; left: 0.5rem; width: 7px; height: 7px; border-radius: 50%; visibility: hidden; }
.today-mail-row.unread .today-unread-dot { background: var(--accent); visibility: visible; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.today-mail-row strong { white-space: nowrap; }
.today-mail-subject { color: var(--heading); font-size: 0.75rem; line-height: 1.35; }
.today-snippet { white-space: nowrap; }
/* Like the conversation row actions: shown on hover, in the space the time column keeps free. */
.today-summarise { position: absolute; right: 0.4rem; bottom: 0.4rem; width: 28px; height: 28px; display: none; place-items: center; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; }
.today-mail-row:hover .today-summarise, .today-mail-row:focus-within .today-summarise { display: grid; }
@media (hover: none) { .today-summarise { display: grid; } }
.today-summarise:hover { background: var(--accent-soft); color: var(--accent); }
.today-summarise svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 5.25rem 1.5rem 1.5rem;
  scroll-padding-top: 5.25rem;
}

.empty {
  margin: auto;
  color: var(--muted);
  font-size: 0.875rem;
}

.message {
  max-width: 46rem;
  align-self: flex-start;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.message.user { align-self: flex-end; background: var(--accent-soft); box-shadow: none; }
.message.error { background: var(--error-bg); box-shadow: none; border: 1px solid var(--error-line); }

.message-body { min-width: 0; overflow-wrap: anywhere; }
.markdown { line-height: 1.55; }
.markdown p { margin: 0 0 0.75rem; }
.markdown p:last-child { margin-bottom: 0; }
.markdown hr { margin: 0.9rem 0; border: 0; border-top: 1px solid var(--line); }
.markdown h1, .markdown h2, .markdown h3 { margin: 0 0 0.55rem; color: var(--heading); line-height: 1.25; }
.markdown h1 { font-size: 1.25rem; }
.markdown h2 { font-size: 1.1rem; }
.markdown h3 { font-size: 1rem; }
.markdown ul, .markdown ol { max-width: 100%; margin: 0.35rem 0 0.75rem; padding-left: 1.4rem; }
.markdown li { max-width: 100%; margin: 0.2rem 0; overflow-wrap: anywhere; }
.markdown blockquote { margin: 0.5rem 0; padding-left: 0.8rem; border-left: 3px solid var(--line); color: var(--muted); }
.markdown blockquote p { margin-bottom: 0.35rem; }
.markdown code { padding: 0.1rem 0.3rem; border-radius: 3px; background: var(--bg); color: var(--heading); font-size: 0.9em; }
.markdown pre { max-width: 100%; margin: 0.5rem 0 0.75rem; padding: 0.75rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.markdown pre code { padding: 0; white-space: pre; }
.markdown a { color: var(--accent); overflow-wrap: anywhere; }
/* Attachment buttons sit inside Markdown bubbles; keep their text white on the accent fill. */
.markdown a.button:not(.export-drive) { color: #fff; }
.markdown-table-wrap { max-width: 100%; margin: 0.5rem 0 0.75rem; overflow-x: auto; }
.markdown table { border-collapse: collapse; font-size: 0.9em; }
.markdown th, .markdown td { padding: 0.4rem 0.55rem; border: 1px solid var(--line); text-align: left; white-space: nowrap; }
.markdown th { color: var(--heading); background: var(--bg); }

/* A fixed thumbnail height keeps the scroll position right before the image has loaded. */
.attachment-image { display: block; margin-top: 0.75rem; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); line-height: 0; overflow: hidden; cursor: zoom-in; }
.attachment-image img { display: block; height: 180px; width: auto; max-width: 100%; object-fit: contain; }
.image-viewer { max-width: 94vw; max-height: 94vh; padding: 0; border: 0; background: transparent; cursor: zoom-out; }
.image-viewer::backdrop { background: rgba(0, 0, 0, 0.82); }
.image-viewer img { display: block; max-width: 94vw; max-height: 94vh; object-fit: contain; }

.drop-overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 2rem; background: var(--accent-soft); color: var(--heading); font-size: 1.1rem; font-weight: 600; pointer-events: none; }
.drop-overlay[hidden] { display: none; }

/* One element per line of the model's plain text, never parsed as markup. */
.line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.line.heading, .line.name, .line .label { font-weight: 600; color: var(--heading); }
.line.heading:not(:first-child) { margin-top: 0.5rem; }
.line.gap { height: 0.75rem; }
.line a { color: var(--accent); }
.line strong { font-weight: 700; }

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.choice {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.choice:hover { background: var(--accent); color: #fff; }
.choice:disabled { opacity: 0.5; cursor: default; background: var(--surface); color: var(--accent); }

.deck-style-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.deck-style-card {
  position: relative;
  display: grid;
  width: min(178px, 100%);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
  color: var(--heading);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.deck-style-card:hover { border-color: var(--accent); box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 28%, transparent); }
.deck-style-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.deck-style-card:disabled { opacity: 0.55; cursor: default; }
.deck-style-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg); }
.deck-style-label { padding: 0.45rem 0.55rem; font-weight: 650; }

.message-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.35rem; }
/* The copy button's hidden status is absolutely placed; without a positioned parent it escapes
   the scrolling message list and a long conversation makes the whole page scroll. */
.message-actions { position: relative; display: flex; align-items: center; gap: 0.4rem; margin-top: 0.35rem; white-space: normal; }
.message-footer .message-actions { margin-top: 0; }
.message-copy { display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 6px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.message-copy:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.message-copy:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.message-copy:disabled { opacity: 0.5; cursor: wait; }
.message-copy svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.message-copy-status { font-size: 0.75rem; line-height: 1.4; overflow-wrap: anywhere; }
@media (pointer: coarse) {
  .message-copy { width: 44px; height: 44px; }
}

.message-time {
  flex: none;
  font-size: 0.75rem;
  color: var(--muted);
}

.message.user .choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.choice {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.choice:hover { background: var(--accent); color: #fff; }
.choice:disabled { opacity: 0.5; cursor: default; background: var(--surface); color: var(--accent); }

.message-time { text-align: right; }

.button.file {
  /* One button per line: the download and the edit link never sit side by side. */
  display: flex;
  width: fit-content;
  margin-top: 0.75rem;
  padding: 0.25rem 0.9rem;
}

.button.file.upload {
  width: 44px;
  height: 44px;
  margin-top: 0;
  padding: 0;
  display: grid;
  place-items: center;
}

.button.file.upload:disabled { opacity: 0.55; cursor: default; }
.button.file.upload svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.calendar-actions .button.file { margin-top: 0.75rem; }
.calendar-error { margin: 0.5rem 0 0; color: var(--accent); font-size: 0.875rem; }

.export-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.export-row .button.file { display: inline-flex; margin-top: 0; }
.export-drive { border: 1px solid var(--accent); background: var(--surface); color: var(--accent); }

/* /writer replies: the writer's text is plain text with its line breaks. */
.writer-prompt, .writer-notice, .writer-article { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.writer-notice { margin-bottom: 0.5rem; color: var(--muted); }
.writer-draft { margin-bottom: 0.75rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
.writer-title { margin: 0 0 0.6rem; color: var(--heading); font-size: 1.05rem; line-height: 1.35; }
.writer-info { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.8125rem; }
.writer-warning { margin-top: 0.35rem; color: var(--accent); font-size: 0.8125rem; white-space: pre-wrap; }
.writer-drive:not(:empty) { margin-top: 0.6rem; }
.writer-note { color: var(--accent); font-size: 0.8125rem; }
.writer-refusal { margin: 0.5rem 0 0; color: var(--accent); font-size: 0.875rem; }
.writer-opened { align-self: center; margin: 0; padding: 0.35rem 0.75rem; border-radius: 999px; background: var(--accent-soft); color: var(--heading); font-size: 0.8125rem; }
.writer-mark { width: 14px; height: 14px; flex: none; }

/* The "/" command menu sits above the composer. */
.slash-menu { margin-bottom: 0.5rem; }
.slash-menu[hidden] { display: none; }
/* A writer conversation takes no files. */
.composer .upload[hidden] { display: none; }
.slash-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 0.875rem; text-align: left; cursor: pointer; }
.slash-item:hover, .slash-item:focus { border-color: var(--accent); outline: none; }
.slash-item strong { color: var(--accent); }
.slash-item span { color: var(--muted); }
.export-error { flex-basis: 100%; margin: 0; color: var(--accent); font-size: 0.875rem; }

.composer-bar {
  flex: none;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 0.6rem;
  width: max-content;
  max-width: 100%;
}

.file-chip[hidden] { display: none; }

.file-chip-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex: none;
}

.file-chip-text {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer { display: flex; gap: 0.75rem; align-items: flex-end; }

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 9rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font: inherit;
  color: var(--text);
  line-height: 1.5;
}

.composer textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.send {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.send:disabled { opacity: 0.55; cursor: default; }
.send svg { width: 20px; height: 20px; fill: currentColor; }

/* On desktop the account row and the composer sit side by side: one height keeps their top
   lines level. 76px holds the composer's 45px textarea; a longer message still grows it. */
@media (min-width: 992px) {
  .panel-foot,
  .composer-bar { min-height: 76px; }
}

/* Sits in the stream where the answer will land, not over the composer. */
.spinner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  padding: 0.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* display:flex above would otherwise beat the hidden attribute. */
.spinner[hidden] { display: none; }

.dots { display: inline-flex; gap: 3px; }

.dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: wave 1.3s linear infinite;
}

.dots i:nth-child(2) { animation-delay: -1.1s; }
.dots i:nth-child(3) { animation-delay: -0.9s; }

@keyframes wave {
  0%, 60%, 100% { transform: none; }
  30% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .dots i { animation: none; }
}

/* -- icon button ----------------------------------------------------------- */

.icon-button {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  margin-left: -0.5rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover { background: var(--bg); color: var(--heading); }

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.phone-only { display: none; }

/* -- house deck editor ----------------------------------------------------- */

.editor {
  min-height: 100vh;
  color: var(--editor-text);
  background: var(--editor-page);
}

.editor-mark-link { color: var(--editor-muted); font-size: 0.75rem; text-decoration: none; white-space: nowrap; }
.editor-mark-link:hover { color: var(--editor-text); }
.editor-top .topbar-title { flex: 1; min-width: 0; }
.editor-page-count { flex: none; color: var(--editor-muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.editor-deck-settings { display: flex; flex: none; align-items: center; gap: 0.8rem; margin: 0 0.6rem; }
.editor-deck-settings label { display: flex; align-items: center; gap: 0.4rem; color: var(--editor-muted); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; white-space: nowrap; }
.editor-deck-settings select { min-height: 32px; padding: 0.3rem 1.6rem 0.3rem 0.6rem; border: 1px solid var(--editor-border); border-radius: 6px; background: var(--editor-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b8b8b' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 0.6rem center; color: var(--editor-text); font: inherit; font-size: 0.75rem; letter-spacing: 0; text-transform: none; appearance: none; cursor: pointer; }
.editor-deck-settings select:hover { border-color: var(--editor-muted); }
.editor-actions { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.editor-status { min-width: 7rem; color: var(--editor-muted); font-size: 0.75rem; text-align: right; white-space: nowrap; }
/* On a narrow top bar the Drive note shortens (full text in its tooltip) before a button is cut off. */
#deck-drive-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.editor-status.error { color: var(--editor-accent); }
/* Another colleague holds the deck: the notice takes a fixed band and the editor goes read-only. */
.editor-lock[hidden] { display: none; }
.editor-lock { display: flex; align-items: center; height: var(--lock-height, 2.25rem); margin: 0; padding: 0 1rem; background: var(--editor-accent); color: #fff; font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor.read-only .editor-workspace { height: calc(100vh - var(--head-height) - var(--lock-height, 2.25rem)); }
.editor.read-only .deck-form { opacity: 0.55; }
.editor-button { padding: 0.25rem 0.65rem; border: 1px solid var(--editor-border); background: var(--editor-field); color: var(--editor-text); font-size: 0.75rem; white-space: nowrap; }
.editor-button:hover { border-color: var(--editor-muted); background: var(--editor-field-hover); }
#save-deck { border-color: var(--editor-accent); background: var(--editor-accent); color: #fff; }
#save-deck:hover { background: #f27480; }
#present-deck { border-color: var(--editor-accent); color: var(--editor-accent); background: transparent; text-decoration: none; }
#present-deck:hover { background: var(--editor-accent-soft); }
.editor-button:disabled, .page-navigator button:disabled { cursor: default; opacity: 0.45; }
.editor-export { position: relative; }
.editor-share { position: relative; }
.editor-export-menu { position: absolute; z-index: 5; top: calc(100% + 0.4rem); right: 0; display: grid; min-width: 10rem; padding: 0.3rem; border: 1px solid var(--editor-border); border-radius: 8px; background: var(--editor-field); box-shadow: 0 12px 26px light-dark(rgb(15 34 58 / 14%), rgb(0 0 0 / 35%)); }
.editor-export-menu[hidden] { display: none; }
.editor-export-menu a { padding: 0.5rem 0.6rem; border-radius: 5px; color: var(--editor-text); font-size: 0.75rem; text-decoration: none; white-space: nowrap; }
.editor-export-menu a:hover { background: var(--editor-accent-soft); color: var(--editor-accent); }
.share-menu { width: 17rem; gap: 0.4rem; padding: 0.65rem; }
.share-menu button, .share-menu select, .share-menu input { border: 1px solid var(--editor-border); border-radius: 5px; background: var(--editor-panel); color: var(--editor-text); font: inherit; font-size: 0.75rem; }
.share-menu button { min-height: var(--button-height); padding: 0.25rem 0.55rem; cursor: pointer; }
.share-menu button:hover { border-color: var(--editor-accent); color: var(--editor-accent); }
.share-expiry, .share-url { display: grid; gap: 0.25rem; color: var(--editor-muted); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.share-menu select, .share-menu input { width: 100%; min-height: 30px; padding: 0.3rem 0.45rem; text-transform: none; letter-spacing: 0; }
.share-status { margin: 0; color: var(--editor-muted); font-size: 0.7rem; line-height: 1.35; }
.share-status.error { color: var(--editor-accent); }
.share-revoke { color: var(--editor-accent) !important; }

/* -- deck library --------------------------------------------------------- */

.library { min-height:100vh; background:var(--editor-page); color:var(--editor-text); }
/* The search box ends where the list's row lines end. */
.library-top { padding-right:max(1rem, calc((100% - 70rem) / 2)); }
.library-top .topbar-title { flex:1; min-width:0; }
.library-top .editor-status { min-width:0; }
.library-search { width:min(20rem, 35vw); min-height:32px; padding:0.35rem 0.6rem; border:1px solid var(--editor-border); border-radius:6px; background:var(--editor-field); color:var(--editor-text); font:inherit; font-size:0.75rem; }
.library-search:focus { border-color:var(--editor-accent); outline:0; }
.library-note { width:min(100% - 2rem, 70rem); margin:0.9rem auto 0; color:var(--editor-muted); font-size:0.75rem; text-align:right; }
.library-note a { color:var(--editor-text); }
.library-list { width:min(100% - 2rem, 70rem); margin:1.5rem auto; }
.library-row { display:grid; grid-template-columns:160px minmax(0, 1fr) auto; align-items:center; gap:1rem; padding:1rem; border-bottom:1px solid var(--editor-border); }
.library-row[hidden] { display:none; }
.library-row.new { outline:1px solid var(--editor-accent); background:rgb(236 96 110 / 8%); }
.library-thumbnail { width:160px; height:90px; overflow:hidden; background:var(--editor-field); }
.library-thumbnail img { display:block; width:100%; height:100%; object-fit:cover; }
.library-detail h2, .library-detail p { margin:0; }
.library-detail h2 { font-size:0.95rem; font-weight:650; }
.library-detail p { margin-top:0.3rem; color:var(--editor-muted); font-size:0.75rem; }
.library-shared { display:inline-block; margin-top:0.45rem; padding:0.18rem 0.42rem; border-radius:999px; background:rgb(236 96 110 / 16%); color:var(--tag-pdf); font-size:0.6875rem; }
.library-action-rows { display:flex; flex-direction:column; align-items:flex-end; gap:0.4rem; }
.library-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:0.4rem; }
.library-button { padding:0.25rem 0.65rem; border:1px solid var(--editor-border); background:var(--editor-field); color:var(--editor-text); font-size:0.75rem; text-decoration:none; white-space:nowrap; }
.library-button:hover { border-color:var(--editor-muted); background:var(--editor-field-hover); }
.library-button.disabled { pointer-events:none; opacity:.45; }
.library-empty { margin:3rem 1rem; color:var(--editor-muted); text-align:center; }
.library-empty p { margin:0 0 0.75rem; }
.document-row { grid-template-columns:56px minmax(0, 1fr) auto; }
.document-badge { display:grid; place-items:center; width:56px; height:40px; border-radius:6px; font-size:0.6875rem; font-weight:700; letter-spacing:0.04em; }
.document-badge.pdf { background:rgb(236 96 110 / 16%); color:var(--tag-pdf); }
.document-badge.word { background:rgb(66 133 244 / 16%); color:var(--tag-word); }

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

.settings-form { width:min(100% - 2rem, 44rem); margin:1.5rem auto 3rem; display:grid; gap:1.25rem; }
.settings-card { padding:1.25rem 1.5rem; border:1px solid var(--editor-border); border-radius:10px; background:var(--editor-panel); }
.settings-card h2 { margin:0; font-size:1rem; color:var(--editor-ink); }
.settings-hint { margin:0.4rem 0 1rem; color:var(--editor-muted); font-size:0.8125rem; line-height:1.45; }
.settings-field { display:grid; gap:0.35rem; margin-top:0.9rem; }
.settings-label { color:var(--editor-ink); font-size:0.8125rem; font-weight:600; }
.settings-field input, .settings-field select { padding:0.58rem 0.65rem; border:1px solid var(--editor-border); border-radius:6px; background:var(--editor-field); color:var(--editor-text); font:inherit; font-size:0.875rem; }
.settings-field input:focus, .settings-field select:focus { border-color:var(--editor-accent); outline:0; }
.settings-error { color:var(--editor-accent); font-size:0.75rem; line-height:1.35; }
.settings-actions { display:flex; justify-content:flex-end; }
.settings-actions .button { padding:0.25rem 1.4rem; }
.welcome { width:calc(100% - 2rem); max-width:32rem; margin:8vh auto; text-align:left; }
.welcome h1 { margin:0 0 1.5rem; font-size:1.35rem; }
.welcome h2 { margin:0; color:var(--heading); font-size:1rem; }
.welcome .settings-actions { flex-wrap:wrap; gap:0.75rem; margin-top:1.5rem; }
.welcome input { min-width:0; width:100%; }
.welcome .settings-field .settings-hint { margin:0; }
.group-choices { display:grid; gap:0.55rem; margin:1rem 0 0; padding:0; border:0; }
.group-choices legend { margin-bottom:0.35rem; padding:0; }
.group-choice { display:flex; align-items:center; gap:0.6rem; color:var(--editor-text); font-size:0.875rem; cursor:pointer; }
.group-choice input { width:auto; min-width:0; margin:0; accent-color:var(--editor-accent); }
.group-list { margin:0.5rem 0 1rem; padding:0; list-style:none; }
.group-row { display:flex; align-items:center; gap:0.75rem; min-height:2.5rem; padding:0.35rem 0; border-top:1px solid var(--editor-border); }
.group-row:first-child { border-top:0; }
.group-name { flex:1; min-width:0; color:var(--editor-text); font-size:0.875rem; }
.group-state { color:var(--editor-muted); font-size:0.75rem; white-space:nowrap; }
.group-row .group-choice { flex:1; }

/* -- System Admin groups page ----------------------------------------------- */

.admin-page { width:min(100% - 2rem, 56rem); margin:1.5rem auto 3rem; display:grid; gap:1.25rem; }
.admin-message { margin:0; padding:0.6rem 0.9rem; border:1px solid var(--editor-accent); border-radius:8px; background:rgb(236 96 110 / 8%); color:var(--editor-text); font-size:0.8125rem; }
.admin-list { margin:0.75rem 0 0; padding:0; list-style:none; }
.admin-row { display:flex; flex-wrap:wrap; align-items:center; gap:0.5rem 0.75rem; padding:0.65rem 0; border-top:1px solid var(--editor-border); }
.admin-row:first-child { border-top:0; }
.admin-row form { margin:0; }
.admin-row-main { flex:1 1 16rem; min-width:0; display:grid; gap:0.2rem; }
.admin-meta { color:var(--editor-muted); font-size:0.75rem; overflow-wrap:anywhere; }
.admin-inline { display:flex; align-items:center; gap:0.4rem; min-width:0; }
.admin-inline input, .admin-inline select { min-width:0; padding:0.3rem 0.5rem; border:1px solid var(--editor-border); border-radius:6px; background:var(--editor-field); color:var(--editor-text); font:inherit; font-size:0.8125rem; }
.admin-inline input:focus, .admin-inline select:focus { border-color:var(--editor-accent); outline:0; }
.admin-add { margin-top:0.75rem; }
.admin-add input { flex:1; }
.group-chips { display:flex; flex-wrap:wrap; gap:0.35rem; margin-top:0.25rem; }
.group-chip { display:inline-flex; align-items:center; gap:0.15rem; padding:0.1rem 0.15rem 0.1rem 0.55rem; border:1px solid var(--editor-border); border-radius:999px; color:var(--editor-text); font-size:0.75rem; }
.group-chip.pending { border-style:dashed; color:var(--editor-muted); }
.chip-remove { display:grid; place-items:center; width:1.4rem; height:1.4rem; padding:0; border:0; border-radius:50%; background:none; color:inherit; font-size:0.9rem; cursor:pointer; }
.chip-remove:hover { background:var(--editor-field-hover); }
/* Groups page: one row per person, a dialog of group checkboxes (Kit, 2026-10-16). */
.admin-tools { display:flex; flex-wrap:wrap; align-items:center; gap:0.5rem; }
.admin-tools select { min-height:32px; padding:0.3rem 0.5rem; border:1px solid var(--editor-border); border-radius:6px; background:var(--editor-field); color:var(--editor-text); font:inherit; font-size:0.75rem; }
.person-list { margin-top:0.5rem; }
.person-row { border-top:1px solid var(--editor-border); }
.person-row:first-child { border-top:0; }
.person-row[hidden] { display:none; }
.person-open { display:grid; grid-template-columns:minmax(0, 12rem) minmax(0, 16rem) minmax(0, 1fr); align-items:center; gap:0.75rem; width:100%; padding:0.5rem 0.4rem; border:0; border-radius:6px; background:none; color:var(--editor-text); font:inherit; text-align:left; cursor:pointer; }
.person-open:hover, .person-open:focus-visible { background:var(--editor-field-hover); outline:0; }
.person-name { overflow:hidden; font-size:0.875rem; text-overflow:ellipsis; white-space:nowrap; }
.person-email { overflow:hidden; color:var(--editor-muted); font-size:0.75rem; text-overflow:ellipsis; white-space:nowrap; }
.person-open .group-chips { margin-top:0; }
.person-open .group-chip { padding:0.1rem 0.55rem; }
.admin-dialog { width:min(94vw, 26rem); max-height:90vh; overflow-y:auto; padding:1.2rem; border:1px solid var(--editor-border); border-radius:10px; background:var(--editor-panel); color:var(--editor-text); box-shadow:0 18px 55px rgb(0 0 0 / 25%); }
.admin-dialog::backdrop { background:rgb(0 0 0 / 55%); }
.admin-dialog h2 { margin:0; font-size:1.05rem; color:var(--editor-ink); }
.admin-dialog-groups { display:grid; gap:0.15rem; margin:1rem 0; padding:0; border:0; }
.admin-check { display:flex; align-items:center; gap:0.55rem; padding:0.4rem 0.3rem; border-radius:6px; font-size:0.875rem; cursor:pointer; }
.admin-check:hover { background:var(--editor-field-hover); }
.admin-check .admin-meta { margin-left:auto; }
.admin-dialog-actions { display:flex; justify-content:flex-end; gap:0.5rem; }
.nav-badge { position:absolute; top:3px; right:3px; min-width:16px; height:16px; padding:0 4px; border-radius:8px; background:var(--accent); color:#fff; font-size:0.625rem; font-weight:700; line-height:16px; text-align:center; }
.nav-item .nav-badge { position:static; margin-left:auto; }
@media (max-width: 767.98px) {
  .admin-page { width:calc(100% - 1.5rem); }
  .admin-inline { flex:1 1 100%; }
  .admin-inline input, .admin-inline select { flex:1; }
  .person-open { grid-template-columns:minmax(0, 1fr); gap:0.2rem; }
  .admin-tools .library-search { order:0; width:100%; }
}
@media (max-width: 767.98px) {
  .settings-form { width:calc(100% - 1.5rem); }
  .settings-card { padding:1rem 1.1rem; }
}

/* The deck pages sit beside the rail and scroll on their own. */
.layout > .library, .layout > .editor { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; }

.editor-workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; height: calc(100vh - var(--head-height)); }
.editor-ai-panel { display: flex; min-width: 0; min-height: 0; flex-direction: column; padding: 1rem; border-right: 1px solid var(--editor-border); background: var(--editor-panel); }
.ai-messages { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 0.65rem; overflow-y: auto; padding: 0.1rem; }
.ai-message { max-width: 92%; padding: 0.6rem 0.7rem; border-radius: 9px; background: var(--editor-bubble); color: var(--editor-text); font-size: 0.8125rem; line-height: 1.45; white-space: pre-wrap; }
.ai-message.user { align-self: end; background: var(--editor-accent); color: #fff; }
.ai-message.assistant { align-self: start; }
.ai-message.error { background: var(--editor-accent-soft); color: var(--editor-accent); }
.ai-message-body { overflow-wrap: anywhere; }
.ai-message .message-copy { color: inherit; }
.ai-factcheck { width: 100%; }
.ai-factcheck p { margin: 0 0 0.4rem; }
.ai-factcheck p + p { color: var(--editor-muted); }
.ai-factcheck p:last-of-type { margin-bottom: 0; }
.ai-factcheck > button { display: block; width: 100%; margin-top: 0.45rem; padding: 0; border: 0; background: none; color: var(--editor-accent); font: inherit; line-height: inherit; text-align: left; text-decoration: underline; cursor: pointer; }
.ai-factcheck > button:hover, .ai-factcheck > button:focus-visible { color: var(--editor-ink); }
.fact-missing { text-decoration: underline dotted #ff6b6b 2px; background: rgb(255 107 107 / 14%); }
.ai-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.55rem; margin-top: 1rem; }
.ai-composer textarea { min-width: 0; min-height: 2.5rem; resize: vertical; border: 1px solid var(--editor-border); border-radius: 7px; background: var(--editor-panel); color: var(--editor-text); font: inherit; font-size: 0.8125rem; line-height: 1.35; padding: 0.55rem; }
.ai-composer textarea:focus { border-color: var(--editor-accent); outline: 0; }
.ai-composer textarea:disabled { opacity: 0.55; }
.ai-composer .button { align-self: end; padding: 0.25rem 0.7rem; }
.editor-preview-column { display: flex; min-width: 0; min-height: 0; flex-direction: column; padding: 1.25rem; background: var(--editor-page); }
.editor-stage { display: grid; min-height: 0; flex: 1; place-items: center; }
.preview-scale { position: relative; overflow: hidden; border-radius: 12px; background: #050505; box-shadow: 0 20px 50px light-dark(rgb(15 34 58 / 16%), rgb(0 0 0 / 38%)); }
.preview-scale iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; background: #fff; transform-origin: top left; }
.filmstrip-heading { display: flex; justify-content: space-between; margin-top: 0.8rem; color: var(--editor-muted); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; }
.filmstrip-heading span { color: var(--editor-text); }
.page-navigator { display: flex; align-items: center; align-self: center; gap: 0.4rem; margin-top: 1rem; padding: 0.28rem 0.4rem; border: 1px solid var(--editor-border); border-radius: 999px; background: var(--editor-panel); box-shadow: 0 8px 20px light-dark(rgb(15 34 58 / 10%), rgb(0 0 0 / 25%)); color: var(--editor-text); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.page-navigator button { width: 1.5rem; height: 1.5rem; border: 0; border-radius: 50%; background: transparent; color: var(--editor-text); cursor: pointer; font: inherit; font-size: 1.25rem; line-height: 1; }
.page-navigator button:not(:disabled):hover { background: var(--editor-accent-soft); color: var(--editor-accent); }

.page-strip { display: flex; flex: none; gap: 0.65rem; overflow-x: auto; padding: 0.5rem 0.1rem 0.1rem; scroll-snap-type: x proximity; }
.page-tab { position: relative; display: block; width: 160px; flex: 0 0 160px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 8px; background: #050505; cursor: pointer; scroll-snap-align: center; }
.page-tab:hover { border-color: var(--editor-muted); }
.page-tab.selected { border-color: var(--editor-accent); box-shadow: 0 0 0 2px var(--editor-accent-soft); }
.page-thumbnail { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #050505; }
.page-thumbnail iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; pointer-events: none; transform: scale(0.0833334); transform-origin: top left; }
.page-badge { position: absolute; top: 0.35rem; left: 0.35rem; padding: 0.16rem 0.28rem; border-radius: 999px; background: rgb(14 14 14 / 88%); color: #e8e8e8; font-size: 0.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.editor-form-column { display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow-y: auto; border-left: 1px solid var(--editor-border); background: var(--editor-panel); }
.deck-form { width: min(100%, 28rem); margin: 0 auto; padding: 1.5rem; }
.deck-form-heading { margin-bottom: 1.4rem; padding-bottom: 1rem; border-bottom: 1px solid var(--editor-border); }
.deck-form h2, .deck-form-heading p { margin: 0; }
.deck-form h2 { color: var(--editor-text); font-size: 0.75rem; font-weight: 650; letter-spacing: 0.12em; line-height: 1.5; text-transform: uppercase; }
.deck-form-heading p { margin-top: 0.25rem; color: var(--editor-muted); font-size: 0.75rem; }
.deck-form-hint { margin: 0 0 1.25rem; color: var(--editor-muted); font-size: 0.75rem; line-height: 1.45; }
.deck-page-style { margin: 0 0 1.4rem; }
.deck-page-style > legend { margin-bottom: 0.75rem; color: var(--editor-text); }
.deck-segmented-field { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 0.7rem; }
.deck-segmented-field > span { color: var(--editor-muted); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; }
.deck-segmented { display: flex; flex: none; overflow: hidden; border: 1px solid var(--editor-border); border-radius: 6px; }
/* The group's 1px border makes up the rest of the button height. */
.deck-segment { min-width: 2.35rem; min-height: calc(var(--button-height) - 2px); padding: 0.25rem 0.6rem; border: 0; border-left: 1px solid var(--editor-border); background: var(--editor-panel); color: var(--editor-muted); font: inherit; font-size: 0.75rem; cursor: pointer; }
.deck-segment:first-child { border-left: 0; }
.deck-segment:hover { background: var(--editor-field-hover); color: var(--editor-text); }
.deck-segment[aria-pressed="true"] { background: var(--editor-accent); color: #fff; }
.deck-page-style .deck-check { margin: 0.7rem 0; }
.deck-photo .deck-form-hint { margin: 0.6rem 0 0; }
/* The panel's buttons are outlined in the accent colour, so they stand out against the panel. */
.deck-form .editor-button { border-color: var(--editor-accent); color: var(--editor-accent); }
.deck-form .editor-button:hover { border-color: var(--editor-accent); background: var(--editor-accent-soft); }
.deck-text-boxes > .editor-button { margin: 0 0 0.9rem; }
.deck-text-boxes > .editor-button:last-child { margin: 0.2rem 0 0; }
.deck-text-boxes select { min-height: 32px; padding: 0.3rem 0.6rem; border: 1px solid var(--editor-border); border-radius: 6px; background: var(--editor-field); color: var(--editor-text); font: inherit; font-size: 0.75rem; letter-spacing: 0; text-transform: none; cursor: pointer; }
.text-box-swatches { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; }
.text-box-swatch { width: 1.6rem; height: 1.6rem; padding: 0; border: 1px solid var(--editor-muted); border-radius: 50%; background: var(--swatch); cursor: pointer; }
.text-box-swatch.auto { background: var(--editor-field); color: var(--editor-muted); font: inherit; font-size: 0.65rem; font-weight: 700; }
.text-box-swatch[aria-pressed="true"] { outline: 2px solid var(--editor-accent); outline-offset: 2px; }
.deck-range { display:grid; grid-template-columns:1fr auto; gap:0.35rem 0.75rem; align-items:center; margin:0 0 1.1rem; color:var(--editor-muted); font-size:0.6875rem; font-weight:650; letter-spacing:.11em; text-transform:uppercase; }
.deck-range input { grid-column:1 / -1; width:100%; height:0.9rem; margin:0; padding:0; appearance:none; border:0; border-radius:999px; background:linear-gradient(to right,var(--editor-accent) 0 var(--range-fill),var(--editor-border) var(--range-fill) 100%); cursor:pointer; }
.deck-range input::-webkit-slider-thumb { width:1rem; height:1rem; appearance:none; border:2px solid var(--editor-accent); border-radius:50%; background:#fff; box-shadow:0 1px 4px rgb(0 0 0 / 35%); }
.deck-range input::-moz-range-thumb { width:0.8rem; height:0.8rem; border:2px solid var(--editor-accent); border-radius:50%; background:#fff; box-shadow:0 1px 4px rgb(0 0 0 / 35%); }
.deck-range input:focus-visible { outline:2px solid var(--editor-accent-soft); outline-offset:3px; }
.deck-range-value { color:var(--editor-text); font-size:0.8125rem; letter-spacing:0; }
.deck-range-ticks { display:flex; grid-column:1 / -1; justify-content:space-between; color:var(--editor-muted); font-size:0.625rem; font-variant-numeric:tabular-nums; letter-spacing:0; }
.deck-range-ticks > span { position:relative; padding-top:0.28rem; }
.deck-range-ticks > span::before { position:absolute; top:-0.18rem; left:50%; width:1px; height:0.25rem; background:var(--editor-muted); content:""; }
.deck-field { display: block; margin: 0 0 0.9rem; }
.deck-field > span, .deck-array h3, .deck-form fieldset > legend { display: block; margin-bottom: 0.35rem; color: var(--editor-muted); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; }
.deck-field input, .deck-field textarea, .deck-field select { display: block; width: 100%; padding: 0.58rem 0.65rem; border: 1px solid var(--editor-border); border-radius: 6px; background: var(--editor-panel); color: var(--editor-text); font: inherit; font-size: 0.8125rem; line-height: 1.4; }
.deck-field textarea { resize: vertical; }
.deck-field input:focus, .deck-field textarea:focus, .deck-field select:focus { border-color: var(--editor-accent); outline: 2px solid var(--editor-accent-soft); }
.deck-field input:disabled { color: var(--editor-muted); cursor: default; }
.deck-check { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0.85rem 0; color: var(--editor-muted); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; }
.deck-check input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.deck-switch { position: relative; width: 2.4rem; height: 1.35rem; border: 1px solid var(--editor-border); border-radius: 999px; background: var(--editor-page); transition: background 120ms ease, border-color 120ms ease; }
.deck-switch::after { position: absolute; top: 0.17rem; left: 0.17rem; width: 0.88rem; height: 0.88rem; border-radius: 50%; background: var(--editor-muted); content: ""; transition: transform 120ms ease, background 120ms ease; }
.deck-check input:checked + .deck-switch { border-color: var(--editor-accent); background: var(--editor-accent); }
.deck-check input:checked + .deck-switch::after { background: #fff; transform: translateX(1rem); }
.deck-check input:focus-visible + .deck-switch { outline: 2px solid var(--editor-accent-soft); outline-offset: 2px; }
.deck-array { margin: 1.4rem 0; padding-top: 0.2rem; }
.deck-array h3 { margin: 0 0 0.7rem; }
.deck-option { margin: 0 0 0.45rem; padding: 0.55rem 0.65rem; border: 1px solid var(--editor-border); border-radius: 8px; }
.deck-option-label { margin: 0 0 0.35rem; overflow: hidden; color: var(--editor-muted); font-size: 0.8125rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.deck-option .deck-field { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.35rem 0; }
.deck-option .deck-field > span { margin: 0; }
.deck-option .deck-field select { width: auto; min-width: 6.25rem; padding: 0.4rem 0.5rem; }
.deck-option .deck-check { margin: 0.45rem 0; }
.deck-array-row { display: flex; align-items: end; gap: 0.5rem; }
.deck-array-row .deck-field { flex: 1; }
.deck-form fieldset { min-width: 0; margin: 1.25rem 0; padding: 1.1rem 0 0; border: 0; border-top: 1px solid var(--editor-border); }
/* Floated, the legend sits below the dividing line and lines up with the other labels. */
.deck-form fieldset > legend { float: left; width: 100%; padding: 0; }
.deck-form fieldset > legend + * { clear: both; }
.editor-footer { margin-top: auto; padding: 1rem 1.5rem; border-top: 1px solid var(--editor-border); color: var(--editor-muted); font-size: 0.6875rem; letter-spacing: 0.05em; }

/* -- house deck presenter -------------------------------------------------- */

.present { --surface:#242424; --line:#343434; --heading:#f5f5f5; --logo-ink:#ffffff; position: fixed; inset: 0; overflow: hidden; background: #000; }
.present iframe { position: absolute; top: 50%; left: 50%; width: 1920px; height: 1080px; border: 0; pointer-events: none; transform-origin: center; }
.present-counter { position: absolute; right: 1.25rem; bottom: 1rem; padding: 0.35rem 0.5rem; border-radius: 4px; background: rgb(0 0 0 / 58%); color: #fff; font-size: 0.75rem; font-variant-numeric: tabular-nums; letter-spacing: 0.08em; opacity: 1; transition: opacity 300ms ease; }
.present-counter.hidden { opacity: 0; }
.share-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 1; justify-content: space-between; background: linear-gradient(rgb(0 0 0 / 72%), transparent); color: #fff; border-bottom: 0; opacity: 1; transition: opacity 300ms ease; }
.share-bar.hidden { opacity: 0; pointer-events: none; }
.share-bar .logo { width: 31px; }
.share-title { flex: 1; min-width: 0; }
.share-controls { display: flex; flex: none; align-items: center; gap: 0.45rem; }
.share-controls button, .share-controls a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--button-height); padding: 0.25rem 0.5rem; border: 1px solid rgb(255 255 255 / 40%); border-radius: 4px; background: rgb(0 0 0 / 38%); color: #fff; font: inherit; font-size: 0.75rem; text-decoration: none; cursor: pointer; }
.share-controls button:hover, .share-controls a:hover { background: rgb(255 255 255 / 18%); }
.share-controls .present-counter { position: static; padding: 0.25rem 0; background: none; }

/* -- navigation drawer ----------------------------------------------------- */

/* Below 992px the rail gives way to this list: inside the chat drawer, or in a drawer of its
   own that the other pages open from the ☰ in their top bar. The styles are in the block below. */
.drawer-nav, .nav-drawer, .nav-scrim, .nav-today { display: none; }

/* -- phones ---------------------------------------------------------------- */

@media (max-width: 991.98px) {
  :root { --head-height: 60px; --button-height: 44px; }

  .phone-only { display: grid; }

  .layout { height: 100dvh; }

  /* No bottom bar: every destination is in the drawer. */
  .rail { display: none; }
  /* Phones and tablets cannot drop files here; the attach button uploads instead. */
  .drop-overlay { display: none; }

  .panel {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    width: auto;
    border-right: none;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    /* A short screen (a phone on its side) scrolls the drawer, not squeezes the conversations away. */
    overflow-y: auto;
  }

  .panel.open { transform: none; }
  .panel .conversations { min-height: 8rem; }

  .today {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    width: min(300px, 88vw);
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }

  .today.open { transform: none; }

  .layout > .library, .layout > .editor { padding-bottom: env(safe-area-inset-bottom); }
  .editor-workspace { height: calc(100dvh - var(--head-height)); }

  .chat { height: 100%; }

  /* No hover on a touch screen: the row actions are always there. */
  .row-actions { display: flex; }

  .chat-floating-head { padding: 0.5rem 1rem; }
  .chat-floating-head .icon-button { min-width: 44px; min-height: 44px; }
  .chat-title-menu { max-width: calc(100% - 48px); }
  .chat-title-trigger { min-height: 44px; }
  .chat-title-actions button { min-height: 44px; }
  .messages { padding: 5.25rem 1rem 1rem; scroll-padding-top: 5.25rem; gap: 0.75rem; }
  .message { max-width: 90%; }
  .deck-style-options { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.2rem; }
  .deck-style-card { flex: 0 0 172px; }
  .composer-bar { padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom)); }

  .drawer-nav { display: block; flex: none; padding: 0.5rem 0.75rem; border-top: 1px solid var(--line); }
  .drawer-nav ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
  /* Beside the conversations the list is a compact two-column grid. */
  .panel .drawer-nav ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-item {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.75rem;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
  }
  .nav-item:hover { background: var(--bg); color: var(--heading); }
  .nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-item svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .nav-item svg.brand-mark-icon { fill: currentColor; stroke: none; }
  .panel-foot { padding-bottom: calc(0.9rem + env(safe-area-inset-bottom)); }

  /* The other pages' drawer: closed it is out of the tab order as well as off screen. */
  .nav-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(var(--panel-width), 88vw);
    background: var(--panel);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s 0.25s;
  }
  .nav-drawer.open { transform: none; visibility: visible; transition: transform 0.25s ease; }
  .nav-drawer .drawer-nav { flex: 1; overflow-y: auto; border-top: none; }
  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgb(0 0 0 / 45%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0s 0.25s;
  }
  .nav-scrim.open { opacity: 1; visibility: visible; transition: opacity 0.25s ease; }
  .topbar .nav-toggle { width: 44px; height: 44px; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .today-head .tablet-only { display: grid; }
  .nav-today { display: block; }
}

@media (max-width: 767.98px) {
  .today { display: none; }
  .editor-top, .library-top { height: auto; min-height: 56px; flex-wrap: wrap; padding: 0.65rem 0.75rem; }
  .share-bar { padding: 0 0.75rem; }
  .library-search { order: 2; width: 100%; }
  .library-top .editor-status { order: 3; flex-basis: 100%; text-align: left; }
  .library-note { width: calc(100% - 1.5rem); margin-top: 0.6rem; text-align: left; }
  .library-list { width: calc(100% - 1.5rem); margin: 0.75rem auto; }
  .library-row { grid-template-columns:1fr; align-items: flex-start; }
  .library-actions { justify-content: flex-start; }
  .library-action-rows { align-items: flex-start; }
  .document-row { grid-template-columns: 56px minmax(0, 1fr); align-items: center; }
  .document-row .library-actions { grid-column: 1 / -1; }
  .editor-top { gap: 0.6rem; }
  .editor-top .topbar-title { order: 1; flex: 1 1 auto; max-width: calc(100% - 4.8rem); }
  .editor-page-count { order: 1; }
  .editor-deck-settings { order: 2; width: 100%; margin: 0; }
  .editor-actions { order: 2; width: 100%; flex-wrap: wrap; }
  .editor-status { flex: 1 0 100%; min-width: 0; text-align: left; }
  .editor-workspace { display: flex; height: auto; min-height: 0; flex-direction: column; }
  .editor-preview-column { order: 1; padding: 0.75rem; }
  .editor-stage { min-height: 0; flex: none; }
  .filmstrip-heading { margin-top: 0.75rem; }
  .page-navigator { margin-top: 0.75rem; }
  .page-strip { gap: 0.55rem; padding: 0.5rem 0.1rem 0.1rem; }
  .page-tab { width: 7.5rem; flex-basis: 7.5rem; }
  .page-thumbnail iframe { transform: scale(0.0625); }
  .editor-ai-panel { order: 2; min-height: 16rem; border-top: 1px solid var(--editor-border); border-right: 0; }
  .editor-form-column { order: 3; overflow: visible; border-left: 0; border-top: 1px solid var(--editor-border); }
  .deck-form { padding: 1.25rem 0.75rem; }
  .editor-footer { padding: 1rem 0.75rem; }
  .share-bar { align-items: flex-start; padding: 0.65rem 0.75rem; }
  .share-title { max-width: 42vw; }
  .share-controls { gap: 0.25rem; }
}

/* The line a finished action shows (app/done.py, rail.js). */
.done-line {
  margin: 6px 0 0;
  color: var(--done);
  font-size: 13px;
  line-height: 1.4;
}
.done-top {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 6px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.done-top .done-line {
  margin: 0;
}
.done-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
}
