/* Hallmark · macrostructure: Workbench · tone: utilitarian · anchor hue: terracotta
 * genre: modern-minimal · design-system: DESIGN.md · designed-as-app
 * audience: teammates and administrators · use: read, reply and manage
 * Hallmark · pre-emit critique: P4 H4 E4 S4 R5 V4
 */
:root {
  --canvas: oklch(97.5% 0.008 70);
  --surface: oklch(99.2% 0.004 70);
  --rail: oklch(95.5% 0.012 68);
  --ink: oklch(25% 0.018 50);
  --muted: oklch(49% 0.018 55);
  --line: oklch(88% 0.015 65);
  --accent: oklch(51% 0.145 40);
  --wash: oklch(94% 0.035 50);
  --green: oklch(43% 0.08 155);
  --red: oklch(45% 0.16 28);
  --amber: oklch(47% 0.095 75);
  font:
    15px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    system-ui,
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: var(--accent);
  text-underline-offset: 3px;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease-out;
}
button:hover,
.button:hover {
  background: var(--rail);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary,
.button.primary {
  background: var(--accent);
  color: oklch(99% 0.005 65);
  border-color: var(--accent);
}
button.primary:hover,
.button.primary:hover {
  background: oklch(46% 0.14 40);
}
button.danger {
  color: var(--red);
}
button.quiet {
  background: transparent;
}
button.small,
.button.small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.83rem;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  min-width: 0;
}
textarea {
  resize: vertical;
  min-height: 88px;
}
label {
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
}
label.check {
  display: flex;
  align-items: center;
  gap: 9px;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 1.9rem;
  line-height: 1.2;
  letter-spacing: -0.045em;
  margin-bottom: 0;
}
h2 {
  font-size: 1.3rem;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}
