/* NBAPC Assistant
   Colours are taken from the NBAPC mark: orange #F28921, brown #4F3B2C, white, black.
   Bricolage Grotesque carries headings; Atkinson Hyperlegible Next carries everything read at length. */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/vendor/fonts/bricolage/bricolage-grotesque-latin-opsz-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Next';
  src: url('/vendor/fonts/atkinson/atkinson-hyperlegible-next-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Next';
  src: url('/vendor/fonts/atkinson/atkinson-hyperlegible-next-latin-wght-italic.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --orange: #f28921;
  --orange-press: #dd7610;
  --brown: #4f3b2c;
  --brown-deep: #36271c;
  --black: #000;
  --white: #fff;

  --page: #fff;
  --surface: #f7f2ee;
  --surface-strong: #efe6df;
  --line: #e3d7cd;
  --line-strong: #b9a595;
  --text: #000;
  --text-soft: #5c4a3d;
  --accent-text: #9a4f06;
  --bubble: var(--brown);
  --bubble-text: #fff;
  --side: var(--brown);
  --side-raised: #5f4937;
  --side-line: #6b5443;
  --side-text: #fff;
  --side-soft: #dccabb;
  --danger: #a3261c;
  --focus: #000;
  --shadow: 0 10px 30px rgb(54 39 28 / 0.16);

  --display: 'Bricolage Grotesque', 'Atkinson Next', system-ui, sans-serif;
  --body: 'Atkinson Next', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, monospace;

  --measure: 46rem;
  --side-width: 18.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --page: #000;
    --surface: #1d150f;
    --surface-strong: #2b2018;
    --line: #3a2c21;
    --line-strong: #6b5443;
    --text: #fff;
    --text-soft: #cdb9a8;
    --accent-text: #f7a552;
    --bubble: #4f3b2c;
    --side: #17100b;
    --side-raised: #2b2018;
    --side-line: #3a2c21;
    --danger: #ff8a7d;
    --focus: #fff;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --page: #000;
  --surface: #1d150f;
  --surface-strong: #2b2018;
  --line: #3a2c21;
  --line-strong: #6b5443;
  --text: #fff;
  --text-soft: #cdb9a8;
  --accent-text: #f7a552;
  --bubble: #4f3b2c;
  --side: #17100b;
  --side-raised: #2b2018;
  --side-line: #3a2c21;
  --danger: #ff8a7d;
  --focus: #fff;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  height: 100%;
  background: var(--page);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent-text); text-underline-offset: 0.18em; }
ul, ol { margin: 0; padding: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sidebar :focus-visible, .login-art :focus-visible { outline-color: var(--orange); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 0.75rem; top: -4rem; z-index: 50;
  background: var(--orange); color: #000; padding: 0.6rem 1rem; border-radius: 0.5rem; font-weight: 600;
}
.skip-link:focus { top: 0.75rem; }

/* Buttons ---------------------------------------------------------------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0 1.15rem;
  border: 1.5px solid transparent; border-radius: 999px;
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.button.small { min-height: 2.25rem; padding: 0 0.9rem; font-size: 0.9375rem; }
.button.primary { background: var(--orange); color: #000; }
.button.primary:hover { background: var(--orange-press); }
.button.quiet { background: transparent; border-color: var(--line-strong); color: var(--text); }
.button.quiet:hover:not(:disabled) { background: var(--surface); }
.button.danger { background: var(--danger); color: var(--page); }
.button:disabled { opacity: 0.45; }

.icon-button {
  display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-soft);
}
.icon-button:hover { background: var(--surface-strong); color: var(--text); }
.icon-button.on-dark { color: var(--side-soft); }
.icon-button.on-dark:hover { background: var(--side-raised); color: #fff; }

/* App frame -------------------------------------------------------------- */

body.app { display: grid; grid-template-columns: var(--side-width) minmax(0, 1fr); overflow: hidden; }
body.app.files-open { grid-template-columns: var(--side-width) minmax(0, 1fr) 21rem; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0; height: 100dvh;
  background: var(--side); color: var(--side-text);
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 1.1rem 1rem 0.9rem 1.1rem; }
.brand img { border-radius: 50%; flex: none; }
.brand-name { font: 700 1.2rem/1.1 var(--display); letter-spacing: -0.015em; flex: 1; }
.sidebar-close { display: none; }

.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin: 0.25rem 1rem 0.9rem; min-height: 2.9rem;
  border: 0; border-radius: 999px; background: var(--orange); color: #000; font-weight: 700;
}
.new-chat:hover { background: #ff9c38; }

.search { display: block; margin: 0 1rem 0.5rem; }
.search input {
  width: 100%; min-height: 2.5rem; padding: 0 0.9rem;
  border: 1.5px solid var(--side-line); border-radius: 0.6rem;
  background: transparent; color: #fff; font-size: 0.9375rem;
}
.search input::placeholder { color: var(--side-soft); opacity: 1; }
.search input:focus { border-color: var(--orange); outline: none; }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0.25rem 0.6rem 1rem; scrollbar-color: var(--side-line) transparent; }
.chat-list ul { list-style: none; }
.chat-group { font: 600 0.8125rem/1 var(--body); color: var(--side-soft); padding: 1.1rem 0.6rem 0.5rem; letter-spacing: 0; }
.chat-list-empty { color: var(--side-soft); font-size: 0.9375rem; padding: 1rem 0.6rem; line-height: 1.45; }

