:root {
  color-scheme: light;
  --body-bg:
    linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 170px),
    linear-gradient(135deg, #f6f9fd 0%, #eaf1f7 100%);
  --sidebar-bg:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 250, 253, 0.94)),
    #ffffff;
  --main-bg:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0)),
    #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --thread-bg: rgba(248, 250, 252, 0.78);
  --drawer-bg: rgba(255, 255, 255, 0.96);
  --overlay: rgba(15, 23, 42, 0.22);
  --send-bg: #111827;
  --send-ink: #ffffff;
  --assistant-bubble-bg: #ffffff;
  --assistant-bubble-border: #d8e1ec;
  --assistant-avatar-bg: linear-gradient(145deg, #ffffff, #edf4ff);
  --assistant-avatar-ink: #172033;
  --user-bubble-bg: #111827;
  --user-bubble-border: transparent;
  --user-bubble-ink: #ffffff;
  --user-avatar-bg: #0f766e;
  --streaming-bubble-bg: linear-gradient(180deg, #ffffff, #f2fbf9);
  --streaming-bubble-border: #a9d8d1;
  --subtle-button-bg: rgba(255, 255, 255, 0.86);
  --subtle-button-hover-bg: #f8fafc;
  --subtle-button-border: #d8e1ec;
  --subtle-button-hover-border: #bdcadb;
  --subtle-button-ink: #4b5b70;
  --subtle-button-hover-ink: #111827;
  --bg: #f4f7fb;
  --bg-strong: #eaf0f7;
  --ink: #111827;
  --ink-soft: #263344;
  --muted: #687588;
  --muted-strong: #4b5b70;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-tint: #f1f8f7;
  --line: #d8e1ec;
  --line-soft: #e7edf5;
  --line-strong: #bdcadb;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --accent-soft: #e8f5f3;
  --blue: #2563eb;
  --blue-soft: #edf4ff;
  --green: #16803c;
  --green-soft: #ecfdf3;
  --amber: #b7791f;
  --amber-soft: #fff7ed;
  --red: #c2410c;
  --red-soft: #fff1f2;
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-float: 0 22px 60px rgba(15, 23, 42, 0.16);
  --radius: 8px;
  --font:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: var(--font);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --body-bg: linear-gradient(135deg, #0b111a 0%, #101827 100%);
  --sidebar-bg:
    linear-gradient(180deg, rgba(18, 27, 40, 0.96), rgba(13, 20, 31, 0.96)),
    #0f1724;
  --main-bg:
    linear-gradient(180deg, rgba(17, 27, 42, 0.96), rgba(11, 17, 26, 0.96)),
    #0b111a;
  --topbar-bg: rgba(12, 19, 30, 0.9);
  --thread-bg: rgba(15, 24, 37, 0.82);
  --drawer-bg: rgba(15, 24, 37, 0.98);
  --overlay: rgba(0, 0, 0, 0.52);
  --send-bg: #14b8a6;
  --send-ink: #031311;
  --assistant-bubble-bg: #172435;
  --assistant-bubble-border: #2b3b50;
  --assistant-avatar-bg: linear-gradient(145deg, #1d3347, #102a2c);
  --assistant-avatar-ink: #bdece6;
  --user-bubble-bg: #123a3a;
  --user-bubble-border: #1e6f69;
  --user-bubble-ink: #dffcf7;
  --user-avatar-bg: #128579;
  --streaming-bubble-bg: linear-gradient(180deg, #172d35, #132635);
  --streaming-bubble-border: #25655f;
  --subtle-button-bg: rgba(20, 32, 47, 0.72);
  --subtle-button-hover-bg: rgba(27, 42, 61, 0.9);
  --subtle-button-border: #28384c;
  --subtle-button-hover-border: #3a4d63;
  --subtle-button-ink: #8da0b8;
  --subtle-button-hover-ink: #c7d5e6;
  --bg: #0b111a;
  --bg-strong: #101827;
  --ink: #edf5ff;
  --ink-soft: #d7e2f0;
  --muted: #93a4ba;
  --muted-strong: #b4c1d0;
  --surface: #121c2a;
  --surface-soft: #172435;
  --surface-tint: #102b2a;
  --line: #263447;
  --line-soft: #1f2b3b;
  --line-strong: #3a4d63;
  --accent: #14b8a6;
  --accent-strong: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --blue-soft: rgba(37, 99, 235, 0.14);
  --green-soft: rgba(22, 128, 60, 0.16);
  --amber-soft: rgba(183, 121, 31, 0.18);
  --red-soft: rgba(194, 65, 12, 0.16);
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.28);
  --shadow-float: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  height: 100%;
  background: var(--bg);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  height: 100%;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--body-bg);
  font-size: 14px;
}

body.auth-ready {
  overflow: hidden;
}

body.auth-loading,
body.auth-required {
  overflow: auto;
}

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

button {
  cursor: pointer;
}

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

body.auth-loading .app-shell,
body.auth-required .app-shell {
  display: none;
}

body.auth-ready .auth-screen,
body:not(.auth-required) .auth-screen {
  display: none;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

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

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background: var(--body-bg);
  padding: 22px;
}

.auth-panel {
  display: grid;
  gap: 13px;
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow-float);
}

.auth-panel .brand {
  margin-bottom: 6px;
}

.auth-panel h1 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0;
}