h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}
p {
  max-width: 72ch;
  margin-bottom: 14px;
}
.muted,
.fine {
  color: var(--muted);
}
.fine {
  font-size: 0.82rem;
}
.eyebrow,
.nav-label {
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  font-weight: 700;
  color: var(--muted);
}
.eyebrow {
  margin-bottom: 8px;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.wide {
  width: 100%;
}
.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.brand svg {
  width: 43px;
  height: 43px;
  color: var(--accent);
  flex-shrink: 0;
}
.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100dvh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 28px 16px 18px;
  overflow: auto;
}
.rail .brand {
  padding: 0 8px 30px;
}
.nav-label {
  padding: 0 13px;
  margin: 23px 0 8px;
}
.rail nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  margin: 3px 0;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.91rem;
  font-weight: 550;
}
.rail nav a span {
  width: 18px;
  text-align: center;
  font-size: 1.12rem;
}
.rail nav a:hover {
  background: var(--canvas);
  color: var(--ink);
}
.rail nav a[aria-current="page"] {
  background: var(--wash);
  color: var(--accent);
}
.rail-account {
  margin-top: auto;
  padding: 28px 4px 0;
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 0.83rem;
}
.rail-account strong {
  font-weight: 650;
  display: block;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-account div > span {
  font-size: 0.72rem;
  color: var(--muted);
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--wash);
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}
.icon-button {
  border: 0;
  background: transparent;
  padding: 7px;
  min-height: 34px;
  margin-left: auto;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 34px 25px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
main {
  min-width: 0;
}
#view {
  padding: 26px 34px;
}
#notice:not(:empty) {
  margin: 20px 34px 0;
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: var(--wash);
  border-radius: 8px;
  font-size: 0.9rem;
}
#notice.error {
  color: var(--red);
  background: oklch(96% 0.02 30);
}
.split {
  display: grid;
  grid-template-columns: minmax(245px, 330px) minmax(0, 1fr);
  min-height: calc(100dvh - 180px);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.list-pane {
  border-right: 1px solid var(--line);
  background: var(--canvas);
  min-width: 0;
}
.list-toolbar {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.list {
  max-height: calc(100dvh - 270px);
  overflow: auto;
}
.conversation-row {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: transparent;
  padding: 17px 18px;
  font-weight: 400;
}
.conversation-row:hover {
  background: var(--rail);
}
.conversation-row[aria-pressed="true"] {
  background: var(--wash);
}
.row-top {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.row-title {
  display: block;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-preview {
  font-size: 0.83rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}
.source {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  white-space: nowrap;
}
.reader {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 500px;
}
.reader-header {
  padding: 24px;
  border-bottom: 1px solid var(--line);
}
.reader-header h2 {
  margin: 4px 0 6px;
}
.reader-header p {
  margin: 0;
}
.messages {
  padding: 24px;
  overflow: auto;
  flex: 1;
  max-height: calc(100dvh - 400px);
  min-height: 200px;
}
.message {
  margin-bottom: 25px;
  overflow-wrap: anywhere;
}
.message-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 0.82rem;
  margin-bottom: 6px;
}
.message-meta time {
  color: var(--muted);
  font-size: 0.72rem;
}
.message-body {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.65;
}
.record {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  margin-top: 5px;
}
.context {
  padding: 14px 16px;
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 22px;
  white-space: pre-wrap;
  font-size: 0.875rem;
}
.compose {
  padding: 18px 24px;
  border-top: 1px solid var(--line);
}
.compose .actions {
  justify-content: space-between;
  margin-top: 10px;
}
.compose .fine {
  margin: 0;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 55px 28px;
  text-align: center;
  min-height: 260px;
  color: var(--muted);
}
.empty h2 {
  color: var(--ink);
}
.empty p {
  max-width: 42ch;
}
.empty .empty-mark {
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 20px;
}
.stack {
  display: grid;
  gap: 20px;
}
.section {
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}
.section:first-child {
  padding-top: 0;
}
.section:last-child {
  border-bottom: 0;
}
.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.section-heading p {
  margin: 0;
}
.status {
  font-size: 0.72rem;
  font-weight: 650;
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--rail);
  white-space: nowrap;
}
.status.ok {
  color: var(--green);
  background: oklch(94% 0.025 155);
}
.status.warn {
  color: var(--amber);
  background: oklch(95% 0.035 80);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 850px;
}
.form-grid .full {
  grid-column: 1/-1;
}
.form-grid p {
  margin: 0;
}
.connection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.connection:last-child {
  border-bottom: 0;
}
.connection h2 {
  margin: 0 0 6px;
}
.connection p {
  margin-bottom: 6px;
}
.connection .accounts {
  margin-top: 12px;
}
.account-item {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 15px;
}
.account-item strong {
  font-size: 0.875rem;
}
.account-item p {
  font-size: 0.8rem;
}
.account-item button {
  margin-left: auto;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  background: var(--rail);
}
th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:last-child td {
  border-bottom: 0;
}
td small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 3px;
}
td code {
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}
td .actions {
  flex-wrap: nowrap;
}
.table-form {
  display: flex;
  align-items: center;
  gap: 10px;
}
.table-form label {
  font-size: 0.75rem;
}
.table-form button {
  flex-shrink: 0;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 22px;
}
.toolbar form {
  display: flex;
  gap: 8px;
  max-width: 420px;
  flex: 1;
}
.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  margin-top: 15px;
  font-size: 0.8rem;
  color: var(--muted);
}
.panel {
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 24px;
}
.panel details > summary {
  cursor: pointer;
  font-weight: 650;
}
.panel details[open] > summary {
  margin-bottom: 18px;
}
.panel .panel {
  padding: 0;
  border: 0;
  border-radius: 0;
}
.secret-result {
  padding: 18px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 9px;
  margin: 20px 0;
}
.secret-result p {
  margin-bottom: 9px;
}
.secret-result input {
  font-family: ui-monospace, monospace;
}
.code {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  background: var(--rail);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.admin-note {
  margin-top: 24px;
  max-width: 74ch;
  font-size: 0.82rem;
  color: var(--muted);
}
.login-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
}
.login-copy {
  padding: 7vw;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}