.chat-item { position: relative; display: flex; align-items: center; border-radius: 0.6rem; }
.chat-item a {
  flex: 1; min-width: 0; padding: 0.55rem 0.6rem; border-radius: 0.6rem;
  color: #fff; text-decoration: none; font-size: 0.9688rem; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item:hover, .chat-item:focus-within { background: var(--side-raised); }
.chat-item.active { background: var(--side-raised); box-shadow: inset 3px 0 0 var(--orange); }
.chat-item.active a { font-weight: 600; }
.chat-item-actions { display: none; padding-right: 0.25rem; }
.chat-item:hover .chat-item-actions, .chat-item:focus-within .chat-item-actions, .chat-item.active .chat-item-actions { display: flex; }
.chat-item-actions button {
  display: grid; place-items: center; width: 2rem; height: 2rem;
  border: 0; border-radius: 0.45rem; background: transparent; color: var(--side-soft);
}
.chat-item-actions button:hover { background: var(--side); color: var(--orange); }

.account { position: relative; padding: 0.6rem; border-top: 1px solid var(--side-line); }
.account-button {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; padding: 0.5rem;
  border: 0; border-radius: 0.7rem; background: transparent; color: #fff; text-align: left;
}
.account-button:hover { background: var(--side-raised); }
.avatar {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem; flex: none;
  border-radius: 50%; background: #fff; color: var(--brown); font: 700 0.9rem/1 var(--display);
}
.account-text { display: grid; min-width: 0; line-height: 1.25; }
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-email { font-size: 0.8438rem; color: var(--side-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu {
  position: absolute; z-index: 30; min-width: 14rem; padding: 0.35rem;
  background: var(--page); color: var(--text); border: 1px solid var(--line); border-radius: 0.8rem; box-shadow: var(--shadow);
}
.account-menu { left: 0.6rem; right: 0.6rem; bottom: calc(100% - 0.2rem); }
.menu button {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 2.6rem; padding: 0 0.7rem;
  border: 0; border-radius: 0.5rem; background: transparent; text-align: left;
}
.menu button:hover { background: var(--surface-strong); }

.scrim { position: fixed; inset: 0; z-index: 19; background: rgb(0 0 0 / 0.5); }

/* Main column ------------------------------------------------------------ */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 0.5rem; min-height: 3.75rem; padding: 0.4rem 1.25rem; flex: none; }
.sidebar-open { display: none; }
.chat-title {
  flex: 1; min-width: 0; font: 600 1.0625rem/1.3 var(--display);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.files-button { min-height: 2.4rem; padding: 0 0.9rem; font-size: 0.9375rem; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; padding: 0.5rem 1.25rem 1.5rem; scroll-behavior: auto; }

/* Welcome ---------------------------------------------------------------- */

.welcome { max-width: var(--measure); margin: 0 auto; padding: clamp(1.5rem, 9vh, 6rem) 0 1rem; }
.welcome-ring { width: clamp(7rem, 16vw, 10.5rem); margin-bottom: 1.75rem; }
.welcome-ring img { display: block; width: 100%; height: auto; }
.welcome-title { font-size: clamp(2.4rem, 5.2vw, 4rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.04; }
.welcome-sub { margin-top: 0.9rem; font-size: 1.1875rem; color: var(--text-soft); max-width: 34rem; }
.starters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }
.starter {
  min-height: 2.75rem; padding: 0 1.1rem;
  border: 1.5px solid var(--brown); border-radius: 999px; background: transparent; color: var(--text); font-weight: 600;
}
:root[data-theme='dark'] .starter { border-color: var(--line-strong); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .starter { border-color: var(--line-strong); } }
.starter:hover { background: var(--orange); border-color: var(--orange); color: #000; }

/* Thread ----------------------------------------------------------------- */

.thread { max-width: var(--measure); margin: 0 auto; display: flex; flex-direction: column; gap: 1.75rem; }
.msg { min-width: 0; }
.msg.user { align-self: flex-end; max-width: min(85%, 36rem); display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; }
.bubble {
  padding: 0.75rem 1.1rem; border-radius: 1.3rem 1.3rem 0.35rem 1.3rem;
  background: var(--bubble); color: var(--bubble-text);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.sent-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.thumb img { display: block; max-width: 13rem; max-height: 11rem; border-radius: 0.9rem; border: 1px solid var(--line); }
.sent-file {
  display: inline-flex; align-items: center; gap: 0.5rem; max-width: 18rem; padding: 0.5rem 0.85rem;
  border: 1.5px solid var(--line-strong); border-radius: 0.8rem; color: var(--text); text-decoration: none; font-size: 0.9375rem;
}
.sent-file span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sent-file span:first-child { display: grid; color: var(--accent-text); }
.sent-file:hover { background: var(--surface); }

.msg.assistant { align-self: stretch; }

.status { display: flex; align-items: center; gap: 0.6rem; color: var(--text-soft); font-weight: 500; min-height: 1.8rem; }
.ring-indicator circle { fill: var(--orange); opacity: 0.25; animation: handoff 1.4s linear infinite; }
@keyframes handoff {
  0%, 100% { opacity: 0.25; }
  12% { opacity: 1; }
  40% { opacity: 0.25; }
}

/* Prose ------------------------------------------------------------------ */

.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose .table-wrap { margin: 0 0 1rem; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.75rem 0 0.6rem; font-family: var(--display); letter-spacing: -0.015em; line-height: 1.2; }
.prose h1 { font-size: 1.625rem; }
.prose h2 { font-size: 1.375rem; }
.prose h3 { font-size: 1.1875rem; }
.prose h4 { font-size: 1.0625rem; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: 0.3rem 0; }
.prose li::marker { color: var(--accent-text); font-weight: 600; }
.prose blockquote { padding: 0.1rem 0 0.1rem 1rem; border-left: 1px solid var(--line-strong); color: var(--text-soft); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.prose img { max-width: 100%; border-radius: 0.6rem; }
.prose code { font: 0.9em var(--mono); background: var(--surface-strong); padding: 0.12em 0.38em; border-radius: 0.3rem; }
.prose pre {
  background: var(--brown-deep); color: #f6ece4; border-radius: 0.8rem; overflow: hidden;
  font: 0.875rem/1.6 var(--mono);
}
:root[data-theme='dark'] .prose pre { background: var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .prose pre { background: var(--surface); } }
.prose pre code { display: block; background: none; padding: 0.9rem 1rem 1rem; overflow-x: auto; font-size: 1em; border-radius: 0; }
.code-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.3rem 0.4rem 0.3rem 1rem; background: rgb(255 255 255 / 0.08); color: #dccabb; font: 0.8125rem var(--body);
}
.copy-code {
  display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2rem; padding: 0 0.6rem;
  border: 0; border-radius: 0.4rem; background: transparent; color: inherit;
}
.copy-code:hover { background: rgb(255 255 255 / 0.14); color: #fff; }
.copy-code:focus-visible { outline-color: var(--orange); }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-literal { color: #ffab57; }
.hljs-string, .hljs-attr, .hljs-symbol { color: #e9d3a8; }
.hljs-comment, .hljs-quote { color: #a8927f; font-style: italic; }
.hljs-number, .hljs-title, .hljs-section, .hljs-name { color: #fff; font-weight: 600; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 0.7rem; }
.prose table, table.data { width: 100%; border-collapse: collapse; font-size: 0.9688rem; }
.prose th, .prose td, table.data th, table.data td { padding: 0.6rem 0.85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th, table.data th { background: var(--surface); font-weight: 700; white-space: nowrap; }
.prose tr:last-child td, table.data tbody tr:last-child td { border-bottom: 0; }

/* Files ------------------------------------------------------------------ */

.file-cards { display: grid; gap: 0.6rem; margin-top: 0.9rem; }
.file-cards:empty { display: none; }
.file-card {
  display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 0.8rem 0.7rem 0.7rem; max-width: 30rem;
  border: 1.5px solid var(--brown); border-radius: 0.9rem; background: var(--page); color: var(--text); text-decoration: none;
}
:root[data-theme='dark'] .file-card { border-color: var(--line-strong); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .file-card { border-color: var(--line-strong); } }
.file-card:hover { background: var(--surface); }
.file-card-icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none; border-radius: 0.65rem; background: var(--orange); color: #000; }
.file-card-text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.file-card-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-meta { font-size: 0.875rem; color: var(--text-soft); }
.file-card-action { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; font-size: 0.9375rem; color: var(--accent-text); }

.msg-extras { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 0.75rem; }
.msg-extras:empty { display: none; }
.msg-action {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.25rem; padding: 0 0.6rem; margin-left: -0.6rem;
  border: 0; border-radius: 0.5rem; background: transparent; color: var(--text-soft); font-size: 0.9375rem;
}
.msg-action:hover { background: var(--surface-strong); color: var(--text); }
.note { color: var(--text-soft); font-size: 0.9375rem; }
.error-note {
  flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border: 1.5px solid var(--danger); border-radius: 0.8rem; color: var(--danger); font-weight: 500;
}
.error-note p { flex: 1; min-width: 14rem; }
.sources { flex-basis: 100%; font-size: 0.9375rem; }
.sources summary { cursor: pointer; font-weight: 600; color: var(--text-soft); width: fit-content; padding: 0.25rem 0; }
.sources ol { padding: 0.4rem 0 0 1.4rem; display: grid; gap: 0.35rem; }
.sources li span { color: var(--text-soft); margin-left: 0.5rem; }

/* Composer --------------------------------------------------------------- */

.composer-wrap { flex: none; padding: 0 1.25rem 0.9rem; }
.composer {
  max-width: var(--measure); margin: 0 auto; padding: 0.6rem 0.6rem 0.5rem;
  border: 2px solid var(--brown); border-radius: 1.5rem; background: var(--page);
}
:root[data-theme='dark'] .composer { border-color: var(--line-strong); background: var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .composer { border-color: var(--line-strong); background: var(--surface); } }
.composer:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px rgb(242 137 33 / 0.28); }
.composer textarea {
  display: block; width: 100%; max-height: 16.25rem; padding: 0.5rem 0.65rem 0.4rem;
  border: 0; outline: 0; resize: none; background: transparent; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--text-soft); opacity: 1; }
.composer-row { display: flex; align-items: center; gap: 0.5rem; }
.composer-hint { flex: 1; text-align: right; font-size: 0.8438rem; color: var(--text-soft); padding-right: 0.25rem; }
.send {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none;
  border: 0; border-radius: 50%; background: var(--orange); color: #000;
}
.send:hover:not(:disabled) { background: var(--orange-press); }
.send:disabled { background: var(--surface-strong); color: var(--line-strong); }
.send.stop, .send.stop:hover:not(:disabled) { background: var(--text); color: var(--page); }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.15rem 0.25rem 0.35rem; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 0.5rem; max-width: 100%; padding: 0.3rem 0.3rem 0.3rem 0.4rem;
  border-radius: 0.7rem; background: var(--surface-strong); font-size: 0.9063rem;
}
.chip.uploading { opacity: 0.6; }
.chip-type { padding: 0.15rem 0.4rem; border-radius: 0.35rem; background: var(--brown); color: #fff; font-weight: 700; font-size: 0.75rem; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; font-weight: 600; }
.chip-size { color: var(--text-soft); white-space: nowrap; }
.chip button { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border: 0; border-radius: 50%; background: transparent; color: var(--text-soft); }
.chip button:hover { background: var(--line); color: var(--text); }
.chip button svg { width: 15px; height: 15px; }

.fine-print { max-width: var(--measure); margin: 0.55rem auto 0; text-align: center; font-size: 0.8438rem; color: var(--text-soft); }

.drop-overlay {
  position: absolute; inset: 0.75rem; z-index: 10; display: grid; place-items: center;
  border: 3px dashed var(--orange); border-radius: 1.5rem; background: color-mix(in srgb, var(--page) 90%, transparent);
  font: 700 1.5rem var(--display); pointer-events: none;
}

/* Files panel ------------------------------------------------------------ */

.files-panel { display: flex; flex-direction: column; min-height: 0; height: 100dvh; border-left: 1px solid var(--line); background: var(--page); }
.files-panel header { display: flex; align-items: center; justify-content: space-between; min-height: 3.75rem; padding: 0.4rem 0.6rem 0.4rem 1.1rem; }
.files-panel h2 { font-size: 1.125rem; }
.files-body { flex: 1; overflow-y: auto; padding: 0 1.1rem 1.5rem; }
.files-body h3 { font: 600 0.875rem var(--body); color: var(--text-soft); margin: 1rem 0 0; letter-spacing: 0; }
.files-body .file-card-action span { display: none; }

/* Dialog and toasts ------------------------------------------------------ */

.dialog {
  width: min(28rem, calc(100vw - 2rem)); padding: 1.5rem; border: 0; border-radius: 1.1rem;
  background: var(--page); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.dialog h2 { font-size: 1.375rem; margin-bottom: 0.6rem; }
.dialog p { color: var(--text-soft); }
.dialog label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.dialog input, .add-person input, .add-person select, table.data select, .dev-signin input {
  min-height: 2.75rem; padding: 0 0.8rem; border: 1.5px solid var(--line-strong); border-radius: 0.6rem; background: var(--page);
}
.dialog input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.4rem; }

.toasts { position: fixed; z-index: 60; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: grid; gap: 0.5rem; width: min(30rem, calc(100vw - 2rem)); }
.toast { padding: 0.8rem 1.1rem; border-radius: 0.8rem; background: #000; color: #fff; font-weight: 500; box-shadow: var(--shadow); }
:root[data-theme='dark'] .toast { background: #fff; color: #000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .toast { background: #fff; color: #000; } }

/* Administration --------------------------------------------------------- */

.admin-view { overflow-y: auto; display: block; }
.admin-inner { max-width: 68rem; margin: 0 auto; padding: 0.5rem 1.5rem 4rem; }
.back-link { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; text-decoration: none; min-height: 2.75rem; }
.admin-heading { font-size: clamp(2rem, 4vw, 2.9rem); font-weight: 700; letter-spacing: -0.02em; margin-top: 0.5rem; }
.admin-lede { margin-top: 0.6rem; color: var(--text-soft); max-width: 44rem; }
.admin-loading { padding: 2rem 1.5rem; }
.admin-inner section { margin-top: 2.75rem; }
.admin-inner h3 { font-size: 1.4375rem; margin-bottom: 0.35rem; }
.admin-inner section > .note { max-width: 44rem; margin-bottom: 1rem; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 0; margin: 2rem 0 0; border-top: 2px solid var(--text); }
.figure { padding: 1rem 1rem 1.1rem 0; border-bottom: 1px solid var(--line); }
.figure dt { font-size: 0.9375rem; color: var(--text-soft); }
.figure dd { margin: 0.2rem 0 0; font: 700 2rem/1.1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td { vertical-align: middle; }
table.data tr.is-disabled td { color: var(--text-soft); }
.cell-sub { display: block; font-size: 0.875rem; color: var(--text-soft); }
table.data select { min-height: 2.4rem; }

.add-person { margin-top: 1.25rem; }
.add-person label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.add-person-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.add-person input { flex: 1 1 16rem; max-width: 24rem; }

/* Sign-in ---------------------------------------------------------------- */

body.login { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100dvh; height: auto; }
.login-art { position: relative; overflow: hidden; background: var(--brown); min-height: 14rem; }
.login-logo {
  position: absolute; top: 50%; left: 50%; width: min(118%, 54rem); max-width: none;
  transform: translate(-58%, -50%);
  animation: arrive 900ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes arrive {
  from { transform: translate(-58%, -50%) rotate(-14deg) scale(0.94); opacity: 0; }
  to { transform: translate(-58%, -50%) rotate(0) scale(1); opacity: 1; }
}
.login-panel { display: grid; align-items: center; padding: 3rem clamp(1.5rem, 6vw, 5.5rem); }
.login-inner { max-width: 27rem; }
.login-mark { display: none; width: 4.5rem; height: 4.5rem; margin-bottom: 1.5rem; }
.login h1 { font-size: clamp(2.6rem, 5vw, 4.25rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1; }
.login-lede { margin-top: 1.1rem; font-size: 1.1875rem; color: var(--text-soft); }
.ms-button {
  display: inline-flex; align-items: center; gap: 0.75rem; margin-top: 2.25rem; min-height: 3.25rem; padding: 0 1.4rem;
  border: 2px solid var(--text); border-radius: 0.5rem; background: var(--page); color: var(--text);
  font: 600 1.0625rem 'Segoe UI', var(--body); text-decoration: none;
}
.ms-button:hover { background: var(--orange); border-color: var(--orange); color: #000; }
.login-help { margin-top: 1.25rem; color: var(--text-soft); font-size: 0.9688rem; }
.login-error { margin-top: 1.5rem; padding: 0.85rem 1rem; border: 1.5px solid var(--danger); border-radius: 0.7rem; color: var(--danger); font-weight: 500; }
.dev-signin { display: grid; gap: 0.4rem; margin-top: 2rem; }
.dev-signin label { font-weight: 600; margin-top: 0.5rem; }
.dev-signin .button { margin-top: 1rem; justify-self: start; }
.dev-note { padding: 0.6rem 0.9rem; border-radius: 0.6rem; background: var(--surface); font-size: 0.9375rem; }

/* Small screens ---------------------------------------------------------- */

@media (max-width: 1100px) {
  body.app.files-open { grid-template-columns: var(--side-width) minmax(0, 1fr); }
  .files-panel { position: fixed; z-index: 25; top: 0; right: 0; width: min(22rem, 100vw); box-shadow: var(--shadow); }
}

@media (max-width: 820px) {
  body.app, body.app.files-open { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 20; top: 0; left: 0; width: min(20rem, 88vw);
    transform: translateX(-100%); transition: transform 200ms ease; visibility: hidden;
  }
  body.sidebar-open .sidebar { transform: none; visibility: visible; }
  .sidebar-open, .sidebar-close { display: inline-grid; }
  .topbar { padding: 0.4rem 0.6rem; }
  .scroller { padding: 0.5rem 1rem 1.25rem; }
  .composer-wrap { padding: 0 0.75rem calc(0.6rem + env(safe-area-inset-bottom)); }
  .composer-hint { visibility: hidden; }
  .chat-item-actions { display: flex; }
  .msg.user { max-width: 92%; }
  .file-card-action span { display: none; }
  .admin-inner { padding: 0.5rem 1rem 3rem; }

  body.login { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .login-art { display: none; }
  .login-mark { display: block; }
  .login-panel { align-items: start; padding-top: 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .ring-indicator circle { opacity: 0.7; }
}