.auth-panel .button-primary {
  margin-top: 4px;
}

.auth-mode-button {
  min-height: 34px;
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.auth-mode-button:hover {
  color: var(--ink);
}

.auth-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.auth-message.error {
  color: var(--red);
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  padding: 18px;
}

.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  background: var(--overlay);
  backdrop-filter: blur(3px);
}

.mobile-sidebar-overlay[hidden] {
  display: none;
}

.sidebar-header,
.brand,
.sidebar-footer,
.thread-strip,
.panel-heading,
.route-controls,
.message-head,
.message-actions,
.stream-status,
.typing-bars {
  display: flex;
  align-items: center;
}

.sidebar-header {
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 16px;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  color: #dffcf5;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)),
    #0c6b64;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-copy,
.environment-item strong,
.environment-item span,
.session-main strong,
.session-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.brand-copy span {
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.mobile-close-button,
.mobile-nav-button,
.new-session-button,
.message-action,
.session-action {
  display: grid;
  place-items: center;
  border: 1px solid var(--subtle-button-border);
  border-radius: var(--radius);
  color: var(--subtle-button-ink);
  background: var(--subtle-button-bg);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}

.mobile-close-button,
.mobile-nav-button {
  display: none;
  width: 38px;
  height: 38px;
}

.mobile-close-button {
  color: var(--muted-strong);
  border-color: var(--line);
  background: var(--surface-soft);
}

.new-session-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  margin-bottom: 14px;
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 820;
}

.new-session-button svg {
  width: 16px;
  height: 16px;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: #ffffff;
  border-color: #0f766e;
  background: #0f766e;
}

.icon-button.ghost {
  color: var(--muted-strong);
  border-color: var(--line);
  background: var(--surface-soft);
}

.icon-button:hover,
.new-session-button:hover {
  background: var(--accent-strong);
}

.icon-button:active,
.new-session-button:active,
.button:active,
.message-action:active,
.session-action:active {
  transform: translateY(1px);
}

.route-controls label span,
.detail-list dt {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.search-box {
  position: relative;
  display: block;
  margin: 0 0 9px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box input,
.field,
.route-controls select,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.search-box input {
  height: 38px;
  padding: 0 12px 0 36px;
  color: var(--ink-soft);
  background: var(--surface);
}

.search-box input::placeholder,
.field::placeholder,
.composer textarea::placeholder {
  color: var(--muted);
}

.search-box input:focus,
.field:focus,
.route-controls select:focus,
.composer textarea:focus {
  border-color: rgba(15, 118, 110, 0.68);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.archive-toggle {
  width: 100%;
  min-height: 34px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.archive-toggle:hover {
  color: var(--ink);
  border-color: #b9c8d8;
  background: var(--surface);
}

.session-list {
  display: grid;
  align-content: start;
  gap: 8px;
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  padding-right: 2px;
}

.session-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 74px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  padding: 10px;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.session-item::before {
  position: absolute;
  inset: 10px auto 10px 0;
  width: 3px;
  border-radius: 4px;
  background: transparent;
  content: "";
}

.session-item:hover,
.session-item.active {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.session-item.active::before {
  background: var(--accent);
}

.session-main {
  min-width: 0;
  border: 0;
  color: inherit;
  background: transparent;
  padding: 0;
  text-align: left;
}

.session-main strong,
.session-main span {
  display: block;
}

.session-main strong {
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.25;
}

.session-main span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.session-actions {
  display: grid;
  gap: 5px;
}

.session-action {
  width: 30px;
  height: 28px;
}

.session-action svg {
  width: 15px;
  height: 15px;
}

.session-action:hover,
.message-action:hover {
  color: var(--subtle-button-hover-ink);
  border-color: var(--subtle-button-hover-border);
  background: var(--subtle-button-hover-bg);
}

.session-action.danger:hover {
  color: #991b1b;
  border-color: #fecaca;
  background: var(--red-soft);
}

.session-empty {
  min-height: 70px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  padding: 18px 12px;
  font-size: 13px;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  min-height: 34px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.health-strip,
.account-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-strip {
  justify-content: space-between;
}

.account-strip[hidden] {
  display: none;
}

.account-strip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link {
  min-height: 26px;
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  padding: 0;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-link:hover {
  color: var(--ink);
}

.health-dot,
.status-light,
.check-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}

.health-dot.ok,
.check-dot.ok,
.status-light {
  background: #24b26b;
  box-shadow: 0 0 0 3px rgba(36, 178, 107, 0.12);
}

.health-dot.error,
.check-dot.error {
  background: #fb923c;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.12);
}

.conversation-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--main-bg);
}

.topbar {
  position: relative;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 80px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
  padding: 16px 28px 14px;
}

.title-group {
  min-width: 0;
}

h1 {
  overflow-wrap: anywhere;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 780;
  line-height: 1.15;
}

h2 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.3;
}

#conversationMeta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.route-controls {
  gap: 10px;
  flex: 0 0 auto;
}

.route-controls label {
  display: grid;
  gap: 5px;
  min-width: 140px;
}

.route-controls select {
  height: 38px;
  padding: 0 34px 0 11px;
  color: var(--ink-soft);
}

.user-menu {
  position: relative;
  flex: 0 0 auto;
}

.avatar-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid color-mix(in srgb, var(--accent) 72%, var(--line));
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  font-size: 12px;
  font-weight: 860;
  letter-spacing: 0;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

.avatar-button:hover {
  border-color: var(--accent-strong);
}

.menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 236px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-float);
}

.menu-popover[hidden] {
  display: none;
}

.menu-profile {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line-soft);
  padding: 12px;
}

