:root {
  color-scheme: light;
  --bg: #4b383d;
  --bg-wash: #7a6665;
  --surface: rgba(224, 215, 211, 0.4);
  --surface-soft: rgba(225, 215, 211, 0.26);
  --surface-strong: rgba(237, 229, 225, 0.52);
  --ink: #171113;
  --ink-strong: #090607;
  --muted: #493e40;
  --muted-strong: #241c1f;
  --line: rgba(255, 255, 255, 0.24);
  --line-strong: rgba(22, 13, 15, 0.24);
  --brand: #a62436;
  --brand-strong: #7e1828;
  --brand-soft: rgba(166, 36, 54, 0.16);
  --gold: #b13e4d;
  --green: #367a56;
  --amber: #966c22;
  --red: #9f2d34;
  --glass-fill: rgba(230, 220, 216, 0.28);
  --glass-fill-strong: rgba(240, 232, 228, 0.44);
  --glass-line: rgba(255, 255, 255, 0.42);
  --glass-highlight: rgba(255, 255, 255, 0.78);
  --shadow: 0 24px 80px rgba(16, 5, 9, 0.26);
  --shadow-soft: 0 14px 44px rgba(16, 5, 9, 0.18);
  --radius: 8px;
  --sidebar-width: 224px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  background:
    linear-gradient(135deg, rgba(108, 16, 28, 0.42), transparent 31%),
    linear-gradient(22deg, rgba(9, 6, 8, 0.32), transparent 47%),
    linear-gradient(180deg, #8a7773, #5d464b 48%, #38272d),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  margin: 0;
  min-height: 100vh;
}

body::before {
  background: linear-gradient(90deg, var(--brand-strong), var(--brand), transparent 78%);
  content: "";
  height: 3px;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 90;
}

a {
  color: var(--brand-strong);
  text-decoration: none;
}

a:hover {
  color: var(--ink-strong);
}

.sidebar {
  background: rgba(255, 253, 248, 0.9);
  border-right: 1px solid var(--line);
  bottom: 0;
  display: flex;
  flex-direction: column;
  left: 0;
  padding: 22px 14px;
  position: fixed;
  top: 0;
  width: var(--sidebar-width);
  z-index: 20;
}

.brand-block {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding: 0 8px 18px;
}

.brand-mark {
  color: var(--ink);
  display: grid;
  gap: 3px;
}

.brand-mark strong {
  color: var(--ink-strong);
  display: block;
  font-size: 22px;
  letter-spacing: 0;
}

.brand-mark span,
.muted,
small {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a,
.nav-logout,
.agent-nav-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted-strong);
  display: flex;
  font-weight: 750;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
}

.nav-list a.active,
.nav-list a:hover {
  background: var(--brand-soft);
  border-color: #dfbfc0;
  color: var(--brand-strong);
}

.nav-icon {
  flex: 0 0 18px;
  height: 18px;
  width: 18px;
}

.logout-form {
  margin-top: auto;
}

.nav-logout {
  justify-content: flex-start;
  width: 100%;
}

.agent-nav-button {
  display: none;
}

.app-shell {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 34px clamp(22px, 4vw, 54px) 88px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 36px 20px;
  place-items: center;
}

.narrow {
  margin: 0 auto;
  max-width: 780px;
}

.narrow-head {
  margin-left: auto;
  margin-right: auto;
  max-width: 780px;
}

.page-head,
.panel-head {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.page-head {
  margin: 0 0 20px;
}

.page-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.page-head h1,
.panel-head h2 {
  margin: 0;
}

.page-copy {
  color: rgba(20, 12, 14, 0.86);
  font-size: 15px;
  font-weight: 560;
  margin: 8px 0 0;
  max-width: 680px;
  text-shadow: 0 1px 22px rgba(255, 255, 255, 0.32);
}

.eyebrow,
.panel-kicker {
  color: #7d1320;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-shadow: 0 1px 20px rgba(255, 255, 255, 0.36);
  text-transform: uppercase;
}

.panel-kicker {
  color: var(--gold);
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  color: var(--ink-strong);
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  color: var(--ink-strong);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel,
.login-card {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
  padding: 20px;
}

.panel-head {
  margin-bottom: 16px;
}

.stack {
  display: grid;
  gap: 14px;
}

.login-card {
  max-width: 560px;
  padding: clamp(28px, 5vw, 46px);
  width: min(560px, 100%);
}

.login-card form.stack {
  margin-top: 18px;
}

.auth-login-card {
  display: grid;
  gap: 16px;
}

.auth-actions {
  display: grid;
  gap: 14px;
  margin-top: 4px;
}

.auth-divider {
  align-items: center;
  display: flex;
  gap: 12px;
  margin: 0;
}

.auth-divider::before,
.auth-divider::after {
  background: var(--line);
  content: "";
  flex: 1 1 auto;
  height: 1px;
}

.google-signin-slot {
  min-height: 44px;
}

.auth-status {
  min-height: 20px;
}

.passkey-panel {
  display: grid;
  gap: 16px;
}

.passkey-table-shell form {
  margin: 0;
}

.split-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  margin-bottom: 18px;
}

.metric-card {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  min-height: 118px;
  padding: 17px;
  position: relative;
}

.metric-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 750;
}

