/* Laptop sizes. Loaded last so it can retune the other files.
   Tiers by width: narrow 1024–1279, standard 1280–1679, then the whole interface scales up (110–180%); short screens ≤ 820px tall.
   Column widths come from four variables, so each tier only changes numbers. Phone rules (≤ 640px) stay in the other files. */
:root { --side-w: 296px; --src-w: 344px; --read-w: 760px; --gutter: 24px; }

/* The composer never grows wider than its box (the Send button used to stick out on narrow screens). */
.composer { grid-template-columns: minmax(0, 1fr); }

/* Columns follow the variables. */
[data-view="chat"] { grid-template-columns: auto minmax(0, 1fr) var(--src-w); }
[data-view="chat"] > aside.drawer, [data-view="welcome"] > aside.drawer { width: var(--side-w); }
[data-view="chat"][data-side="closed"] > aside.drawer, [data-view="welcome"][data-side="closed"] > aside.drawer { margin-left: calc(-1 * var(--side-w)); }
.thread { width: min(var(--read-w), 100% - 2 * var(--gutter)); }
[data-view="chat"] > .dock-chat { padding: 4px var(--gutter) 12px; }
.dock-chat .composer { width: min(var(--read-w) + 40px, 100%); }

/* Standard laptops (1280–1439): slimmer side columns. */
@media (min-width: 641px) and (max-width: 1439px) {
  :root { --side-w: 272px; --src-w: 312px; }
  /* The type tag sits above the source name so the name keeps the full card width. */
  .sc-line { flex-direction: column; align-items: flex-start; gap: 3px; }
  .sc-tag { order: -1; }
}

/* Narrow laptops (1024–1279). */
@media (min-width: 641px) and (max-width: 1279px) {
  :root { --side-w: 256px; --src-w: 288px; --read-w: 720px; --gutter: 20px; }
  .top { padding: 0 16px; }
  .stage { width: calc(100% - 48px); }
  .stage { gap: 32px; }
  .sc { padding: 10px; gap: 8px; }
}

/* Below 1200px with the history column open, the welcome screen stacks: heading and box first, suggestions under it. */
@media (min-width: 641px) and (max-width: 1199px) {
  [data-side="open"] .stage { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 28px; }
  [data-side="open"] .sugs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Large screens: scale the whole interface instead of the type alone, so text, spacing and controls grow together.
   The body is shrunk by the same factor so a full-height layout still fits the window exactly. */
:root { --z: 1; }
@media (min-width: 1680px) { :root { --z: 1.1; } }
@media (min-width: 1900px) { :root { --z: 1.2; } }
@media (min-width: 2300px) { :root { --z: 1.4; } }
@media (min-width: 3200px) { :root { --z: 1.8; } }
body { zoom: var(--z); height: calc(100dvh / var(--z)); }

/* Short screens (≤ 820px tall, e.g. 1366 × 768, 1280 × 720): give the history list the room.
   The contact box becomes one row of icon buttons; their names stay for screen readers and show on hover. */
@media (min-width: 641px) and (max-height: 820px) {
  .foot-links { display: flex; padding: 3px; }
  .foot-links a, .foot-links button { flex: 1; justify-content: center; height: 30px; padding: 0; }
  .foot-links span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tools-box { gap: 6px; padding: 8px 10px 10px 8px; }
  .tool { min-height: 36px; padding: 5px 12px; }
}
@media (min-width: 641px) and (max-height: 740px) {
  .top { min-height: 60px; }
  [data-view="welcome"] > aside.drawer, [data-view="chat"] > aside.drawer { padding-top: 12px; }
}

/* From the live page (18/11): phones and tablets (≤ 1023px). The history column opens over the chat, with the backdrop
   behind it (a tap on the backdrop closes it), never beside it: beside it, the chat was squeezed to 64px on a 360px phone. */
@media (max-width: 1023px) {
  /* !important: the layout rules of chat.css / msg.css / hist.css pin the column in the grid with stronger selectors. */
  body[data-side] > aside.drawer { position: fixed !important; inset: 0 auto 0 0 !important; z-index: var(--z-modal) !important; width: min(330px, 88vw) !important; overflow-y: auto; }
  body[data-side="open"] > aside.drawer { margin-left: 0 !important; transform: none !important; visibility: visible !important; }
  body[data-side="closed"] > aside.drawer { margin-left: 0 !important; transform: translateX(-102%) !important; visibility: hidden !important; }
  body[data-side="open"] > .backdrop { opacity: 1; visibility: visible; }
}