.menu-profile strong {
  color: var(--ink);
  font-size: 13px;
}

.menu-profile span {
  color: var(--muted);
  font-size: 12px;
}

.menu-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 720;
  text-align: left;
}

.menu-popover button:hover {
  background: var(--surface-soft);
}

.menu-popover svg {
  width: 16px;
  height: 16px;
  color: var(--muted-strong);
}

.thread-strip {
  grid-row: 2;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted-strong);
  background: var(--thread-bg);
  padding: 0 28px;
  font-size: 12px;
  font-weight: 720;
}

.thread-strip div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.thread-strip svg {
  width: 15px;
  height: 15px;
  color: #7e8ca0;
}

.messages {
  grid-row: 3;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 30px 34px;
  scroll-behavior: smooth;
}

.new-message-pill {
  position: absolute;
  left: 50%;
  bottom: 100px;
  z-index: 12;
  min-height: 36px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 999px;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft));
  padding: 0 14px;
  font-size: 12px;
  font-weight: 820;
  box-shadow: var(--shadow-soft);
  transform: translateX(-50%);
}

.new-message-pill[hidden] {
  display: none;
}

.new-message-pill:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  width: min(680px, 100%);
  min-height: 100%;
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.empty-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
}

.empty-state h2 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 22px;
}

.empty-state p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(560px, 100%);
}

.prompt-chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--surface);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.3;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.prompt-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-self: flex-start;
  gap: 10px;
  width: min(860px, 100%);
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
  align-self: flex-end;
}

.message.service {
  align-self: center;
  width: min(640px, 100%);
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted-strong);
  background: var(--surface);
  font-size: 10px;
  font-weight: 850;
}

.message.user .message-avatar {
  grid-column: 2;
  color: #dffcf5;
  border-color: color-mix(in srgb, var(--user-avatar-bg) 72%, var(--line));
  background: var(--user-avatar-bg);
}

.message.assistant .message-avatar {
  color: var(--assistant-avatar-ink);
  background: var(--assistant-avatar-bg);
}