.metric-card strong {
  color: var(--ink-strong);
  display: block;
  font-size: 34px;
  line-height: 1;
  margin-top: 16px;
}

.entry-form {
  display: grid;
  gap: 18px;
}

.form-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: 150px minmax(0, 1fr);
  padding-top: 18px;
}

.panel-head + .entry-form .form-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.section-label {
  color: var(--muted);
  display: grid;
  gap: 5px;
  min-width: 0;
}

.section-label span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 850;
}

.section-label strong {
  color: var(--ink-strong);
}

.grid-form {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.detail-form {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.form-actions {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
}

label,
.field {
  color: var(--muted-strong);
  display: grid;
  font-size: 13px;
  font-weight: 760;
  gap: 6px;
  min-width: 0;
}

.field {
  position: relative;
}

.field-label {
  display: block;
}

.required-marker {
  color: var(--brand-strong);
  font-weight: 900;
  margin-left: 3px;
}

.wide {
  grid-column: span 2;
}

input,
select,
textarea,
button,
.button-link {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  max-width: 100%;
  padding: 10px 11px;
}

input,
select,
textarea {
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  outline: none;
  width: 100%;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #9b9287;
}

input[type="file"] {
  background: var(--surface);
  min-height: 44px;
}

.multi-select {
  position: relative;
}

.multi-select-button {
  align-items: center;
  background: rgba(255, 253, 248, 0.94);
  border-color: var(--line-strong);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-height: 43px;
  overflow: hidden;
  padding-right: 34px;
  position: relative;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

select:not([multiple]) {
  appearance: none;
  background-color: rgba(255, 253, 248, 0.94);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  min-height: 43px;
  padding-right: 34px;
}

.multi-select-button::after {
  border-color: currentColor transparent transparent;
  border-style: solid;
  border-width: 5px 4px 0;
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
}

.multi-select-menu {
  background: rgba(245, 238, 234, 0.98);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: none;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 35;
}

.multi-select.open .multi-select-menu {
  display: grid;
  gap: 4px;
}

.multi-select-menu label {
  align-items: center;
  color: var(--ink);
  display: flex;
  flex-direction: row;
  font-weight: 650;
  gap: 8px;
  padding: 7px 8px;
}

.multi-select-menu label:hover {
  background: rgba(154, 45, 57, 0.08);
  border-radius: var(--radius);
}

.multi-select-menu input[type="checkbox"] {
  accent-color: var(--brand);
  flex: 0 0 auto;
  width: auto;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button-link:focus-visible,
a:focus-visible {
  box-shadow: 0 0 0 3px rgba(127, 48, 56, 0.2);
  outline: 1px solid var(--brand);
  outline-offset: 2px;
}

button,
.button-link {
  background: var(--brand);
  border-color: var(--brand);
  color: #fffdf8;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  line-height: 1.2;
  text-align: center;
}

button:hover,
.button-link:hover {
  background: var(--brand-strong);
  color: #fffdf8;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.ghost,
.button-link.ghost {
  background: rgba(255, 253, 248, 0.8);
  border-color: var(--line-strong);
  color: var(--ink);
}

button.ghost:hover,
.button-link.ghost:hover {
  background: var(--surface-strong);
  color: var(--ink-strong);
}

button.danger,
.button-link.danger {
  border-color: #e5b5b2;
  color: var(--red);
}

.button-link.compact,
button.compact {
  font-size: 12px;
  padding: 8px 10px;
}

.filter-bar,
.inline-form,
.review-form,
.action-stack {
  align-items: center;
  display: flex;
  gap: 8px;
}

.filter-bar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-bar input {
  min-width: 260px;
}

.review-form {
  align-items: stretch;
  flex-wrap: wrap;
  min-width: 280px;
}

.review-form input {
  min-width: 180px;
}

.inline-choice {
  align-items: center;
  display: flex;
  gap: 6px;
}

.inline-choice span {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.inline-choice select {
  min-width: 92px;
}

.action-stack {
  align-items: stretch;
  flex-wrap: wrap;
}

.action-stack form {
  margin: 0;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

.dense-table {
  background: var(--surface);
  min-width: 720px;
}

.dense-table th,
.dense-table td,
.narrow th,
.narrow td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.dense-table tr:last-child td {
  border-bottom: 0;
}

.dense-table th,
.narrow th {
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.dense-table td,
.narrow td {
  color: var(--ink);
}

.dense-table td span,
.alert-table small {
  display: block;
  margin-top: 4px;
}

.dense-table td .chip {
  display: inline-block;
  margin-top: 0;
}

.record-title,
.record-subtitle,
.alert-copy {
  display: block;
}

.record-subtitle {
  color: var(--muted);
  margin-top: 5px;
}

.settings-table th {
  min-width: 220px;
}

.score-value {
  color: var(--brand-strong);
  font-size: 18px;
}

.chip {
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted-strong);
  display: inline-block;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.1;
  padding: 5px 8px;
  text-transform: uppercase;
}

.chip.high,
.chip.vip,
.chip.vvip {
  background: var(--brand-soft);
  border-color: #dfbfc0;
  color: var(--brand-strong);
}

.chip.normal {
  background: #e4f0e7;
  border-color: #b6d3bd;
  color: var(--green);
}

.queue-list,
.activity-list {
  display: grid;
  gap: 10px;
}

.queue-list article,
.activity-list div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}

.queue-title {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.queue-list p,
.activity-list p {
  margin: 7px 0 0;
}

.activity-list span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.draft-cell {
  max-width: 380px;
  white-space: pre-wrap;
}

.chat-log {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  min-height: 360px;
  padding: 16px;
}

.message {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.message:last-child {
  border-bottom: 0;
}

.message span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.message.user p {
  color: var(--ink-strong);
}

.message.assistant p,
.message.assistant .message-content {
  color: var(--muted-strong);
}

.message p,
.message-content {
  white-space: pre-wrap;
}

.markdown-body {
  white-space: normal;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre {
  margin: 0 0 10px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 20px;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-size: 15px;
  line-height: 1.3;
  margin: 0 0 8px;
}

.markdown-body code {
  background: rgba(9, 6, 8, 0.08);
  border-radius: 4px;
  font-size: 0.94em;
  padding: 1px 4px;
}

.markdown-body pre {
  background: rgba(9, 6, 8, 0.08);
  border-radius: var(--radius);
  overflow-x: auto;
  padding: 10px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

.chat-workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(220px, 0.78fr) minmax(420px, 1.45fr) minmax(280px, 0.95fr);
  align-items: start;
}

.chat-sidebar,
.chat-main,
.memory-panel {
  min-width: 0;
}

@media (min-width: 901px) {
  .chat-workspace > .chat-sidebar,
  .chat-workspace > .memory-panel {
    max-height: calc(100vh - 68px);
    overflow-y: auto;
    overscroll-behavior: contain;
    position: sticky;
    top: 34px;
  }
}

.thread-list {
  display: grid;
  gap: 10px;
}

.thread-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.thread-item a {
  color: var(--ink);
  display: grid;
  gap: 4px;
  text-decoration: none;
}

.thread-item.active {
  border-color: rgba(154, 45, 57, 0.34);
  background: rgba(154, 45, 57, 0.12);
}

.thread-item form {
  display: flex;
  justify-content: flex-start;
}

.thread-list span,
.memory-meta,
.agent-thread-title,
.chat-stream-status {
  color: var(--muted);
  font-size: 12px;
}

.agent-thread-title {
  margin: 4px 0 0;
}

.chat-stream-status {
  min-height: 18px;
  margin: -2px 0 10px;
}

.stream-thinking {
  background: rgba(238, 229, 225, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted-strong);
  margin: 8px 0;
  padding: 0;
}

.stream-thinking summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
  min-height: 38px;
  padding: 9px 11px;
}

.stream-thinking summary::-webkit-details-marker {
  display: none;
}

.stream-thinking summary::before {
  border-color: transparent transparent transparent var(--brand-strong);
  border-style: solid;
  border-width: 5px 0 5px 7px;
  content: "";
  flex: 0 0 auto;
  transition: transform 160ms ease;
}

.stream-thinking[open] summary::before {
  transform: rotate(90deg);
}

.stream-thinking-title {
  color: var(--ink-strong);
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.stream-thinking-current {
  color: var(--muted);
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-thinking-steps {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px 12px 34px;
}

.stream-thinking-steps li {
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.35;
  padding-left: 2px;
}

.stream-thinking-steps:empty {
  display: none;
}

.stream-thinking-thoughts {
  border-top: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.42;
  margin: 0;
  padding: 10px 12px 12px;
  white-space: pre-wrap;
}

.stream-thinking-thoughts:empty {
  display: none;
}

.memory-create-form,
.memory-edit-form {
  display: grid;
  gap: 10px;
}

.memory-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.memory-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.memory-item.pending {
  border-color: rgba(154, 45, 57, 0.28);
}

.memory-meta {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  text-transform: capitalize;
}

.memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 112px;
}

.partial-region[aria-busy="true"],
.agent-rail-shell[aria-busy="true"] {
  opacity: 0.62;
}

.agent-launcher {
  align-items: center;
  bottom: 20px;
  box-shadow: var(--shadow);
  gap: 9px;
  position: fixed;
  right: 20px;
  z-index: 42;
}

.agent-drawer {
  background: var(--surface);
  border-left: 1px solid var(--line);
  bottom: 0;
  box-shadow: -22px 0 55px rgba(68, 49, 31, 0.18);
  max-width: 430px;
  padding: 16px;
  position: fixed;
  right: 0;
  top: 0;
  transform: none;
  display: none;
  width: min(430px, 94vw);
  z-index: 70;
}

.agent-drawer.open {
  display: block;
}

.agent-scrim {
  background: rgba(38, 33, 27, 0.26);
  border: 0;
  bottom: 0;
  display: none;
  left: 0;
  padding: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 65;
}

.agent-scrim.open {
  display: block;
}

.agent-rail-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 18px;
}

.agent-rail-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.agent-head-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.agent-head-actions form {
  margin: 0;
}

.agent-rail-head h2 {
  color: var(--ink-strong);
  margin: 0;
}

.agent-rail-copy {
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0 14px;
}

.agent-rail-loading {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 10px;
  margin: auto;
}

.agent-status-dot {
  background: var(--green);
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(54, 122, 86, 0.12);
  display: inline-block;
  height: 9px;
  width: 9px;
}

.starter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.starter-chip {
  background: var(--brand-soft);
  border-color: #dfbfc0;
  color: var(--brand-strong);
  font-size: 12px;
  padding: 7px 9px;
  text-align: left;
}

.starter-chip:hover {
  background: #ead1d0;
  color: var(--brand-strong);
}

.agent-error {
  background: #f7e4e1;
  border: 1px solid #e4b6b1;
  border-radius: var(--radius);
  margin: 0 0 12px;
  padding: 9px 10px;
}

.agent-message-list {
  display: grid;
  flex: 1;
  gap: 10px;
  min-height: 170px;
  overflow-y: auto;
  padding-right: 4px;
}

.agent-message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.agent-message.user {
  background: var(--surface-soft);
}

.agent-message.assistant {
  background: var(--brand-soft);
  border-color: #dfbfc0;
}

.agent-message span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 850;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.agent-message p,
.agent-message .message-content {
  margin: 0;
  white-space: pre-wrap;
}

.agent-message .markdown-body {
  white-space: normal;
}

.agent-empty {
  align-self: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 14px;
}

.agent-empty p {
  margin: 4px 0 0;
}

.agent-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
}

.agent-form textarea {
  min-height: 92px;
}

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

.detail-drawer {
  background: var(--surface);
  border-left: 1px solid var(--line);
  bottom: 0;
  box-shadow: -18px 0 45px rgba(68, 49, 31, 0.22);
  max-width: 820px;
  overflow-y: auto;
  padding: 24px;
  position: fixed;
  right: 0;
  top: 0;
  transform: none;
  display: none;
  width: min(820px, 94vw);
  z-index: 60;
}

.detail-drawer.open {
  display: block;
}

.drawer-scrim {
  background: rgba(38, 33, 27, 0.34);
  border: 0;
  bottom: 0;
  display: none;
  left: 0;
  padding: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 50;
}

.drawer-scrim.open {
  display: block;
}

.drawer-head {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-head h2 {
  margin: 0;
}

.icon-button {
  align-items: center;
  min-width: 42px;
  padding-left: 12px;
  padding-right: 12px;
}

.error {
  color: var(--red);
  font-weight: 850;
}

.success {
  color: var(--green);
  font-weight: 850;
}

/* Black/red liquid-glass pass: restrained, legible, and work-focused. */
.sidebar,
.panel,
.metric-card,
.login-card,
.table-shell,
.queue-list article,
.activity-list div,
.chat-log,
.agent-drawer,
.agent-rail-shell,
.agent-message,
.stream-thinking,
.agent-empty,
.detail-drawer {
  -webkit-backdrop-filter: blur(28px) saturate(145%);
  backdrop-filter: blur(28px) saturate(145%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.035)), var(--glass-fill);
  border-color: var(--glass-line);
  box-shadow: var(--shadow-soft), inset 0 1px 0 var(--glass-highlight);
}

.panel,
.metric-card,
.login-card,
.table-shell,
.queue-list article,
.activity-list div,
.chat-log,
.agent-rail-shell,
.agent-message,
.stream-thinking,
.agent-empty {
  position: relative;
}

.panel::after,
.login-card::after,
.table-shell::after,
.agent-rail-shell::after,
.detail-drawer::after {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 24%),
    linear-gradient(315deg, rgba(166, 36, 54, 0.08), transparent 38%);
  border-radius: inherit;
  content: "";
  inset: 0;
  opacity: 0.58;
  pointer-events: none;
  position: absolute;
}

.panel > *,
.login-card > *,
.table-shell > *,
.agent-rail-shell > *,
.detail-drawer > * {
  position: relative;
  z-index: 1;
}

.sidebar {
  background: linear-gradient(180deg, rgba(238, 229, 225, 0.5), rgba(207, 194, 191, 0.28)), rgba(56, 40, 45, 0.38);
}

.brand-mark,
.brand-mark strong,
h1,
h2,
.page-head h1,
.panel-head h2,
.section-label strong {
  color: var(--ink-strong);
}

.brand-mark span,
.muted,
small,
.section-label,
.metric-card span,
.agent-rail-copy {
  color: var(--muted);
}

.nav-list a,
.nav-logout,
.agent-nav-button {
  color: var(--muted-strong);
}

.nav-list a.active,
.nav-list a:hover {
  background: rgba(182, 56, 70, 0.2);
  border-color: rgba(255, 90, 104, 0.38);
  color: var(--ink-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.metric-card {
  background: linear-gradient(180deg, rgba(238, 229, 225, 0.44), rgba(207, 194, 191, 0.22)), rgba(46, 32, 37, 0.12);
}

input,
select,
textarea {
  background: rgba(245, 238, 234, 0.34);
  border-color: rgba(22, 13, 15, 0.2);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

input::placeholder,
textarea::placeholder {
  color: rgba(29, 23, 25, 0.48);
}

input[type="file"] {
  background: rgba(245, 238, 234, 0.32);
}

.multi-select-button {
  background: rgba(245, 238, 234, 0.34);
  border-color: rgba(22, 13, 15, 0.2);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

select:not([multiple]) {
  background-color: rgba(245, 238, 234, 0.34);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  border-color: rgba(22, 13, 15, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.multi-select-button:hover {
  background: rgba(245, 238, 234, 0.46);
  color: var(--ink-strong);
}

select:not([multiple]):hover {
  background-color: rgba(245, 238, 234, 0.46);
  color: var(--ink-strong);
}

.multi-select-menu {
  background: rgba(238, 229, 225, 0.96);
  border-color: rgba(22, 13, 15, 0.2);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button-link:focus-visible,
a:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 90, 104, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  outline-color: var(--brand-strong);
}

button,
.button-link {
  background: linear-gradient(180deg, #c94351, #8f2734);
  border-color: rgba(255, 90, 104, 0.45);
  color: #fffaf3;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 10px 24px rgba(119, 20, 31, 0.2);
}

.agent-scrim,
.drawer-scrim {
  color: transparent;
  cursor: default;
  box-shadow: none;
}

.agent-scrim:hover,
.drawer-scrim:hover,
.agent-scrim:focus,
.drawer-scrim:focus {
  background: rgba(0, 0, 0, 0.48);
  border-color: transparent;
  box-shadow: none;
  color: transparent;
}

button:hover,
.button-link:hover {
  background: linear-gradient(180deg, #dc4b5a, #a42d3b);
  color: #fffaf3;
}

button.ghost,
.button-link.ghost {
  background: rgba(238, 229, 225, 0.4);
  border-color: rgba(42, 28, 29, 0.18);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

button.ghost:hover,
.button-link.ghost:hover {
  background: rgba(238, 229, 225, 0.58);
  color: var(--ink-strong);
}

button.danger,
.button-link.danger {
  border-color: rgba(255, 90, 104, 0.42);
  color: var(--red);
}

.dense-table {
  background: transparent;
}

.dense-table th,
.narrow th {
  background: rgba(238, 229, 225, 0.34);
  color: rgba(29, 23, 25, 0.78);
}

.dense-table td,
.narrow td {
  color: var(--ink);
}

.chip {
  background: rgba(238, 229, 225, 0.38);
  border-color: rgba(42, 28, 29, 0.16);
  color: var(--muted-strong);
}

.chip.high,
.chip.vip,
.chip.vvip {
  background: rgba(154, 45, 57, 0.16);
  border-color: rgba(154, 45, 57, 0.28);
  color: var(--brand-strong);
}

.chip.normal {
  background: rgba(72, 185, 130, 0.16);
  border-color: rgba(72, 185, 130, 0.34);
  color: var(--green);
}

.score-value,
.eyebrow,
.panel-kicker,
a {
  color: var(--brand-strong);
}

.page-head .eyebrow {
  color: var(--muted-strong);
}

a:hover {
  color: var(--ink-strong);
}

.queue-list article,
.activity-list div,
.chat-log,
.agent-message.user {
  background: rgba(238, 229, 225, 0.34);
}

.agent-message.assistant,
.stream-thinking,
.starter-chip {
  background: rgba(154, 45, 57, 0.13);
  border-color: rgba(154, 45, 57, 0.28);
  color: var(--brand-strong);
}

.starter-chip:hover {
  background: rgba(154, 45, 57, 0.2);
  color: var(--ink-strong);
}

.agent-error {
  background: rgba(154, 45, 57, 0.12);
  border-color: rgba(154, 45, 57, 0.28);
}

.agent-scrim,
.drawer-scrim {
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.agent-status-dot {
  background: var(--brand-strong);
  box-shadow: 0 0 0 4px rgba(255, 90, 104, 0.14), 0 0 22px rgba(255, 90, 104, 0.5);
}

@media (max-width: 1180px) {
  .grid-form,
  .detail-form,
  .split-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  body.authenticated {
    padding-top: 0;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    bottom: auto;
    display: grid;
    gap: 10px;
    left: 0;
    padding: 16px;
    position: sticky;
    right: 0;
    top: 0;
    width: auto;
  }

  .brand-block {
    border-bottom: 0;
    margin: 0;
    padding: 0;
  }

  .brand-mark strong {
    font-size: 19px;
  }

  .brand-mark span {
    font-size: 13px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-list a {
    flex: 0 0 auto;
    min-height: 38px;
    white-space: nowrap;
  }

  .logout-form {
    display: none;
  }

  .agent-nav-button {
    display: inline-flex;
    width: 100%;
  }

  .agent-launcher {
    display: none;
  }

  .app-shell {
    margin-left: 0;
    padding: 24px 16px 88px;
  }

  .form-section {
    grid-template-columns: 1fr;
  }

  .section-label {
    align-items: center;
    display: flex;
    gap: 10px;
  }
}

@media (max-width: 720px) {
  .page-head,
  .panel-head,
  .filter-bar,
  .inline-form,
  .review-form,
  .action-stack {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions,
  .filter-bar {
    justify-content: stretch;
  }

  .page-actions > *,
  .filter-bar > *,
  .form-actions button {
    width: 100%;
  }

  .grid-form,
  .detail-form,
  .split-grid,
  .chat-form,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .chat-workspace {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: span 1;
  }

  .panel {
    padding: 16px;
  }

  .form-actions {
    justify-content: stretch;
  }

  .filter-bar input,
  .review-form input {
    min-width: 0;
  }

  .dense-table {
    min-width: 640px;
  }

  .agent-launcher {
    bottom: 14px;
    right: 14px;
  }

  .detail-drawer,
  .agent-drawer {
    padding: 14px;
    width: 100vw;
  }

  .agent-rail-shell {
    padding: 15px;
  }
}

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