:root {
  --canvas: #f4f5f0;
  --surface: #ffffff;
  --surface-subtle: #f8f8f4;
  --surface-tint: #edf5f0;
  --ink: #19342f;
  --ink-strong: #0e2622;
  --muted: #61716d;
  --muted-light: #687874;
  --line: #dce3dd;
  --line-strong: #c7d2cb;
  --brand: #155f53;
  --brand-dark: #0d463e;
  --brand-soft: #d8eee6;
  --accent: #db684f;
  --accent-soft: #f8e3dc;
  --warning: #8b5a0a;
  --warning-soft: #fff1cf;
  --danger: #a33d37;
  --danger-soft: #fbe6e3;
  --success: #2a7254;
  --success-soft: #e0f1e8;
  --sidebar: #102e2a;
  --sidebar-muted: #9fb6b1;
  --shadow-sm: 0 1px 2px rgba(14, 38, 34, 0.05), 0 4px 16px rgba(14, 38, 34, 0.04);
  --shadow-lg: 0 20px 50px rgba(14, 38, 34, 0.12);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --focus: 0 0 0 3px rgba(155, 57, 37, 0.52);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
summary,
label[for="attachment-input"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: var(--brand);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--brand-dark);
}

p,
h1,
h2,
h3,
h4 {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--ink-strong);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.4vw, 2.15rem);
}

h2 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

small {
  font-size: 0.78rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--ink-strong);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input,
select {
  min-height: 44px;
  padding: 0.65rem 0.78rem;
}

textarea {
  min-height: 92px;
  padding: 0.75rem 0.85rem;
  line-height: 1.55;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #667773;
}

input:hover,
textarea:hover,
select:hover {
  border-color: #9fafaa;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  border-color: var(--brand);
  box-shadow: var(--focus);
}