.login-copy .brand {
  margin-bottom: 90px;
}
.login-copy h1 {
  font-size: 2.7rem;
  line-height: 1.16;
  letter-spacing: -0.05em;
  margin: 5px 0 24px;
}
.login-copy .intro {
  font-size: 1.1rem;
  max-width: 43ch;
  color: var(--muted);
}
.login-notes {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 35px;
  color: var(--muted);
  font-size: 0.8rem;
}
.login-form {
  align-self: center;
  width: 100%;
  max-width: 460px;
  padding: 50px;
  margin: 0 auto;
}
.login-form h2 {
  font-size: 1.7rem;
  line-height: 1.25;
}
.login-form > p:not(.eyebrow) {
  color: var(--muted);
}
.login-form .button {
  margin: 16px 0 24px;
  justify-content: space-between;
}
.login-form .fine + .fine {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
#login-message:not(:empty) {
  color: var(--red);
  font-size: 0.85rem;
  margin: 12px 0;
}
.standalone {
  padding: 60px;
}
.loading {
  display: grid;
  gap: 16px;
  max-width: 650px;
}
.skeleton {
  height: 62px;
  border-radius: 8px;
  background: var(--rail);
}
.skeleton:nth-child(2) {
  width: 85%;
}
.skeleton:nth-child(3) {
  width: 65%;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.skip {
  position: fixed;
  left: 12px;
  top: -100px;
  background: var(--surface);
  padding: 12px;
  z-index: 10;
}
.skip:focus {
  top: 12px;
}
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }
  .rail {
    padding-inline: 10px;
  }
  .page-header {
    padding: 24px;
  }
  #view {
    padding: 22px;
  }
  .split {
    grid-template-columns: 255px minmax(0, 1fr);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .login-copy {
    padding: 6vw;
  }
  .login-form {
    padding: 32px;
  }
  .table-form {
    flex-wrap: wrap;
  }
}
@media (max-width: 800px) {
  .app-shell {
    display: block;
  }
  .rail {
    height: auto;
    position: static;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail .brand {
    padding: 0 0 14px;
    font-size: 1rem;
  }
  .rail .brand br {
    display: none;
  }
  .rail .brand svg {
    width: 30px;
    height: 30px;
  }
  .rail nav {
    display: flex;
    overflow: auto;
    gap: 5px;
  }
  .rail nav a {
    white-space: nowrap;
    margin: 0;
    font-size: 0.8rem;
    padding: 8px 11px;
  }
  .nav-label,
  .rail-account {
    display: none;
  }
  .rail nav a span {
    display: none;
  }
  .page-header {
    padding: 22px 18px;
    align-items: flex-start;
  }
  h1 {
    font-size: 1.65rem;
  }
  #view {
    padding: 18px;
  }
  #notice:not(:empty) {
    margin: 15px 18px 0;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .list-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .list {
    max-height: 270px;
  }
  .reader {
    min-height: 400px;
  }
  .messages {
    max-height: 500px;
  }
  .reader-header,
  .messages,
  .compose {
    padding: 18px;
  }
  .connection {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .login-page {
    display: block;
  }
  .login-copy {
    padding: 30px;
  }
  .login-copy .brand {
    margin-bottom: 45px;
  }
  .login-copy h1 {
    font-size: 2.1rem;
  }
  .login-notes {
    display: none;
  }
  .login-form {
    padding: 35px 30px;
    max-width: none;
  }
  .panel {
    padding: 18px;
  }
  .section-heading {
    flex-wrap: wrap;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .page-header .actions {
    justify-content: flex-end;
  }
  button,
  .button {
    min-height: 42px;
  }
  .table-form {
    min-width: 190px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 800px) {
  .rail-account {
    display: flex;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--line);
  }
  .rail-account > div {
    flex: 1;
  }
  .rail-account .avatar {
    display: none;
  }
}

/* Hallmark polish · shared system from DESIGN.md; existing base retained. */
html, body { overflow-x: clip; }
:root { font-family: var(--font-body); }
body { font-family: var(--font-body); }
h1, h2, h3 { font-family: var(--font-display); font-style: normal; overflow-wrap: anywhere; min-width: 0; }
h1 { font-size: var(--text-xl); letter-spacing: -.035em; }
h2 { font-size: var(--text-lg); }
button, .button, summary, .rail nav a { -webkit-tap-highlight-color: var(--color-transparent); }
button, .button { white-space: nowrap; min-height: 44px; border-radius: var(--radius-input); transition: transform var(--dur-micro) var(--ease-out); }
button:active:not(:disabled), .button:active { transform: translateY(1px); }
button:disabled, input:disabled, textarea:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
button[aria-busy=true], form[aria-busy=true] button[type=submit] { cursor: progress; }
button[aria-busy=true]::after, form[aria-busy=true] button[type=submit]::after { content: '…'; }
button.small, .button.small { min-height: 36px; padding: var(--space-2xs) var(--space-xs); }
button.primary, .button.primary { color: var(--color-accent-ink); }
button.primary:hover, .button.primary:hover { background: var(--color-accent-hover); }
:is(input, select, textarea):not([type=checkbox]) { min-height: 44px; border-color: var(--color-input-border); border-radius: var(--radius-input); }
:is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
label { gap: var(--space-2xs); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
form > .fine { margin-top: var(--space-sm); }
form .form-feedback { color: var(--red); font-size: var(--text-sm); margin: var(--space-xs) 0 0; }
form .form-feedback[hidden] { display: none; }
form[aria-busy=true] { cursor: progress; }
input:user-invalid, textarea:user-invalid { border-color: var(--red); }
.status.ok { background: var(--color-success-surface); }
.status.warn { background: var(--color-warning-surface); }
#notice.error { background: var(--color-error-surface); }
.secret-result input, .code, td code { font-family: var(--font-mono); }
.check { min-height: 44px; }
.app-shell { grid-template-columns: 232px minmax(0, 1fr); }
.rail { padding: var(--space-md) var(--space-xs) var(--space-sm); }
.rail-heading { display: flex; align-items: center; gap: var(--space-2xs); }
.rail .brand { padding: 0 var(--space-2xs) var(--space-lg); font-size: 1.08rem; gap: var(--space-3xs); white-space: nowrap; }
.rail .brand svg { width: 32px; height: 32px; }
.nav-toggle { display: none; }
.nav-label { text-transform: none; letter-spacing: .01em; font-size: var(--text-xs); font-weight: 600; margin: var(--space-md) 0 var(--space-2xs); padding-inline: var(--space-xs); }
.rail nav .nav-text { display: inline; width: auto; font-size: var(--text-sm); text-align: left; }
.rail nav a { min-height: 44px; padding: var(--space-2xs) var(--space-xs); gap: var(--space-xs); white-space: nowrap; font-weight: 500; }
.rail nav a[aria-current=page] { font-weight: 650; }
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; }
.rail-account { border-top: var(--rule-fine) solid var(--line); padding: var(--space-sm) var(--space-2xs) 0; gap: var(--space-2xs); }
.rail-account > div { min-width: 0; flex: 1; }
.rail-account strong { max-width: 100%; font-size: var(--text-sm); }
.icon-button { width: 36px; min-width: 36px; padding: var(--space-2xs); }
.icon-button svg { width: 20px; height: 20px; }
.page-header { padding: var(--space-lg); align-items: center; gap: var(--space-md); background: var(--canvas); }
.page-description { font-size: var(--text-sm); color: var(--muted); margin: var(--space-2xs) 0 0; }
#view { padding: var(--space-md) var(--space-lg) var(--space-lg); }
#view > * { min-width: 0; }
#notice:not(:empty) { margin: 0 var(--space-lg) var(--space-sm); padding: var(--space-xs) var(--space-sm); font-size: var(--text-sm); }
.actions { gap: var(--space-2xs); }
.split { border-radius: var(--radius-panel); grid-template-columns: minmax(240px, 310px) minmax(0, 1fr); min-height: min(720px, calc(100dvh - 180px)); }
.list-toolbar { padding: var(--space-sm); gap: var(--space-xs); }
.list { padding: var(--space-2xs); }
.conversation-row { display: block; white-space: normal; padding: var(--space-sm) var(--space-xs); border: 0; border-radius: var(--radius-input); margin-bottom: var(--space-3xs); }
.conversation-row .row-top { align-items: baseline; }
.row-title { font-size: var(--text-sm); }
.row-preview { font-size: var(--text-sm); line-height: 1.55; margin: var(--space-3xs) 0 0; }
.source { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0; }
.reader { min-height: 520px; }
.reader-back { display: none; }
.reader-header { display: flex; flex-wrap: wrap; align-items: start; gap: var(--space-2xs); padding: var(--space-md); border-bottom: var(--rule-fine) solid var(--line); }
.reader-header > .source { width: 100%; }
.reader-header > h2 { flex: 1; min-width: min(100%, 150px); margin: 0; }
header.reader-header > .fine { width: 100%; order: 2; margin: 0; }
.reader-header.stack { display: grid; }
.reader > .context { margin: var(--space-sm) var(--space-md) 0; }
.messages { padding: var(--space-md); min-height: 240px; }
.message { padding-bottom: var(--space-md); margin-bottom: var(--space-md); border-bottom: var(--rule-fine) solid var(--line); }
.message:last-child { border-bottom: 0; margin-bottom: 0; }
.message-meta { gap: var(--space-xs); }
.message-meta strong { font-size: var(--text-sm); }
.message-body { line-height: 1.65; max-width: 70ch; }
.record { font-variant-numeric: tabular-nums; color: var(--muted); }
.compose { padding: var(--space-sm) var(--space-md); }
.compose textarea { min-height: 100px; }
.compose .actions { gap: var(--space-xs); }
.empty { padding: var(--space-xl) var(--space-md); min-height: 280px; }
.empty h2 { max-width: 25ch; line-height: 1.35; margin-bottom: var(--space-2xs); }
.empty p { font-size: var(--text-sm); line-height: 1.65; margin-bottom: var(--space-md); }
.empty-mark { width: 44px; height: 44px; display: grid; place-items: center; border: var(--rule-fine) solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.reader > .empty { flex: 1; }
.list .empty { padding-inline: var(--space-xs); }
.stack { gap: var(--space-sm); }
.panel { padding: var(--space-md); margin-bottom: var(--space-md); border-radius: var(--radius-panel); }
.panel details > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); min-height: 28px; list-style: none; font-size: var(--text-base); }
.panel details > summary::-webkit-details-marker { display: none; }
.panel details > summary::after { content: '+'; color: var(--muted); font-size: var(--text-lg); }
.panel details[open] > summary::after { content: '−'; }
.panel details[open] > summary { margin-bottom: var(--space-md); }
.section { padding: var(--space-lg) 0; }
.section-heading { gap: var(--space-md); margin-bottom: var(--space-md); }
.form-grid { gap: var(--space-md); max-width: 880px; }
.connection { padding: var(--space-md) 0; gap: var(--space-md); }
.connection h2 { font-size: var(--text-lg); }
.connection > div { min-width: 0; }
.connection p, .account-item { overflow-wrap: anywhere; }
.account-item { flex-wrap: wrap; }
.status { font-size: var(--text-xs); font-weight: 500; padding: var(--space-3xs) var(--space-2xs); }
.table-wrap { border-radius: var(--radius-panel); }
table { font-variant-numeric: tabular-nums; }
th { font-size: var(--text-xs); padding: var(--space-xs) var(--space-sm); }
td { padding: var(--space-sm); vertical-align: middle; }
td small { font-size: var(--text-xs); line-height: 1.6; }
td .actions { flex-wrap: wrap; }
.toolbar { margin-bottom: var(--space-sm); gap: var(--space-sm); }
.toolbar .fine { margin: 0; }
.pagination { font-variant-numeric: tabular-nums; margin-top: var(--space-sm); gap: var(--space-2xs); }
.pagination > span { margin-right: auto; }
.code { margin-bottom: var(--space-2xs); }
[data-page='/connections'] #view, [data-page='/admin/providers'] #view { max-width: 1080px; }
[data-page='/chats'] #view > div > .stack { max-width: 640px; margin-inline: auto; }
.login-page { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.login-copy h1 { font-size: var(--text-display); }
.login-form .button { justify-content: space-between; }
@media (hover: hover) {
  tbody tr:hover { background: var(--canvas); }
  input:not(:disabled):hover, textarea:not(:disabled):hover, select:not(:disabled):hover { background: var(--canvas); }
}
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 216px minmax(0, 1fr); }
  .rail { padding-inline: var(--space-2xs); }
  .page-header { padding: var(--space-md); }
  #view { padding: var(--space-md); }
  .split { grid-template-columns: minmax(220px, 270px) minmax(0, 1fr); }
  header.reader-header > button { order: 3; }
}
@media (max-width: 800px) {
  .app-shell { display: block; }
  .rail { padding: var(--space-xs) var(--space-sm); }
  .rail-heading { justify-content: space-between; }
  .rail .brand { padding: 0; font-size: var(--text-base); }
  .nav-toggle { display: inline-flex; font-size: var(--text-sm); }
  .rail nav, .rail-account { display: none; }
  .rail.nav-open nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3xs); overflow: visible; margin-top: var(--space-sm); }
  .rail.nav-open .nav-label { display: block; grid-column: 1/-1; margin: var(--space-xs) 0 var(--space-3xs); }
  .rail.nav-open .rail-account { display: flex; margin-top: var(--space-sm); padding: var(--space-sm) 0 0; }
  .rail.nav-open .avatar { display: grid; }
  .rail nav a { padding: var(--space-2xs); }
  .rail nav .nav-text { font-size: var(--text-xs); }
  .nav-icon { width: 16px; height: 16px; }
  .page-header { padding: var(--space-md) var(--space-sm); flex-direction: column; align-items: stretch; gap: var(--space-sm); }
  .page-header .actions { justify-content: flex-start; }
  .page-header .actions:empty { display: none; }
  #view { padding: 0 var(--space-sm) var(--space-md); }
  #notice:not(:empty) { margin: 0 var(--space-sm) var(--space-sm); }
  .split { display: block; min-height: 400px; }
  .split .list { max-height: none; }
  .split .list-pane { border-bottom: 0; }
  .split .reader { display: none; }
  .split.has-selection .list-pane { display: none; }
  .split.has-selection .reader { display: flex; min-height: 460px; }
  .reader-back { display: inline-flex; width: fit-content; margin-bottom: var(--space-2xs); }
  .reader-header > .reader-back { order: -1; flex-basis: 100%; padding-left: 0; justify-content: flex-start; }
  .reader-header, .messages, .compose { padding: var(--space-sm); }
  .reader > .context { margin-inline: var(--space-sm); }
  .reader-header > h2 { flex-basis: 100%; }
  header.reader-header > .fine { order: 0; }
  .messages { max-height: 55dvh; }
  .compose .actions { align-items: flex-start; }
  .compose .fine { flex-basis: 100%; }
  .compose button[type=submit] { margin-left: auto; }
  .connection { flex-direction: column; align-items: stretch; }
  .connection > .button, .connection > button { align-self: flex-start; }
  .panel { padding: var(--space-sm); }
  .section-heading { flex-direction: column; gap: var(--space-xs); }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-sm); }
  input, select, textarea { font-size: 16px; }
  button.small, .button.small, .icon-button, .panel details > summary { min-height: 44px; }
  .icon-button { min-width: 44px; }
  .toolbar { align-items: stretch; }
  .toolbar form { min-width: 0; width: 100%; max-width: none; }
  .toolbar input { min-width: 0; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { padding: var(--space-sm); border-bottom: var(--rule-fine) solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td { border: 0; padding: var(--space-2xs) 0; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); display: block; color: var(--muted); font-size: var(--text-xs); margin-bottom: var(--space-3xs); }
  td:not([data-label])::before { display: none; }
  .table-form { min-width: 0; flex-wrap: wrap; gap: var(--space-xs); }
  .table-form .form-feedback { flex-basis: 100%; }
  .table-form input:not([type=checkbox]) { flex-basis: 100%; }
  .login-copy { padding: var(--space-md) 30px; }
  .login-copy .brand { margin-bottom: 0; }
  .login-copy h1, .login-copy .intro, .login-notes { display: none; }
  .login-form { max-width: 460px; margin-inline: auto; padding: var(--space-lg) 30px; }
  .login-form .button { font-size: var(--text-sm); }
  .pagination { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled), .button:active { transform: none; }
}

/* Final fit adjustments from the narrow-screen review. */
#view > .empty { min-height: 480px; border: var(--rule-fine) solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.empty .actions { justify-content: center; }
.section form > .section { border-bottom: 0; padding-bottom: 0; }
.form-grid .actions > a { white-space: nowrap; font-size: var(--text-sm); }
@media (max-width: 800px) {
  .toolbar form { flex-basis: 100%; }
  .toolbar form button { flex-shrink: 0; }
  .login-copy .eyebrow { display: none; }
  #view > .empty { min-height: 400px; }
  .form-grid .actions { align-items: flex-start; flex-direction: column; }
  .form-grid .actions > a { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; font-size: .8rem; }
}

form:not(.table-form) > .form-feedback { min-height: 1.5em; }
form:not(.table-form) > .form-feedback[hidden] { display: block; visibility: hidden; }

.reader-back { border: 0; background: var(--color-transparent); }
@media (max-width: 800px) {
  header.reader-header > .reader-back { order: -1; }
}