.message.service .message-avatar {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.message-stack {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.message.user .message-stack {
  grid-column: 1;
  grid-row: 1;
  justify-items: end;
}

.message-head {
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 24px;
}

.message.user .message-head {
  justify-content: flex-end;
}

.message-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-action {
  width: 27px;
  height: 25px;
}

.message-action svg {
  width: 14px;
  height: 14px;
}

.bubble {
  border: 1px solid var(--assistant-bubble-border);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--assistant-bubble-bg);
  padding: 14px 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.user .bubble {
  max-width: 760px;
  border-color: var(--user-bubble-border);
  color: var(--user-bubble-ink);
  background: var(--user-bubble-bg);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.service .bubble {
  border-color: #d7e7e4;
  color: #315451;
  background: var(--accent-soft);
  padding: 9px 12px;
  font-size: 12px;
  box-shadow: none;
}

.streaming .bubble {
  border-color: var(--streaming-bubble-border);
  background: var(--streaming-bubble-bg);
}

.stream-status {
  gap: 8px;
  color: var(--accent-strong);
  font-weight: 720;
}

.stream-status::before {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
  content: "";
}

.typing-bars {
  gap: 4px;
  margin-top: 12px;
}

.typing-bars span {
  width: 18px;
  height: 4px;
  border-radius: 4px;
  background: rgba(15, 118, 110, 0.22);
  animation: typing-pulse 1.2s ease-in-out infinite;
}

.typing-bars span:nth-child(2) {
  animation-delay: 120ms;
}

.typing-bars span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typing-pulse {
  50% {
    background: rgba(15, 118, 110, 0.62);
  }
}

.stream-toggle {
  min-height: 30px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: var(--radius);
  color: var(--accent-strong);
  background: var(--surface);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 780;
}

.stream-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.stream-detail {
  overflow: auto;
  max-height: 260px;
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--surface);
  padding: 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.composer {
  grid-row: 4;
  flex: 0 0 auto;
  border-top: 1px solid var(--line-soft);
  background: var(--topbar-bg);
  padding: 18px 28px calc(22px + env(safe-area-inset-bottom));
  backdrop-filter: blur(14px);
}

.composer-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  width: min(980px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px;
  box-shadow: var(--shadow-soft);
}

.composer textarea {
  min-height: 44px;
  max-height: 180px;
  border-color: transparent;
  resize: none;
  padding: 11px 12px;
  line-height: 1.45;
}

.composer textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 780;
  line-height: 1;
  transition:
    transform 120ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
}

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

.button-secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.button-primary {
  color: var(--send-ink);
  background: var(--send-bg);
}

.button-primary:hover {
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.18);
}

.button-send {
  min-width: 92px;
  height: 44px;
  color: var(--send-ink);
  background: var(--send-bg);
}

.button-send:hover {
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.18);
}

.button-send svg {
  width: 16px;
  height: 16px;
}

.inspector {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(440px, calc(100vw - 28px));
  min-height: 100vh;
  max-height: 100vh;
  border-left: 1px solid var(--line);
  background: var(--drawer-bg);
  padding: 0;
  box-shadow: var(--shadow-float);
  transform: translateX(104%);
  transition: transform 220ms ease;
}

.settings-open .inspector {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  backdrop-filter: blur(3px);
}

.drawer-overlay[hidden] {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 16px;
}

.drawer-header h2 {
  font-size: 16px;
}

.drawer-content {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 16px;
}

.panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.panel-package {
  background: linear-gradient(180deg, var(--accent-soft), var(--surface));
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 142px;
  min-height: 24px;
  border-radius: 999px;
  color: #82490e;
  background: var(--amber-soft);
  padding: 0 9px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 820;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-green {
  color: #166534;
  background: var(--green-soft);
}

.pill-blue {
  color: #1d4ed8;
  background: var(--blue-soft);
}

.path-box {
  overflow: hidden;
  min-height: 54px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--muted-strong);
  background: var(--surface-soft);
  padding: 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.checks,
.detail-list,
.environment-form,
.environment-list,
.user-form,
.user-list,
.activity-list {
  display: grid;
  gap: 8px;
}

.check-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
}

.check-row span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-dot {
  box-shadow: none;
}

.detail-list {
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
}

.detail-list dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  min-height: 38px;
  padding: 0 11px;
  color: var(--ink-soft);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--surface-soft);
  padding: 9px 10px;
  text-align: left;
}

.theme-toggle strong {
  display: block;
  font-size: 13px;
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 32%, transparent);
  transition: background 160ms ease;
}

.switch-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
  transition: transform 160ms ease;
}