input:disabled,
textarea:disabled,
select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible,
label[for="attachment-input"]:has(+ input:focus-visible) {
  outline: 3px solid #9b3925;
  outline-offset: 3px;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  transform: translateY(-150%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.boot-screen {
  display: grid;
  min-height: 100vh;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(216, 238, 230, 0.7), transparent 35%),
    var(--canvas);
  color: var(--muted);
  font-weight: 650;
}

.boot-screen .brand-mark {
  animation: breathe 1.4s ease-in-out infinite alternate;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 820;
  letter-spacing: -0.04em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.brand-mark--large {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.36rem;
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > label,
.label-row label {
  color: var(--ink-strong);
  font-size: 0.84rem;
  font-weight: 720;
}

.field-help {
  color: var(--muted);
  font-size: 0.68rem;
}

.field--checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.field--checkbox input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

.field--checkbox .field-help {
  grid-column: 2;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.label-row span {
  color: var(--muted-light);
  font-size: 0.74rem;
}

.button,
.icon-button,
.text-button,
.nav-item,
.attachment-button {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.65rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 760;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button--primary {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 6px 15px rgba(21, 95, 83, 0.16);
}

.button--primary:hover:not(:disabled) {
  background: var(--brand-dark);
  box-shadow: 0 8px 20px rgba(21, 95, 83, 0.22);
}

.button--quiet {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button--quiet:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-subtle);
}

.button--danger {
  border-color: #e9bdb7;
  background: var(--danger-soft);
  color: var(--danger);
}

.button--wide {
  width: 100%;
  justify-content: space-between;
  padding-inline: 1rem;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--brand);
  font-size: 0.79rem;
  font-weight: 760;
}

.text-button:hover {
  color: var(--brand-dark);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: transparent;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(360px, 1.08fr) minmax(400px, 0.92fr);
  background: var(--surface);
}

.login-intro {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(2rem, 5vw, 4.5rem);
  background:
    radial-gradient(circle at 84% 14%, rgba(242, 161, 137, 0.24), transparent 28%),
    radial-gradient(circle at 12% 76%, rgba(120, 183, 161, 0.25), transparent 34%),
    var(--sidebar);
  color: #eaf3ef;
}

.login-intro::after {
  position: absolute;
  right: -12rem;
  bottom: -15rem;
  width: 34rem;
  height: 34rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
  box-shadow:
    0 0 0 4rem rgba(255, 255, 255, 0.018),
    0 0 0 9rem rgba(255, 255, 255, 0.014);
  content: "";
  pointer-events: none;
}

.login-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: #ffffff;
  font-size: 1.16rem;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.login-copy {
  position: relative;
  z-index: 1;
  max-width: 660px;
  margin-block: 4rem;
}

.login-copy .eyebrow {
  color: #9fd5c5;
}

.login-copy h1 {
  max-width: 13ch;
  margin-bottom: 1.2rem;
  color: #ffffff;
  font-size: clamp(2.6rem, 5.8vw, 5.4rem);
  font-weight: 720;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.login-copy > p:last-child {
  max-width: 52ch;
  margin: 0;
  color: #bfd0cc;
  font-size: clamp(1rem, 1.6vw, 1.18rem);
}

.boundary-card {
  position: relative;
  z-index: 1;
  display: flex;
  max-width: 500px;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(10px);
}

.boundary-card strong {
  color: #ffffff;
  font-size: 0.85rem;
}

.boundary-card p {
  margin: 0.18rem 0 0;
  color: #b9ceca;
  font-size: 0.79rem;
}

.boundary-icon {
  display: inline-grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 850;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  padding: clamp(1.5rem, 5vw, 4rem);
  place-items: center;
  background: #fbfbf8;
}

.login-card {
  display: grid;
  width: min(100%, 420px);
  gap: 1.75rem;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-card h2 {
  margin-bottom: 0.4rem;
  font-size: 2rem;
}

.login-card .muted {
  margin: 0;
  font-size: 0.88rem;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 4.2rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.8rem;
  min-width: 44px;
  min-height: 36px;
  transform: translateY(-50%);
}

.form-error {
  padding: 0.72rem 0.8rem;
  border: 1px solid #ebc3bd;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.82rem;
}

.login-footnote {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.setup-key {
  display: block;
  overflow-wrap: anywhere;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--ink-strong);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  user-select: all;
}

.workspace {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 1.25rem 0.85rem 1rem;
  background: var(--sidebar);
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.45rem 1.6rem;
}

.sidebar-brand > div {
  display: grid;
  line-height: 1.15;
}

.sidebar-brand strong {
  font-size: 0.95rem;
}

.sidebar-brand span:last-child {
  margin-top: 0.16rem;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
}

.primary-nav {
  display: grid;
  gap: 0.25rem;
}

.nav-item {
  position: relative;
  display: grid;
  min-height: 46px;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.62rem;
  border-radius: 11px;
  background: transparent;
  color: #b9cbc7;
  font-size: 0.83rem;
  font-weight: 650;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.nav-item.is-active::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -0.85rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  content: "";
}

.nav-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.68rem;
  font-weight: 820;
}

.nav-count {
  min-width: 21px;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  background: #9b3925;
  color: #ffffff;
  font-size: 0.68rem;
  text-align: center;
}

.sidebar-bottom {
  display: grid;
  gap: 0.7rem;
  margin-top: auto;
}

.privacy-note,
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.66rem;
  padding: 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
}

.privacy-note {
  align-items: flex-start;
}

.privacy-note > div,
.user-meta {
  display: grid;
  min-width: 0;
  flex: 1;
}

.privacy-note strong,
.user-meta strong {
  overflow: hidden;
  color: #eef6f3;
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.privacy-note span:last-child,
.user-meta span {
  overflow: hidden;
  margin-top: 0.12rem;
  color: var(--sidebar-muted);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 0.68rem;
  font-weight: 820;
}

.user-menu .icon-button {
  color: #bfd0cc;
}

.workspace-body {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  flex-direction: column;
}

.topbar {
  position: sticky;
  z-index: 15;
  top: 0;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid rgba(199, 210, 203, 0.72);
  background: rgba(244, 245, 240, 0.93);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
}

.mobile-signout {
  display: none;
}

.runtime-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.42rem;
}

.status-pill,
.tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 720;
  white-space: nowrap;
}

.status-pill {
  min-height: 28px;
  padding: 0.28rem 0.58rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
}

.status-pill--model {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a4afac;
  box-shadow: 0 0 0 3px rgba(164, 175, 172, 0.13);
}

.status-dot--safe,
.status-pill.is-online .status-dot,
.status-pill.is-healthy .status-dot {
  background: #60b58c;
  box-shadow: 0 0 0 3px rgba(96, 181, 140, 0.15);
}

.status-pill.is-offline .status-dot,
.status-pill.is-error .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(219, 104, 79, 0.15);
}

.main-content {
  width: min(100%, 1500px);
  flex: 1;
  margin-inline: auto;
  padding: clamp(1rem, 2.7vw, 2.25rem) clamp(1rem, 3vw, 2.5rem) 3rem;
}

.safety-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.35rem;
  padding: 0.72rem 0.82rem;
  border: 1px solid #ead8ac;
  border-radius: 11px;
  background: var(--warning-soft);
  color: #72501a;
}

