:root {
  color-scheme: dark;
  --bg: #0d1015;
  --glass: rgba(35, 38, 45, 0.72);
  --glass-strong: rgba(43, 46, 53, 0.9);
  --sidebar: rgba(25, 27, 32, 0.72);
  --elevated: rgba(255, 255, 255, 0.055);
  --elevated-hover: rgba(255, 255, 255, 0.085);
  --line: rgba(255, 255, 255, 0.105);
  --line-soft: rgba(255, 255, 255, 0.065);
  --text: #f5f5f7;
  --secondary: #c7c7cc;
  --muted: #8e8e93;
  --blue: #0a84ff;
  --blue-light: #64d2ff;
  --green: #30d158;
  --yellow: #ffd60a;
  --danger: #ff453a;
  --chat-gutter: clamp(15px, 4vw, 65px);
  --shadow: 0 36px 100px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.32);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { min-height: 20px; color: #ff6961; }

.wallpaper {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(5, 8, 14, .94), rgba(26, 28, 38, .84)),
    radial-gradient(circle at 48% 45%, #283447, transparent 58%);
  pointer-events: none;
}
.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.14'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}
.aurora { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .42; }
.aurora-blue { width: 56vw; height: 54vw; left: -17vw; bottom: -26vw; background: #117adf; }
.aurora-violet { width: 45vw; height: 45vw; right: -10vw; top: -19vw; background: #8d5cff; opacity: .3; }
.aurora-silver { width: 38vw; height: 24vw; left: 38vw; top: 25vh; background: #a7c4de; opacity: .12; }

.liquid-glass {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .1);
  backdrop-filter: blur(44px) saturate(160%);
  -webkit-backdrop-filter: blur(44px) saturate(160%);
}
.eyebrow {
  margin: 0 0 8px;
  color: #8fc9ff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
}

/* Login */
.login-shell { position: relative; z-index: 1; display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 44px; border-radius: 30px; text-align: center; }
.login-card h1 { margin: 8px 0 8px; font-size: 36px; letter-spacing: -.04em; }
.login-card > p.muted { max-width: 330px; margin: 0 auto; line-height: 1.5; }
.login-icon {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 0 auto 24px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 23px;
  background: linear-gradient(145deg, rgba(255,255,255,.3), rgba(255,255,255,.06)), linear-gradient(160deg, #268cff, #6d5dfc);
  box-shadow: 0 17px 38px rgba(0, 95, 255, .28), inset 0 1px 1px rgba(255,255,255,.5);
}
.spark { position: absolute; display: block; background: white; border-radius: 999px; box-shadow: 0 0 16px rgba(255,255,255,.7); }
.spark-one { width: 5px; height: 38px; left: 36px; top: 20px; transform: rotate(34deg); }
.spark-two { width: 34px; height: 5px; left: 21px; top: 37px; transform: rotate(34deg); }
.spark-three { width: 12px; height: 12px; left: 32px; top: 33px; }
.login-card form { display: grid; gap: 11px; margin-top: 30px; text-align: left; }
.login-card label { padding-left: 3px; }

/* Shared controls */
label { color: var(--secondary); font-size: 12px; }
input, textarea, select {
  color: var(--text);
  background: rgba(4, 6, 10, .32);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 11px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(10,132,255,.75);
  background: rgba(4,6,10,.44);
  box-shadow: 0 0 0 3px rgba(10,132,255,.17);
}
input { padding: 12px 13px; }
.primary {
  padding: 10px 16px;
  color: white;
  font-weight: 650;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 11px;
  background: linear-gradient(180deg, #2394ff, #0878e7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 7px 18px rgba(0,98,220,.22);
  transition: filter .15s, transform .15s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(.98); }
.wide { width: 100%; margin-top: 7px; }

/* Window and sidebar */
.app-window {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  width: calc(100vw - 28px);
  height: calc(100vh - 28px);
  margin: 14px;
  overflow: hidden;
  border-radius: 22px;
}
.mobile-conversation-button, .mobile-navigation, .drawer-backdrop { display: none; }
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 13px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  box-shadow: inset -1px 0 rgba(0,0,0,.18);
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 3px 6px 15px; }
.brand-glyph {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 12px;
  font-size: 18px;
  font-weight: 750;
  background: linear-gradient(145deg, rgba(255,255,255,.22), rgba(255,255,255,.04)), linear-gradient(145deg, #168dff, #6857ee);
  box-shadow: inset 0 1px rgba(255,255,255,.24), 0 7px 18px rgba(0,0,0,.18);
}
.brand-row strong, .brand-row span { display: block; }
.brand-row strong { font-size: 14px; }
.brand-row span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.search-field { position: relative; margin: 0 3px 13px; }
.search-field svg {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 2;
}
.search-field input { width: 100%; height: 35px; padding: 7px 9px 7px 33px; border-radius: 9px; font-size: 12px; background: rgba(255,255,255,.055); }
.search-field input::-webkit-search-cancel-button { filter: invert(1); opacity: .55; }
.main-navigation { display: grid; gap: 3px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  color: var(--secondary);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}
.nav-button:hover { color: var(--text); background: var(--elevated); }
.nav-button.active {
  color: white;
  border-color: rgba(255,255,255,.07);
  background: linear-gradient(180deg, rgba(255,255,255,.13), rgba(255,255,255,.085));
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 2px 8px rgba(0,0,0,.12);
}
.nav-icon { position: relative; display: block; width: 23px; height: 23px; border-radius: 6px; background: linear-gradient(180deg, #5bb4ff, #0878dd); box-shadow: inset 0 1px rgba(255,255,255,.3); }
.chat-icon::before { content: ""; position: absolute; inset: 6px 5px 7px; border: 1.5px solid white; border-radius: 5px; }
.chat-icon::after { content: ""; position: absolute; left: 7px; bottom: 4px; width: 5px; height: 5px; border-left: 1.5px solid white; transform: rotate(-28deg); }
.activity-icon { background: linear-gradient(180deg, #b09cff, #7456e8); }
.activity-icon::before { content: ""; position: absolute; left: 5px; right: 5px; bottom: 5px; height: 10px; border-left: 2px solid white; border-bottom: 2px solid white; }
.activity-icon::after { content: ""; position: absolute; left: 7px; top: 7px; width: 9px; height: 7px; border-top: 2px solid white; border-right: 2px solid white; transform: skewY(-30deg); }
.key-icon { background: linear-gradient(180deg, #ffb340, #f17715); }
.key-icon::before { content: ""; position: absolute; width: 7px; height: 7px; left: 5px; top: 7px; border: 2px solid white; border-radius: 50%; }
.key-icon::after { content: ""; position: absolute; width: 8px; height: 2px; right: 4px; top: 11px; background: white; box-shadow: 3px 3px white; transform: rotate(-35deg); }
.node-icon { background: linear-gradient(180deg, #47d7a1, #138e6f); }
.node-icon::before { content: ""; position: absolute; inset: 5px; border: 1.7px solid white; border-radius: 4px; }
.node-icon::after { content: "···"; position: absolute; top: 1px; left: 5px; color: white; font-size: 13px; font-weight: 800; letter-spacing: 1px; }
.conversation-section { display: flex; flex: 1; min-height: 0; flex-direction: column; padding-top: 13px; transition: opacity .18s; }
.conversation-section.view-muted { opacity: .5; }
.section-label-row { display: flex; align-items: center; justify-content: space-between; height: 30px; padding: 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.round-button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0 0 1px;
  color: var(--secondary);
  font-size: 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
}
.round-button:hover { color: white; border-color: var(--line); background: var(--elevated); }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.conversation-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin: 2px 0;
  padding: 8px 7px;
  color: var(--secondary);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}
.conversation-item:hover { color: white; background: var(--elevated); }
.conversation-item.active { color: white; border-color: rgba(10,132,255,.2); background: rgba(10,132,255,.2); }
.conversation-symbol { width: 7px; height: 7px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; }
.conversation-item.active .conversation-symbol { border-color: #8fc9ff; background: #62b5ff; box-shadow: 0 0 8px rgba(10,132,255,.6); }
.conversation-copy { min-width: 0; }
.conversation-copy strong, .conversation-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy strong { font-size: 12px; font-weight: 550; }
.conversation-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.conversation-empty { margin: 18px 8px; color: var(--muted); font-size: 11px; text-align: center; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 5px 0; border-top: 1px solid var(--line-soft); }
.model-mini-status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.model-mini-status .status-dot { width: 7px; height: 7px; background: var(--green); }
.model-mini-status strong, .model-mini-status span { display: block; }
.model-mini-status strong { font-size: 11px; }
.model-mini-status div span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.logout-button { padding: 6px 7px; color: var(--muted); font-size: 10px; border: 0; border-radius: 7px; background: transparent; }
.logout-button:hover { color: white; background: var(--elevated); }

/* Workspace */
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: rgba(32,34,40,.42); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 99px; gap: 20px; padding: 20px 27px; border-bottom: 1px solid var(--line); background: rgba(30,32,38,.38); }
.topbar-copy { min-width: 0; }
.topbar h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 21px; font-weight: 650; letter-spacing: -.025em; }
.view-description { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0,0,0,.14);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 8px currentColor; }
.status-pill.online { color: #79e891; }
.status-pill.online .status-dot { background: var(--green); }
.status-pill.offline { color: #ff817a; }
.status-pill.offline .status-dot { background: var(--danger); }
.toolbar-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  color: var(--secondary);
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.045);
  box-shadow: inset 0 1px rgba(255,255,255,.035);
}
.toolbar-button:hover { color: white; background: var(--elevated-hover); }
.toolbar-button svg { width: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.toolbar-button.danger:hover { color: #ff817a; border-color: rgba(255,69,58,.28); background: rgba(255,69,58,.09); }
.toolbar-button:disabled { opacity: .45; }
.workspace-view { display: flex; flex: 1; min-height: 0; flex-direction: column; }

/* Empty and conversation */
.empty-state { display: grid; place-items: center; align-content: center; flex: 1; padding: 40px; text-align: center; }
.empty-state .eyebrow { margin-top: 28px; }
.empty-state h3 { margin: 0 0 7px; font-size: clamp(25px, 3vw, 34px); font-weight: 680; letter-spacing: -.045em; }
.empty-state > p:not(.eyebrow) { max-width: 530px; margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.hero-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 29px;
  background: linear-gradient(145deg, rgba(255,255,255,.24), rgba(255,255,255,.025)), linear-gradient(145deg, #2499ff, #7866f7);
  box-shadow: inset 0 1px rgba(255,255,255,.36), 0 24px 55px rgba(15,102,245,.28);
  transform: rotate(-3deg);
}
.hero-orb::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255,255,255,.16); border-radius: 23px; }
.hero-orb span { font-size: 39px; font-weight: 750; text-shadow: 0 4px 14px rgba(0,0,0,.26); transform: rotate(3deg); }
.chat-view { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.message-list { flex: 1; overflow-y: auto; padding: 27px var(--chat-gutter); scroll-behavior: smooth; }
.message-list.is-streaming { scroll-behavior: auto; }
.message { display: flex; gap: 13px; width: min(1120px, 100%); margin: 0 0 26px; }
.message-avatar {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  color: white;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 9px;
  background: linear-gradient(145deg, #2697ff, #7763e9);
  box-shadow: inset 0 1px rgba(255,255,255,.25);
}
.message.user .message-avatar { color: #202127; background: linear-gradient(145deg, #e9e9ee, #a9abb2); }
.message-body { min-width: 0; padding-top: 1px; }
.message-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.message-meta strong { font-size: 12px; }
.message-meta span { color: var(--muted); font-size: 9px; }
.message-content { color: #e7e7ea; font-size: 14px; line-height: 1.72; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.user .message-content { color: var(--secondary); }
.message.pending .message-content::after { content: "▋"; color: #74baff; animation: blink .8s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer {
  margin: 0 var(--chat-gutter) 20px;
  padding: 10px 11px 9px 15px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 17px;
  background: rgba(22,24,29,.68);
  box-shadow: 0 17px 55px rgba(0,0,0,.27), inset 0 1px rgba(255,255,255,.05);
  backdrop-filter: blur(24px) saturate(140%);
}
.composer textarea { width: 100%; max-height: 180px; resize: none; padding: 7px 0 10px; border: 0; background: transparent; line-height: 1.5; }
.composer textarea:focus { box-shadow: none; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.queue-status { color: var(--muted); font-size: 10px; white-space: nowrap; }
.queue-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: #9fd0ff; font-size: 20px; border: 1px solid rgba(41,151,255,.32); border-radius: 10px; background: rgba(41,151,255,.11); }
.queue-button:disabled { opacity: .42; }
.settings-row { display: flex; align-items: center; gap: 14px; }
.settings-row label { display: flex; align-items: center; gap: 7px; }
.settings-row select { padding: 4px 7px; font-size: 11px; }
.settings-row label:has(select) { min-width: 0; }
.settings-row label:has(select) select { max-width: 150px; }
.toggle input { display: none; }
.toggle span { position: relative; width: 29px; height: 17px; border-radius: 999px; background: #56585f; box-shadow: inset 0 1px 2px rgba(0,0,0,.28); transition: .18s; }
.toggle span::after { content: ""; position: absolute; width: 13px; height: 13px; top: 2px; left: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: .18s; }
.toggle input:checked + span { background: var(--blue); }
.toggle input:checked + span::after { left: 14px; }
.send-button { display: grid; place-items: center; width: 34px; height: 34px; color: white; font-size: 19px; border: 0; border-radius: 10px; background: linear-gradient(180deg, #2997ff, #087cf0); box-shadow: inset 0 1px rgba(255,255,255,.3), 0 6px 15px rgba(0,91,215,.22); }
.send-button:disabled { opacity: .35; }
.send-button.stop-button { color: #fff5f4; font-size: 13px; background: linear-gradient(180deg, #ff6259, #d9342c); box-shadow: inset 0 1px rgba(255,255,255,.28), 0 6px 15px rgba(174,31,25,.26); }

/* Usage and API Keys */
/* .management-view is a column flexbox (via .workspace-view); its direct
   children default to flex-shrink: 1, so on a short viewport the browser
   silently squeezes a card below the height its own content needs instead of
   growing the page. Since .content-card also clips with overflow: hidden,
   a squeezed card's overflow isn't just visually tight, it's invisible and
   unreachable -- no scrollbar appears anywhere to reveal it. flex-shrink: 0
   keeps every card and the summary grid at their natural height, so
   .management-view's own overflow-y: auto scrolls the page instead. */
.management-view { gap: 14px; overflow-y: auto; padding: 22px; }
.management-view > * { flex-shrink: 0; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-card, .content-card, .key-reveal {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  box-shadow: inset 0 1px rgba(255,255,255,.055), 0 10px 30px rgba(0,0,0,.11);
}
.summary-card { min-height: 119px; padding: 17px; }
.summary-card span, .summary-card strong, .summary-card small { display: block; }
.summary-card span { color: var(--secondary); font-size: 11px; }
.summary-card strong { margin: 15px 0 5px; font-size: 25px; letter-spacing: -.04em; }
.summary-card small { color: var(--muted); font-size: 9px; }
.content-card { overflow: hidden; }
.content-card-header { display: flex; align-items: center; justify-content: space-between; gap: 22px; min-height: 76px; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); }
.content-card-header h3 { margin: 0; font-size: 14px; }
.content-card-header p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.activity-list, .key-list { min-height: 170px; }
.activity-row, .key-row { display: flex; align-items: flex-start; gap: 13px; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); }
.activity-row:last-child, .key-row:last-child { border-bottom: 0; }
.activity-row:hover, .key-row:hover { background: rgba(255,255,255,.025); }
.request-indicator { width: 8px; height: 8px; margin-top: 5px; flex: 0 0 auto; border-radius: 50%; background: var(--danger); box-shadow: 0 0 9px rgba(255,69,58,.28); }
.request-indicator.success { background: var(--green); box-shadow: 0 0 9px rgba(48,209,88,.3); }
.activity-main, .key-main { min-width: 0; flex: 1; }
.activity-title, .key-title { display: flex; align-items: center; gap: 9px; }
.activity-title strong, .key-title strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.activity-title span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.activity-main p, .key-main p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.activity-main .response-preview { color: #b7b7bd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-metrics { min-width: 67px; text-align: right; }
.activity-metrics strong, .activity-metrics span { display: block; }
.activity-metrics strong { font-size: 12px; }
.activity-metrics span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.loading-row, .empty-list { display: grid; place-items: center; align-content: center; min-height: 170px; padding: 26px; color: var(--muted); font-size: 11px; text-align: center; }
.empty-list strong, .empty-list span { display: block; }
.empty-list strong { margin-bottom: 6px; color: var(--secondary); font-size: 12px; }
.keys-header { align-items: flex-end; }
.key-create-form { display: flex; gap: 8px; }
.key-create-form input { width: min(210px, 25vw); height: 36px; }
.key-create-form select { min-width: 150px; height: 36px; padding: 7px 10px; font-size: 11px; }
.key-create-form .primary { height: 36px; padding: 7px 12px; font-size: 11px; white-space: nowrap; }
.key-reveal { display: grid; grid-template-columns: minmax(170px, auto) minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 15px 17px; border-color: rgba(10,132,255,.35); background: linear-gradient(145deg, rgba(10,132,255,.16), rgba(100,210,255,.055)); }
.key-reveal strong { font-size: 12px; }
.key-reveal p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.key-reveal code { overflow-x: auto; padding: 10px; color: #9ed1ff; font-size: 10px; border-radius: 8px; background: rgba(0,0,0,.26); }
.key-reveal .primary { padding: 8px 11px; font-size: 10px; }
.key-badge { position: relative; width: 31px; height: 31px; flex: 0 0 auto; border-radius: 9px; background: linear-gradient(145deg, #ffb23f, #ec7219); box-shadow: inset 0 1px rgba(255,255,255,.3); }
.key-badge::before { content: ""; position: absolute; width: 8px; height: 8px; left: 7px; top: 8px; border: 2px solid white; border-radius: 50%; }
.key-badge::after { content: ""; position: absolute; width: 10px; height: 2px; right: 5px; top: 15px; background: white; box-shadow: 3px 3px white; transform: rotate(-38deg); }
.key-main code { display: block; margin-top: 6px; color: #c2c2c8; font-size: 10px; }
.state-label { padding: 2px 6px; color: var(--muted); font-size: 8px; border: 1px solid var(--line); border-radius: 999px; }
.state-label.active { color: #79e891; border-color: rgba(48,209,88,.22); background: rgba(48,209,88,.07); }
.key-row.revoked { opacity: .52; }
.danger-button { align-self: center; padding: 6px 9px; color: #ff817a; font-size: 10px; border: 1px solid rgba(255,69,58,.22); border-radius: 8px; background: rgba(255,69,58,.035); }
.danger-button:hover { background: rgba(255,69,58,.11); }

/* Nodes */
.node-list {
  min-height: 150px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.node-list:focus-visible { outline: 2px solid rgba(10,132,255,.72); outline-offset: -2px; }
.node-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 13px; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); }
.node-row:last-child { border-bottom: 0; }
.node-row:hover { background: rgba(255,255,255,.025); }
.node-row.disabled { opacity: .58; }
.node-indicator { width: 10px; height: 10px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px rgba(255,69,58,.32); }
.node-indicator.online { background: var(--green); box-shadow: 0 0 10px rgba(48,209,88,.35); }
.node-indicator.disabled { background: var(--muted); box-shadow: none; }
.node-main { flex: 1; min-width: 0; }
.node-title { display: flex; align-items: center; gap: 9px; }
.node-title strong { min-width: 0; font-size: 12px; overflow-wrap: anywhere; }
.node-main p, .node-main small { display: block; margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.node-main small { color: #aeb0b7; }
.node-actions { display: flex; flex: 0 0 auto; gap: 7px; align-items: center; }
.subtle-danger { background: rgba(255,69,58,.1); }
.node-key-update { display: flex; flex: 1 0 100%; align-items: end; gap: 8px; margin: 1px 0 0 23px; padding: 11px; border: 1px solid rgba(10,132,255,.22); border-radius: 10px; background: rgba(10,132,255,.06); }
.node-key-update label { display: grid; flex: 1; gap: 5px; min-width: 0; font-size: 10px; }
.node-key-update input { min-width: 0; height: 35px; font-size: 11px; }
.node-key-update .primary, .node-key-update .toolbar-button { height: 35px; padding: 7px 11px; white-space: nowrap; }
.node-create-form { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 12px 9px; padding: 16px 17px; }
.node-create-form label { display: grid; gap: 5px; min-width: 0; font-size: 10px; }
.node-create-form input, .node-create-form select { min-width: 0; height: 37px; font-size: 11px; }
.node-create-form .primary { align-self: end; height: 37px; padding: 7px 12px; white-space: nowrap; }
.node-form-actions { display: flex; grid-column: 1 / -1; align-items: end; justify-content: flex-end; gap: 8px; }
.node-form-actions .toolbar-button { height: 37px; padding: 7px 12px; white-space: nowrap; }
.node-key-update select { min-width: 0; height: 35px; font-size: 11px; }
.node-provider-tag { padding: 2px 7px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px; }
.node-models { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 5px 4px 9px; font-size: 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); }
.model-chip.disabled { opacity: .5; }
.model-chip span { color: var(--text); font-weight: 600; }
.model-chip code { padding: 0; color: var(--muted); font-size: 9px; background: none; }
.model-chip button { display: grid; place-items: center; width: 17px; height: 17px; padding: 0; color: var(--muted); font-size: 11px; line-height: 1; border: 0; border-radius: 50%; background: rgba(255,255,255,.06); cursor: pointer; }
.model-chip button:hover { color: var(--text); background: rgba(255,255,255,.12); }
.subtle-button { padding: 4px 10px; font-size: 10px; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 27px; transform: translateX(-50%); padding: 9px 14px; color: white; font-size: 11px; font-weight: 600; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(52,54,61,.9); box-shadow: 0 12px 35px rgba(0,0,0,.36), inset 0 1px rgba(255,255,255,.12); backdrop-filter: blur(20px); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: rgba(255,255,255,.17); background-clip: padding-box; }

@media (max-width: 820px) {
  html, body { width: 100%; height: 100%; overflow: hidden; }
  body { min-height: 100dvh; }
  button, input, textarea, select { touch-action: manipulation; }
  input, textarea, select { font-size: 16px; }

  .app-window {
    grid-template-columns: 1fr;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto calc(64px + env(safe-area-inset-bottom)) 0;
    width: min(86vw, 340px);
    min-height: 0;
    padding: max(16px, env(safe-area-inset-top)) 14px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: rgba(22, 24, 29, .97);
    box-shadow: 24px 0 65px rgba(0,0,0,.48);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .conversation-drawer-open .sidebar { transform: translateX(0); }
  .sidebar .main-navigation { display: none; }
  .conversation-section { flex: 1; }
  .conversation-section.view-muted { display: none; }
  .conversation-list { min-height: 0; overflow-y: auto; }
  .conversation-item { min-height: 44px; }
  .round-button { width: 44px; height: 44px; }
  .sidebar-footer { display: flex; }
  .logout-button { min-width: 44px; min-height: 44px; }

  .drawer-backdrop {
    position: fixed;
    z-index: 40;
    inset: 0 0 calc(64px + env(safe-area-inset-bottom));
    display: block;
    padding: 0;
    border: 0;
    background: rgba(0,0,0,.56);
    backdrop-filter: blur(3px);
  }
  .mobile-navigation {
    position: fixed;
    z-index: 60;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 5px 6px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: rgba(22,24,29,.94);
    box-shadow: 0 -12px 35px rgba(0,0,0,.28);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
  }
  .mobile-navigation .nav-button {
    min-width: 0;
    min-height: 54px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    font-size: 10px;
    text-align: center;
  }
  .mobile-navigation .nav-icon { width: 24px; height: 24px; }

  .workspace { height: 100%; min-height: 0; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar {
    min-height: 80px;
    gap: 10px;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  }
  .mobile-conversation-button {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    padding: 0;
    color: var(--secondary);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.045);
  }
  .mobile-conversation-button span,
  .mobile-conversation-button::before,
  .mobile-conversation-button::after {
    width: 18px;
    height: 1.5px;
    border-radius: 999px;
    background: currentColor;
  }
  .mobile-conversation-button::before, .mobile-conversation-button::after { position: absolute; content: ""; }
  .mobile-conversation-button::before { transform: translateY(-6px); }
  .mobile-conversation-button::after { transform: translateY(6px); }
  .topbar-copy { flex: 1; }
  .topbar h2 { font-size: 18px; }
  .view-description { max-width: 46vw; }
  .topbar-actions { flex: 0 0 auto; }
  .topbar-actions .toolbar-button { min-width: 44px; min-height: 44px; justify-content: center; }
  .topbar-actions .toolbar-button span { display: none; }
  .workspace-view { min-height: 0; }

  .empty-state { min-height: 0; padding: 28px 20px; }
  .hero-orb { width: 78px; height: 78px; border-radius: 24px; }
  .hero-orb span { font-size: 33px; }
  .message-list { min-height: 0; padding: 20px 14px; }
  .message { max-width: 100%; }
  .message:not(.pending) { content-visibility: auto; contain-intrinsic-size: auto 160px; }
  .message-body, .message-content { max-width: 100%; }
  .composer { margin: 0 10px 10px; padding: 9px 9px 8px 13px; }
  .composer-footer { align-items: end; }
  .send-button { width: 44px; height: 44px; flex: 0 0 auto; }
  .queue-button { width: 44px; height: 44px; flex: 0 0 auto; }
  .queue-status { display: none; }

  .management-view { padding: 13px; }
  .content-card, .key-reveal { min-width: 0; }
  .content-card-header.keys-header { align-items: stretch; flex-direction: column; }
  .key-create-form { flex-wrap: wrap; }
  .key-create-form input { width: 100%; }
  .key-create-form select { min-width: 0; flex: 1; }
  .key-create-form input, .key-create-form select, .key-create-form .primary { min-height: 44px; font-size: 16px; }
  .key-reveal { grid-template-columns: 1fr auto; }
  .key-reveal code { grid-column: 1 / -1; grid-row: 2; max-width: 100%; }
  .key-row { flex-wrap: wrap; }
  .key-main code, .activity-main .response-preview { overflow-wrap: anywhere; white-space: normal; }
  .danger-button { min-height: 44px; }
  .node-create-form { grid-template-columns: 1fr 1fr; }
  .node-create-form input, .node-create-form select { min-height: 44px; font-size: 16px; }
  .node-actions { flex-wrap: wrap; justify-content: flex-end; }
  .node-actions button, .node-key-update button, .node-form-actions button { min-height: 44px; }
  .node-key-update { flex-wrap: wrap; }
  .node-key-update input, .node-key-update select { min-height: 44px; font-size: 16px; }
  .node-models { max-width: 100%; }
  .model-chip { max-width: 100%; }
  .model-chip span, .model-chip code { overflow: hidden; text-overflow: ellipsis; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); text-align: center; }
}

@media (max-width: 640px) {
  .sidebar { width: min(90vw, 330px); }
  .node-list { max-height: none; }
  .node-row { flex-wrap: wrap; gap: 10px; padding: 14px; }
  .node-main { flex-basis: calc(100% - 24px); }
  .node-actions { width: 100%; padding-left: 23px; justify-content: flex-start; }
  .node-key-update { margin-left: 0; }
}

@media (max-width: 520px) {
  .view-description { max-width: 52vw; }
  .status-pill { display: none; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 87px; }
  .summary-card strong { margin: 9px 0 3px; }
  .content-card-header { align-items: stretch; flex-direction: column; gap: 12px; }
  .content-card-header .toolbar-button { min-height: 44px; justify-content: center; }
  .activity-row { gap: 9px; padding: 13px; }
  .activity-title { align-items: flex-start; flex-direction: column; gap: 3px; }
  .activity-metrics { min-width: 50px; }
  .settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }
  .settings-row label { min-width: 0; }
  .settings-row label:has(select) { display: grid; align-items: center; grid-template-columns: auto minmax(0, 1fr); }
  .settings-row label:has(select) select { width: 100%; max-width: none; min-height: 36px; padding: 5px 7px; font-size: 16px; }
  .toggle { min-height: 36px; }
  .key-create-form { display: grid; grid-template-columns: 1fr; }
  .key-create-form select, .key-create-form .primary { width: 100%; }
  .key-reveal { grid-template-columns: 1fr; }
  .key-reveal code { grid-column: 1; grid-row: auto; }
  .key-reveal .primary { min-height: 44px; }
  .node-create-form { grid-template-columns: 1fr; }
  .node-form-actions { display: grid; grid-template-columns: 1fr; }
  .node-actions { padding-left: 0; }
  .node-key-update { align-items: stretch; flex-direction: column; }
  .message { gap: 9px; }
  .message-avatar { width: 28px; height: 28px; }
  .login-shell { min-height: 100dvh; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); }
  .login-card { padding: 34px 25px; }
}

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