.theme-toggle[aria-checked="true"] .switch-track {
  background: var(--accent);
}

.theme-toggle[aria-checked="true"] .switch-track span {
  transform: translateX(18px);
}

.split-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.environment-form,
.daemon-setup,
.environment-list,
.user-form,
.user-list {
  display: grid;
  gap: 8px;
}

.environment-item,
.user-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 8px 9px;
}

.environment-item strong,
.environment-item span,
.user-item strong,
.user-item span {
  display: block;
}

.environment-item strong,
.user-item strong {
  color: var(--ink-soft);
  font-size: 13px;
}

.environment-item span,
.user-item span {
  color: var(--muted);
  font-size: 12px;
}

.environment-item button,
.user-item button {
  min-width: 34px;
  min-height: 32px;
  padding: 0 10px;
}

.environment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 6px;
}

.activity-item,
.activity-empty,
.user-empty {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 9px 10px;
}

.activity-item strong,
.activity-item span {
  display: block;
}

.activity-item strong {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item span,
.activity-empty,
.user-empty {
  color: var(--muted);
  font-size: 12px;
}

.command-field {
  min-height: 82px;
  resize: vertical;
  padding: 10px 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
}

.inline-status {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: var(--overlay);
  padding: 18px;
  backdrop-filter: blur(5px);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-dialog {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-float);
}

.confirm-dialog h2 {
  font-size: 16px;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.button-danger {
  color: #ffffff;
  background: #b91c1c;
}

.button-danger:hover {
  background: #991b1b;
  box-shadow: 0 12px 24px rgba(185, 28, 28, 0.18);
}

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

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

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  body {
    font-size: 15px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: 100dvh;
    isolation: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    display: flex;
    width: min(340px, calc(100vw - 42px));
    height: 100dvh;
    max-height: none;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 14px;
    box-shadow: var(--shadow-float);
    transform: translateX(-104%);
    transition: transform 220ms ease;
  }

  body.sessions-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-header {
    min-height: 38px;
    margin-bottom: 14px;
  }

  .mobile-close-button,
  .mobile-nav-button {
    display: grid;
  }

  .mobile-nav-button {
    grid-row: 1;
    color: var(--muted-strong);
    border-color: var(--line);
    background: var(--surface);
  }

  .mobile-settings-button {
    grid-column: 3;
  }

  .title-group {
    grid-row: 1;
    grid-column: 2;
  }

  .new-session-button {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    margin-bottom: 14px;
  }

  .search-box,
  .archive-toggle {
    display: block;
  }

  .session-list {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding-bottom: 0;
  }

  .session-item {
    min-height: 70px;
  }

  .session-empty {
    min-height: 70px;
    padding: 18px 12px;
  }

  .sidebar-footer {
    display: grid;
  }

  .conversation-shell {
    height: 100dvh;
    min-height: 0;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    min-height: auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .user-menu {
    position: relative;
    grid-row: 1;
    grid-column: 4;
    top: auto;
    right: auto;
  }

  .route-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    padding-right: 0;
  }

  .route-controls label {
    min-width: 0;
  }

  .thread-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: auto;
    padding: 10px 16px;
  }

  .thread-strip div {
    overflow: hidden;
  }

  .thread-strip div span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .messages {
    gap: 14px;
    padding: 18px 14px 20px;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .composer {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .composer-frame {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 6px;
  }

  .composer textarea {
    min-height: 44px;
    padding: 10px;
  }

  .button-send {
    width: 46px;
    min-width: 46px;
    height: 44px;
    padding: 0;
  }

  .button-send span {
    display: none;
  }

  .inspector {
    width: min(420px, calc(100vw - 16px));
  }
}

@media (max-width: 560px) {
  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .topbar {
    gap: 12px;
    padding: 10px;
  }

  h1 {
    font-size: 19px;
  }

  .route-controls label span {
    font-size: 12px;
  }

  .route-controls select {
    height: 42px;
  }

  .thread-strip {
    display: none;
  }

  .messages {
    padding: 16px 10px 18px;
  }

  .message,
  .message.user {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .message-avatar {
    display: none;
  }

  .message.user .message-stack {
    grid-column: auto;
  }

  .bubble {
    padding: 12px;
    line-height: 1.5;
  }

  .empty-state {
    align-content: start;
    padding-top: 12px;
  }

  .new-message-pill {
    bottom: 88px;
  }

  .confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