.safety-mark {
  flex: 0 0 auto;
  padding: 0.22rem 0.48rem;
  border-radius: 6px;
  background: #7a5519;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.safety-banner p {
  flex: 1;
  margin: 0;
  font-size: 0.77rem;
}

.safety-banner .text-button {
  color: #72501a;
}

.view {
  animation: view-in 180ms ease both;
}

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 252px;
  gap: 1.25rem;
  align-items: start;
}

.assistant-primary {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.35rem;
}

.section-heading--compact {
  align-items: center;
}

.section-heading-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.55rem;
}

.section-heading > div > p:not(.eyebrow) {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.mode-picker {
  display: grid;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.mode-option {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 68px;
  align-items: center;
  gap: 0.62rem;
  padding: 0.62rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: border 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.mode-option:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.mode-option:has(input:checked) {
  border-color: #82b8a8;
  background: var(--surface-tint);
  box-shadow: 0 0 0 1px rgba(21, 95, 83, 0.08);
}

.mode-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.mode-option:has(input:focus-visible) {
  outline: 3px solid rgba(219, 104, 79, 0.36);
  outline-offset: 2px;
}

.mode-initial {
  display: inline-grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: #e8edE9;
  color: var(--brand-dark);
  font-size: 0.68rem;
  font-weight: 850;
}

.mode-option:has(input:checked) .mode-initial {
  background: var(--brand);
  color: #ffffff;
}

.mode-option > span:last-child {
  display: grid;
  min-width: 0;
}

.mode-option strong,
.mode-option small {
  overflow-wrap: anywhere;
}

.mode-option strong {
  color: var(--ink-strong);
  font-size: 0.75rem;
}

.mode-option small {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.assistant-results {
  display: grid;
  min-height: 250px;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 240px;
  padding: 2.25rem 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  text-align: center;
}

.empty-state h3 {
  margin: 0.65rem 0 0.35rem;
}

.empty-state p {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state--wide {
  min-height: 220px;
  grid-column: 1 / -1;
}

.empty-monogram {
  display: inline-grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border: 1px solid #c4ddd3;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.9rem;
  font-weight: 850;
}

.result-loading {
  display: grid;
  min-height: 250px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.loading-indicator {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  font-size: 0.82rem;
}

.loading-dots {
  display: flex;
  gap: 0.3rem;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  animation: dot-bounce 900ms ease-in-out infinite alternate;
}

.loading-dots span:nth-child(2) {
  animation-delay: 150ms;
}

.loading-dots span:nth-child(3) {
  animation-delay: 300ms;
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.78rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
}

.result-card-header > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.result-card-header h3 {
  margin: 0;
  font-size: 0.82rem;
}

.result-card-body {
  padding: 1rem;
  color: #2a423e;
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-summary {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid #c9ddd5;
  border-radius: var(--radius);
  background: var(--surface-tint);
}

.transcript-summary__mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 850;
}

.transcript-summary h3,
.transcript-summary p {
  margin: 0;
}

.transcript-summary h3 {
  font-size: 0.92rem;
}

.transcript-summary p:last-child {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.conversation-transcript {
  display: grid;
  gap: 0.72rem;
}

.transcript-load-earlier {
  justify-self: center;
}

.transcript-message {
  width: min(88%, 680px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.transcript-message--user {
  justify-self: end;
  border-color: #b9d8ce;
  background: var(--surface-tint);
}

.transcript-message--assistant {
  justify-self: start;
}

.transcript-message--structured {
  width: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.transcript-message--structured > .transcript-message__meta {
  margin-bottom: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.transcript-message__result {
  display: grid;
  gap: 0.72rem;
}

.transcript-message__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.67rem;
}

.transcript-message__meta strong {
  color: var(--ink-strong);
  font-size: 0.72rem;
}

.transcript-message__content {
  padding: 0.78rem;
  color: #2a423e;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-drawer {
  width: min(430px, 100%);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: -20px 0 60px rgba(14, 38, 34, 0.2);
  animation: history-drawer-in 180ms ease both;
}

.history-drawer::backdrop {
  background: rgba(7, 27, 24, 0.42);
  backdrop-filter: blur(2px);
}

.history-drawer__shell {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.history-drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.history-drawer__header h2,
.history-drawer__header p {
  margin-bottom: 0;
}

.history-drawer__header h2 {
  font-size: 1.38rem;
}

.history-drawer__header p:last-child {
  max-width: 36ch;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.history-close {
  flex: 0 0 auto;
  font-size: 1.15rem;
}

.history-drawer__actions {
  padding: 1rem 1.25rem 0.7rem;
}

.history-status {
  min-height: 1.35rem;
  padding: 0 1.25rem 0.5rem;
  color: var(--muted);
  font-size: 0.69rem;
}

.history-status.is-error {
  color: var(--danger);
}

.history-navigation {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.history-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0 1.25rem 1.25rem;
  list-style: none;
}

.history-load-more {
  display: grid;
  place-items: center;
  padding-top: 0.35rem;
}

.history-item {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.history-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.history-item.is-active {
  border-color: #7fb2a3;
  background: var(--surface-tint);
  box-shadow: 0 0 0 1px rgba(21, 95, 83, 0.08);
}

.history-item__open {
  display: grid;
  min-width: 0;
  gap: 0.42rem;
  padding: 0.75rem 0.5rem 0.75rem 0.8rem;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.history-item__open:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.history-item__heading,
.history-item__timing {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-item__heading strong {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-active-label {
  flex: 0 0 auto;
  padding: 0.13rem 0.38rem;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.history-active-label--muted {
  background: var(--surface-strong);
  color: var(--muted);
}

.history-item__timing {
  flex-wrap: wrap;
  justify-content: flex-start;
  color: var(--muted-light);
  font-size: 0.64rem;
}

.history-item__timing span + span::before {
  margin-right: 0.5rem;
  content: "·";
}

.history-item__delete {
  width: 34px;
  height: 34px;
  margin-right: 0.55rem;
  color: var(--muted);
}

.history-item__delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.history-panel-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  padding: 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-subtle);
  text-align: center;
}

.history-panel-state h3 {
  margin: 0.65rem 0 0.3rem;
}

.history-panel-state p {
  max-width: 32ch;
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.history-skeleton {
  display: grid;
  gap: 0.5rem;
  min-height: 78px;
  align-content: center;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.history-skeleton span {
  height: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #e9eeea 20%, #f7f8f5 45%, #e9eeea 70%);
  background-size: 300% 100%;
  animation: shimmer 1.2s linear infinite;
}

.history-skeleton span:first-child {
  width: 55%;
}

.history-skeleton span:last-child {
  width: 78%;
}

.history-drawer__footer {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.8rem 1.25rem max(1rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
}

.history-drawer__footer .status-dot {
  margin-top: 0.28rem;
}

.history-drawer__footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.67rem;
}

.confirmation-dialog {
  width: min(430px, calc(100% - 2rem));
  max-width: none;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.confirmation-dialog::backdrop {
  background: rgba(7, 27, 24, 0.5);
}

.confirmation-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  padding: 1.35rem;
}

.confirmation-card h2 {
  margin-bottom: 0.35rem;
  font-size: 1.22rem;
}

.confirmation-card p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.confirmation-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 850;
}

.confirmation-error {
  grid-column: 1 / -1;
  margin: 0;
}

.confirmation-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 0.55rem;
  padding-top: 0.35rem;
}

.result-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0.9rem 1rem 1rem 2.2rem;
  color: #2a423e;
  font-size: 0.84rem;
}

.result-list li::marker {
  color: var(--brand);
}

.result-card--draft {
  border-left: 3px solid var(--brand);
}

.result-card--prediction {
  border-left: 3px solid var(--accent);
}

.unapproved-note {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0;
  padding: 0.65rem 1rem;
  border-top: 1px solid #f0d6cf;
  background: #fff9f7;
  color: #7f4a3f;
  font-size: 0.73rem;
}

.result-sources {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.2rem;
}

.result-sources > h3 {
  margin: 0.3rem 0 0;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.source-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.composer {
  display: grid;
  gap: 0.62rem;
  padding: 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.composer:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus);
}

.composer > label {
  color: var(--ink-strong);
  font-size: 0.78rem;
  font-weight: 760;
}

.composer textarea {
  min-height: 100px;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.composer textarea:focus-visible {
  outline: none;
  box-shadow: none;
}

.composer-footer,
.composer-tools,
.composer-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.composer-footer {
  justify-content: space-between;
  padding-top: 0.72rem;
  border-top: 1px solid var(--line);
}

.attachment-button {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.36rem 0.5rem;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 720;
}

.attachment-button:hover {
  background: #ecf0ec;
}

.attachment-hint,
.character-count {
  color: var(--muted-light);
  font-size: 0.67rem;
}

.memory-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.memory-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--brand);
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.attachment-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 0.38rem;
  padding: 0.3rem 0.42rem 0.3rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 0.69rem;
}

.attachment-chip > span:first-child {
  overflow: hidden;
  max-width: 190px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.attachment-chip button:hover {
  background: var(--line);
  color: var(--danger);
}

.context-rail {
  position: sticky;
  top: 105px;
  display: grid;
  gap: 0.8rem;
}

.rail-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.rail-card--accent {
  border-color: #e8c8bf;
  background: var(--accent-soft);
}

.rail-card h3 {
  margin-top: 0.2rem;
}

.rail-card > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.step-list {
  display: grid;
  gap: 0.78rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.step-list li > span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.66rem;
  font-weight: 850;
}

.step-list p {
  display: grid;
  margin: 0;
}

.step-list strong {
  font-size: 0.75rem;
}

.step-list small {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-bar input {
  border-color: transparent;
  background: var(--surface-subtle);
}

.results-status {
  min-height: 1.3rem;
  margin: 0.78rem 0 0.42rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.results-status.is-error {
  color: var(--danger);
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.source-card {
  display: flex;
  min-width: 0;
  min-height: 156px;
  flex-direction: column;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.source-card-top,
.source-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.source-card-footer span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-card h3 {
  margin: 0.7rem 0 0.38rem;
  font-size: 0.9rem;
}

.source-card h3 a {
  color: inherit;
  text-decoration: none;
}

.source-card h3 a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.source-card > p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.76rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.source-card-footer {
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
  color: var(--muted-light);
  font-size: 0.66rem;
}

.tag {
  padding: 0.2rem 0.45rem;
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-transform: capitalize;
}

.tag--draft,
.status-badge--draft,
.tag--review {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag--approved,
.status-badge--approved,
.status-badge--executed,
.tag--living {
  background: var(--success-soft);
  color: var(--success);
}

.tag--blocked,
.status-badge--blocked,
.status-badge--failed,
.tag--stale {
  background: var(--danger-soft);
  color: var(--danger);
}

.create-request-card {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.create-request-card summary {
  padding: 0.85rem 1rem;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 780;
  cursor: pointer;
}

.create-request-card[open] summary {
  border-bottom: 1px solid var(--line);
}

.request-form {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.request-form > .field {
  max-width: 360px;
}

.request-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.request-field--wide {
  grid-column: 1 / -1;
}

.request-form .button {
  justify-self: start;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.action-list {
  display: grid;
  gap: 0.75rem;
}

.action-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.action-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.action-card h3 {
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

.action-card-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin: 0.8rem 0;
  color: var(--muted-light);
  font-size: 0.68rem;
}

.action-payload-review {
  margin: 0.9rem 0;
  padding: 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-subtle);
}

.action-payload-review h4 {
  margin-bottom: 0.7rem;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.action-payload-list {
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) minmax(0, 1fr);
  gap: 0.42rem 0.8rem;
  margin: 0;
  font-size: 0.74rem;
}

.action-payload-list dt {
  color: var(--muted);
  font-weight: 750;
}

.action-payload-list dd {
  min-width: 0;
  margin: 0;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.action-payload-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.67rem;
}

.action-progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0.9rem 0 1rem;
}

.progress-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  color: var(--muted-light);
  font-size: 0.64rem;
  text-align: center;
}

.progress-step::before {
  position: absolute;
  z-index: 0;
  top: 9px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
  content: "";
}

.progress-step:first-child::before {
  display: none;
}

.progress-dot {
  z-index: 1;
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  font-size: 0.56rem;
}

.progress-step.is-complete,
.progress-step.is-current {
  color: var(--brand-dark);
  font-weight: 740;
}

.progress-step.is-complete::before,
.progress-step.is-current::before {
  background: #86bba9;
}

.progress-step.is-complete .progress-dot,
.progress-step.is-current .progress-dot {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.progress-step.is-current .progress-dot {
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.action-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.action-card-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.action-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.loading-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(90deg, #f7f8f5 25%, #edf0ec 40%, #f7f8f5 60%);
  background-size: 300% 100%;
  animation: shimmer 1.3s ease infinite;
}

.filter-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.45rem;
}

.field--inline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.field--inline select {
  width: auto;
  min-width: 160px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.audit-table {
  min-width: 650px;
}

.users-table {
  min-width: 760px;
}

th,
td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 790;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfcfa;
}

.audit-event {
  display: grid;
  gap: 0.15rem;
}

.audit-event strong {
  color: var(--ink-strong);
  font-size: 0.76rem;
}

.audit-event small {
  max-width: 54ch;
  color: var(--muted);
}

.status-badge {
  padding: 0.22rem 0.48rem;
  background: #e9edeb;
  color: #55645f;
  text-transform: capitalize;
}

.subheading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0.65rem;
}

.subheading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.subheading .muted {
  font-size: 0.7rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.metric-card {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.metric-card strong {
  display: block;
  overflow: hidden;
  margin-top: 0.55rem;
  color: var(--ink-strong);
  font-size: 1.35rem;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.admin-users {
  margin-top: 1.4rem;
}

.admin-controls,
.admin-invite {
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.admin-controls .subheading,
.admin-invite .subheading {
  align-items: flex-start;
  margin-top: 0;
}

.admin-controls .subheading p,
.admin-invite .subheading p {
  max-width: 68ch;
  margin: 0.28rem 0 0;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.admin-form .button {
  align-self: end;
  justify-self: start;
}

.admin-form select[multiple] {
  min-height: 7.8rem;
}

.invite-result {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.9rem;
  padding: 0.85rem;
  border: 1px solid #d8b972;
  border-radius: 11px;
  background: #fff8e8;
}

.invite-result[hidden] {
  display: none;
}

.invite-result code {
  overflow-wrap: anywhere;
  color: var(--ink-strong);
  font-size: 0.72rem;
}

.invite-result .button {
  justify-self: start;
}

.invite-result p {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.user-controls {
  display: grid;
  min-width: 170px;
  gap: 0.42rem;
}

.user-controls select {
  min-height: 5.3rem;
  font-size: 0.68rem;
}

.user-control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.user-control-buttons .button {
  min-height: 30px;
  padding: 0.35rem 0.55rem;
  font-size: 0.64rem;
}

.user-cell {
  display: grid;
}

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

.user-cell span {
  color: var(--muted);
  font-size: 0.68rem;
}

.capability-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.capability-list .tag {
  font-size: 0.62rem;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  border-top: 1px solid var(--line);
  color: var(--muted-light);
  font-size: 0.66rem;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  width: min(360px, calc(100vw - 2rem));
  gap: 0.55rem;
  pointer-events: none;
}

.toast {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  font-size: 0.77rem;
  animation: toast-in 180ms ease both;
}

.toast--error {
  border-left-color: var(--danger);
}

.noscript {
  position: fixed;
  z-index: 1000;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  padding: 1rem;
  border-radius: 10px;
  background: var(--danger);
  color: #ffffff;
  text-align: center;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes history-drawer-in {
  from {
    opacity: 0;
    transform: translateX(26px);
  }
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

@keyframes dot-bounce {
  to {
    transform: translateY(-5px);
    opacity: 0.45;
  }
}

@keyframes breathe {
  to {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(219, 104, 79, 0.25);
  }
}

@media (max-width: 1180px) {
  .assistant-layout {
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .mode-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-intro {
    min-height: auto;
    padding: 2rem;
  }

  .login-copy {
    margin-block: 2rem;
  }

  .login-copy h1 {
    max-width: 15ch;
    font-size: clamp(2.25rem, 8vw, 3.6rem);
  }

  .login-panel {
    min-height: auto;
    padding-block: 3rem;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: 100%;
    height: auto;
    padding: 0.45rem max(0.45rem, env(safe-area-inset-right)) max(0.45rem, env(safe-area-inset-bottom)) max(0.45rem, env(safe-area-inset-left));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sidebar-brand,
  .sidebar-bottom {
    display: none;
  }

  .mobile-signout {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .primary-nav {
    display: flex;
    justify-content: space-around;
    gap: 0.2rem;
  }

  .nav-item {
    display: flex;
    min-width: 0;
    min-height: 54px;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 0.16rem;
    padding: 0.25rem;
    font-size: 0.61rem;
    text-align: center;
  }

  .nav-item.is-active::before {
    top: -0.45rem;
    right: 28%;
    bottom: auto;
    left: 28%;
    width: auto;
    height: 3px;
    border-radius: 0 0 3px 3px;
  }

  .nav-icon {
    width: 25px;
    height: 25px;
    border: 0;
    background: transparent;
  }

  .nav-count {
    position: absolute;
    top: 2px;
    right: calc(50% - 24px);
  }

  .topbar {
    position: static;
    min-height: 76px;
  }

  .toast-region {
    bottom: calc(70px + env(safe-area-inset-bottom) + 1rem);
  }

  .assistant-layout {
    grid-template-columns: 1fr;
  }

  .context-rail {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .login-intro {
    padding: 1.4rem;
  }

  .login-copy {
    margin-block: 1.5rem;
  }

  .login-copy h1 {
    font-size: clamp(2.1rem, 11vw, 3rem);
  }

  .login-panel {
    padding: 1rem;
  }

  .login-card {
    border-radius: 17px;
    box-shadow: var(--shadow-sm);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.65rem;
  }

  .runtime-status {
    justify-content: flex-start;
  }

  .status-pill--model {
    max-width: 155px;
  }

  .main-content {
    padding-inline: 0.8rem;
  }

  .safety-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .safety-banner p {
    min-width: calc(100% - 5rem);
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .section-heading-actions {
    width: 100%;
  }

  .section-heading-actions .button {
    min-width: 0;
    flex: 1;
  }

  .history-drawer {
    width: 100%;
  }

  .history-drawer__header,
  .history-drawer__actions,
  .history-list {
    padding-inline: 1rem;
  }

  .history-status {
    padding-inline: 1rem;
  }

  .history-drawer__footer {
    padding-inline: 1rem;
  }

  .transcript-message {
    width: 96%;
  }

  .transcript-message--structured {
    width: 100%;
  }

  .confirmation-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .confirmation-actions .button {
    width: 100%;
  }

  .mode-picker {
    display: flex;
    margin-right: -0.8rem;
    padding-right: 0.8rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .mode-option {
    min-width: 170px;
    scroll-snap-align: start;
  }

  .assistant-results {
    min-height: 220px;
  }

  .empty-state {
    min-height: 210px;
  }

  .composer-footer,
  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-footer {
    gap: 0.8rem;
  }

  .composer-tools {
    flex-wrap: wrap;
  }

  .composer-actions .button {
    width: 100%;
  }

  .character-count {
    align-self: flex-end;
  }

  .context-rail,
  .source-grid,
  .source-strip,
  .metric-grid,
  .admin-form,
  .request-form,
  .request-fields {
    grid-template-columns: 1fr;
  }

  .request-field--wide {
    grid-column: auto;
  }

  .search-bar {
    grid-template-columns: 1fr;
  }

  .action-card-top,
  .action-card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .action-card-actions {
    width: 100%;
    justify-content: stretch;
  }

  .action-card-actions .button {
    flex: 1;
  }

  .action-payload-list {
    grid-template-columns: 1fr;
    gap: 0.12rem;
  }

  .action-payload-list dd + dt {
    margin-top: 0.5rem;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .audit-table,
  .users-table {
    min-width: 650px;
  }

  .app-footer {
    align-items: center;
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .nav-item {
    font-size: 0.65rem;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
  }

  .boundary-card {
    gap: 0.6rem;
    padding: 0.68rem 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #aebbb5;
    --line-strong: #71827a;
  }

  .button--primary,
  .brand-mark {
    box-shadow: none;
  }
}

@media print {
  .sidebar,
  .topbar,
  .safety-banner,
  .composer,
  .app-footer,
  .button,
  .filter-row {
    display: none !important;
  }

  .workspace {
    display: block;
  }

  .main-content {
    width: 100%;
    padding: 0;
  }

  .view[hidden] {
    display: none !important;
  }

  .result-card,
  .source-card,
  .action-card,
  .table-wrap {
    break-inside: avoid;
    box-shadow: none;
  }
}
