/* ryra web UI. Dark, amber-accented, laid out like a chat app:
   fixed sidebar on the left, conversation column in the middle.
   Type and accents follow the ryra site brand
   (ryra/site/src/styles/custom.css); the warm dark backgrounds are
   this app's own and intentionally kept. */

:root {
  /* Brand palette (subset). */
  --snow: #f4ede2;
  --amber: #d97a3a;
  --ember: #c25a2c;
  --ink: #1a1410;

  --bg: #1c1c1a;
  --bg-sidebar: #151513;
  --bg-input: #262623;
  --bg-hover: #2a2a27;
  --border: #34342f;
  --text: var(--snow);
  --text-dim: #a39b8b;
  --accent: var(--amber);
  --accent-soft: rgba(217, 122, 58, 0.14);
  --running: #4ade80;
  --stopped: #facc15;
  --danger: #f87171;

  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

code,
pre {
  font-family: var(--mono);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.shell {
  display: flex;
  /* 100vh on mobile is the *large* viewport (it counts the space behind the
     URL bar), so the composer ends up below the fold and you have to scroll
     down to the chat. 100dvh tracks the actually-visible height. vh stays as a
     fallback for browsers without dvh. */
  height: 100vh;
  height: 100dvh;
  /* Pin the whole app to the viewport: the transcript scrolls *inside*
     `.chat-scroll`, never the page body. Without this, a tall transcript grows
     the column past the viewport and the page itself scrolls, carrying the chat
     header (and its mobile sidebar toggle) off-screen. */
  overflow: hidden;
}

/* ---------- sidebar ---------- */

.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  /* Animates the desktop collapse (margin-left slide). The mobile media query
     overrides this with a transform transition for its off-canvas drawer. */
  transition: margin-left 0.22s ease;
  /* The sidebar itself doesn't scroll: the brand (top) and footer (bottom) are
     fixed, and only `.sidebar-scroll` between them scrolls -- so settings /
     health / hostname never move with the lists. */
  overflow: hidden;
}

/* Brand and footer flank the scroll region at fixed size. */
.sidebar-brand {
  flex-shrink: 0;
}

/* The one scroll region: registries, services, tests, and chats flow together
   here and this is the only thing in the sidebar that scrolls. */
.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 10px;
}

/* Same 26x26 mark as the site topbar. */
.sidebar-brand .brand-logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.sidebar-brand .wordmark {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.sidebar-brand .tag {
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.section-actions {
  display: flex;
  gap: 2px;
  visibility: hidden;
}

.sidebar-section:hover .section-actions {
  visibility: visible;
}

.icon-btn {
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* SVG glyph inside an icon button: inherits the button's color via
   currentColor and sits on the text baseline like the unicode glyphs. */
.fb-icon,
.health-icon {
  width: 15px;
  height: 15px;
  display: block;
}

.service-list {
  padding: 0 8px 8px;
}

.section-icon {
  color: var(--accent);
}

.history-list {
  padding: 0 8px 8px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.history-status {
  flex-shrink: 0;
  width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Blue, not green: an idle chat session shouldn't read as a running
   service (those are green dots in the Services list above). */
.history-dot.ready {
  background: #60a5fa;
  box-shadow: 0 0 4px rgba(96, 165, 250, 0.45);
}

.history-dot.perm {
  width: auto;
  height: auto;
  border-radius: 0;
  font-size: 11px;
  font-weight: 700;
  color: #f59e0b;
  animation: perm-pulse 1.5s ease-in-out infinite;
}

@keyframes perm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.history-row:hover {
  background: var(--bg-hover);
}

.history-row.active {
  background: var(--bg-input);
}

.history-open {
  flex: 1;
  min-width: 0;
  padding: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-agent {
  font-size: 11px;
  color: var(--text-dim);
}

.history-del {
  padding: 0 4px;
  border-radius: 4px;
  color: var(--text-dim);
  visibility: hidden;
}

.history-row:hover .history-del,
.test-sidebar-row:hover .history-del {
  visibility: visible;
}

.history-del:hover {
  color: var(--danger);
}

.service-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.service-row:hover {
  background: var(--bg-hover);
}

/* Registries: custom service sources, listed above Services. The default
   registry is implicit and never shown here, mirroring `ryra registry list`. */
.registry-list {
  padding: 0 8px 8px;
}

.registry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.registry-row:hover {
  background: var(--bg-hover);
}

.registry-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-count {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.registry-row:hover .history-del {
  visibility: visible;
}

.registry-dialog {
  background: var(--bg-sidebar);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 380px;
  width: 90vw;
  flex-direction: column;
  gap: 10px;
}

.registry-dialog[open] {
  display: flex;
}

.registry-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.registry-dialog h3 {
  margin: 0;
  font-size: 16px;
}

.registry-dialog p {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.registry-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: inherit;
  font-size: 13px;
}

.registry-input:focus {
  outline: none;
  border-color: var(--accent);
}

.registry-add-btn {
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.registry-add-btn:hover {
  background: var(--accent);
  color: #1a1a17;
}

.registry-cancel-btn {
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.registry-cancel-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.gh-connect-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.gh-connect-btn:hover {
  border-color: var(--accent);
}

.gh-icon {
  flex-shrink: 0;
}

.gh-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 30vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.gh-hint {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gh-cmd {
  font-family: monospace;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  color: var(--text);
  align-self: flex-start;
}

.gh-owner-select {
  width: 100%;
  padding: 5px 8px;
  margin-bottom: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
}

.gh-repo-sublist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gh-repo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.gh-repo-row:hover {
  background: var(--bg-hover);
}

.gh-repo-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-repo-private {
  flex-shrink: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.running {
  background: var(--running);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.status-dot.stopped {
  background: var(--stopped);
}

.service-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Upgrade availability: a marker, not a colour state, so it reads the same
   whether the service is running or stopped. */
.upgrade-marker {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.service-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.sidebar-empty,
.sidebar-error {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.sidebar-error {
  color: var(--danger);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  /* Fixed at the bottom, outside the scroll region. */
  flex-shrink: 0;
}

.linklike {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.linklike:hover {
  color: var(--text);
}

/* The walkthrough re-entry sits in the footer; accent-colored so an
   unfinished setup is easy to spot and get back to. */
.finish-setup {
  color: var(--accent);
}

.finish-setup:hover {
  color: var(--accent);
  opacity: 0.85;
}

/* The box's hostname, right-aligned in the footer opposite the icons. */
.footer-host {
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- chat ---------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Let the column be shorter than its content so `.chat-scroll` (flex:1) can
     take the leftover height and scroll, instead of the column growing and
     pushing the composer below the fold. */
  min-height: 0;
  /* Sits last so the detail panel can dock beside the left sidebar. */
  order: 2;
}

/* Floats just above the composer (anchored to its wrapper, which is
   position:relative), centered, when the transcript is scrolled up. Clicking
   it snaps back to the newest message. bottom:100% keeps it clear of the
   input at any input height. */
.jump-latest {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.jump-latest:hover {
  border-color: var(--accent);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 24px 0;
  min-height: 22px;
}

/* Slides the sidebar out on narrow screens; desktop never shows it. */
.sidebar-toggle {
  display: none;
  margin-right: auto;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 17px;
  color: var(--text-dim);
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Desktop collapse toggle. Hidden by default (incl. mobile, which uses the
   off-canvas `.sidebar-toggle` instead); shown only on desktop below. */
.sidebar-collapse-toggle {
  display: none;
  margin-right: auto;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 17px;
  color: var(--text-dim);
}

.sidebar-collapse-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Desktop only: let the user slide the sidebar away for a plain chat window.
   Scoped above the mobile breakpoint so a persisted `collapsed` state can
   never interfere with the off-canvas drawer on phones. */
@media (min-width: 721px) {
  .sidebar-collapse-toggle {
    display: block;
  }

  .shell.sidebar-collapsed .sidebar {
    /* Slides the fixed-width (272px) sidebar fully off the left edge; the chat
       column reclaims the space. */
    margin-left: -272px;
  }
}

.agent-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.agent-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
}

.agent-select:focus {
  border-color: var(--accent);
}

.chat-scroll {
  flex: 1;
  /* min-height:0 is the load-bearing line: a flex item's default min-height is
     its content, so without this the transcript can't shrink and `overflow-y`
     never engages -- it grows the page instead. */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-column {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-greeting {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* Side gutter so the headline/blurb never run wider than the composer
     below them (which is inset from the screen edge), especially on mobile. */
  padding: 0 24px;
  color: var(--text-dim);
  /* Fades in once we know the state is genuinely a fresh chat, so it
     doesn't pop in and get replaced while an existing chat is loading. */
  animation: greeting-fade-in 0.35s ease both;
}

@keyframes greeting-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.chat-greeting h1 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}

.chat-greeting p {
  margin: 0;
  max-width: 420px;
  text-align: center;
  font-size: 14px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  max-width: 540px;
  margin-top: 16px;
}

/* Faint hint text, not buttons: no box, just dim suggestions that brighten
   on hover. */
.suggestion {
  background: none;
  border: none;
  padding: 2px 4px;
  font: inherit;
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.7;
  cursor: pointer;
  text-align: left;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.suggestion:hover {
  opacity: 1;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg {
  display: flex;
}

.msg.user {
  justify-content: flex-end;
}

.msg.user .bubble {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  max-width: 80%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 0;
}

.msg.assistant .bubble {
  padding: 2px 0;
  max-width: 100%;
  white-space: pre-wrap;
}

.msg.assistant .avatar {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}
.msg.assistant .avatar svg {
  width: 22px;
  height: 22px;
}

/* Markdown bubbles get real block layout; the plain-text bubbles keep
   pre-wrap. Without this override the newlines pulldown-cmark emits
   between tags would render as extra blank lines. */
.bubble.markdown {
  white-space: normal;
  line-height: 1.55;
}

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

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

.bubble.markdown p,
.bubble.markdown ul,
.bubble.markdown ol,
.bubble.markdown table,
.bubble.markdown pre,
.bubble.markdown blockquote {
  margin: 8px 0;
}

.bubble.markdown h1,
.bubble.markdown h2,
.bubble.markdown h3,
.bubble.markdown h4,
.bubble.markdown h5,
.bubble.markdown h6 {
  margin: 16px 0 6px;
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.bubble.markdown h1 {
  font-size: 23px;
}

.bubble.markdown h2 {
  font-size: 19px;
}

.bubble.markdown h3 {
  font-size: 17px;
}

.bubble.markdown ul,
.bubble.markdown ol {
  padding-left: 22px;
}

.bubble.markdown li {
  margin: 2px 0;
}

.bubble.markdown code {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

.bubble.markdown pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}

.bubble.markdown pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}

/* Tables follow the site's docs styling: mono uppercase headers and
   hairline row separators, no cell borders. */
.bubble.markdown table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.bubble.markdown th,
.bubble.markdown td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.bubble.markdown thead th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.bubble.markdown tbody td {
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
}

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

.bubble.markdown blockquote {
  border-left: 2px solid var(--ember);
  padding: 2px 0 2px 16px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.45;
}

.bubble.markdown a {
  color: var(--amber);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--amber) 38%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease;
}

.bubble.markdown a:hover {
  text-decoration-color: var(--amber);
}

.bubble.markdown hr {
  border: none;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--border) 18%,
    var(--border) 82%,
    transparent
  );
  margin: 14px 0;
}

.msg.thought .bubble {
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
  padding: 2px 0 2px 38px;
  white-space: pre-wrap;
}

/* ---------- tool calls / permissions / notices ---------- */

.tool-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 38px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.tool-card .tool-icon {
  color: var(--accent);
}

.tool-card.completed .tool-icon {
  color: var(--running);
}

.tool-card.failed .tool-icon {
  color: var(--danger);
}

.tool-card .tool-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-card .tool-status {
  color: var(--text-dim);
  font-size: 12px;
}

/* Animated dots for pending / active indicators */
@keyframes pulse-dot {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

.dots-anim {
  display: inline-flex;
  gap: 1px;
  font-weight: 700;
  color: var(--accent);
}

.dots-anim span {
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.dots-anim span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots-anim span:nth-child(3) {
  animation-delay: 0.4s;
}

.dots-anim.dim {
  color: var(--text-dim);
}

.perm-card {
  margin-left: 38px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perm-card.answered {
  border-color: var(--border);
  background: var(--bg-input);
}

.perm-title {
  font-size: 14px;
}

.perm-answer {
  font-size: 13px;
  color: var(--text-dim);
}

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

.perm-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-size: 13px;
}

.perm-btn:hover {
  border-color: var(--accent);
}

.perm-btn.allow_once,
.perm-btn.allow_always {
  background: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.notice {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* Per-turn token usage, a quiet line under the agent's reply. */
/* Header context meter: subtle plain text, not a headline number. */
.token-meter {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.item-error {
  margin-left: 38px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--danger);
  font-size: 13px;
  white-space: pre-wrap;
}

/* ---------- composer ---------- */

.composer-wrap {
  padding: 8px 24px 20px;
  /* Anchor for the absolutely-positioned jump-to-latest button. */
  position: relative;
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  /* Equal left/right padding so the + and send sit symmetric from the edges. */
  padding: 12px 16px 8px 16px;
}

.composer:focus-within {
  border-color: var(--accent);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  max-height: 180px;
  min-height: 42px;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.composer-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.model-picker {
  display: flex;
  align-items: center;
}

.model-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 3px 0;
  cursor: pointer;
  outline: none;
}

.model-select:hover {
  color: var(--text);
}

.model-select option {
  background: var(--bg-sidebar);
  color: var(--text);
}

.composer .send {
  background: var(--accent);
  color: var(--ink);
  border-radius: 50%;
  /* Same size as .attach-btn (the +) so the two sides match. */
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.composer .send:disabled {
  opacity: 0.4;
  cursor: default;
}

.composer .send.stop {
  background: var(--danger);
  font-size: 12px;
}

.composer.drag-hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 6px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip-remove {
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-dim);
  border-radius: 4px;
  flex-shrink: 0;
}

.file-chip-remove:hover {
  color: var(--danger);
}

.attach-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.attach-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.composer-hint {
  max-width: 760px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- login ---------- */

.login-wrap {
  /* Same mobile-viewport fix as `.shell`: dvh keeps the card centered in the
     visible area instead of behind the URL bar. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 380px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.login-card h1 .wordmark {
  color: var(--accent);
}

.login-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.login-card code {
  background: var(--bg-input);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

.login-card input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card .connect {
  background: var(--accent);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
}

.login-card .connect:disabled {
  opacity: 0.4;
  cursor: default;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
}

/* ---------- service detail panel ---------- */

.service-row {
  width: 100%;
  text-align: left;
}

.service-row.active {
  background: var(--bg-input);
}

.panel-scrim {
  display: none;
}

.service-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  /* Docks directly right of the left sidebar (order 1, between it and the
     chat) so selecting a service doesn't drag the eye across the screen. */
  order: 1;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.panel-key {
  color: var(--text-dim);
  flex-shrink: 0;
}

.panel-value {
  text-align: right;
  min-width: 0;
  /* Long values (tailnet URLs, registry paths) wrap instead of being cut
     off with an ellipsis, so they stay fully readable. */
  overflow-wrap: anywhere;
}

.panel-value a {
  color: var(--accent);
}

.panel-value .status-dot {
  display: inline-block;
}

.panel-value.mono {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 12px;
}

.panel-section {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.update-badge {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Small pill next to the exposure URL that toggles the scan-to-open QR. */
.qr-toggle {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.qr-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.exposure-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
}

.exposure-qr-img {
  width: 172px;
  height: 172px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  line-height: 0;
}

.exposure-qr-img svg {
  width: 100%;
  height: 100%;
  display: block;
}

.exposure-qr-cap {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.upgrade-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
}

.upgrade-line {
  font-size: 13px;
  color: var(--text);
}

.upgrade-force {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

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

.panel-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-size: 13px;
}

.panel-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.panel-btn.danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.panel-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.panel-empty {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

/* Explanatory line under a panel section (e.g. the Revert/Backups
   distinction). Slightly dimmer and smaller than body text. */
.panel-hint {
  padding: 4px 16px 8px;
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}

.panel-hint strong {
  color: var(--text);
  font-weight: 600;
}

.panel-error {
  font-size: 12px;
  color: var(--danger);
  white-space: pre-wrap;
}

.env-toggle {
  cursor: pointer;
  user-select: none;
}

.env-toggle:hover {
  color: var(--text);
}

.toggle-arrow {
  font-size: 10px;
}

.env-editor {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  outline: none;
  margin-top: 6px;
}

.env-editor:focus {
  border-color: var(--accent);
}

.env-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.env-actions .panel-btn {
  flex: 0 0 auto;
  padding: 5px 14px;
  font-size: 12px;
}

.log-view {
  width: 100%;
  max-height: 320px;
  overflow: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

.log-live {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ok, #3fb950);
  border: 1px solid var(--ok, #3fb950);
}

/* ---------- env schema form (chat inline) ---------- */

.env-form-card {
  margin: 6px 0 8px 36px;
  padding: 12px 14px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  min-width: 0;
}

.env-form-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.env-form-label {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.env-form-optional {
  color: var(--text-dim);
  opacity: 0.7;
  font-style: italic;
}

.env-form-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.env-form-input:focus {
  border-color: var(--accent);
}

.env-form-input:disabled {
  opacity: 0.5;
}

.env-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.env-form-toggle {
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.env-form-toggle input[type="checkbox"] {
  margin-right: 4px;
}

.env-form-submit {
  align-self: flex-start;
  padding: 7px 18px;
}

.env-form-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.env-form-choice-prompt {
  font-size: 12px;
  color: var(--text-dim);
}

.env-form-radio {
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.env-form-radio input[type="radio"] {
  margin: 0;
}

.env-form-submitted {
  font-size: 12px;
  color: var(--running);
}

.remove-dialog {
  background: var(--bg-sidebar);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 380px;
  width: 90vw;
}

.remove-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.remove-dialog h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.remove-dialog p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.remove-dialog input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  box-sizing: border-box;
}

.remove-dialog input:focus {
  outline: none;
  border-color: var(--accent);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ---------- narrow screens (phones) ---------- */

/* Always in the DOM so the fade can transition; only the media query
   below gives it a visible state. */
.sidebar-scrim {
  display: none;
}

@media (max-width: 720px) {
  .sidebar-toggle {
    display: block;
  }

  /* The "Enter to send, Shift+Enter for a new line" hint is a desktop-keyboard
     affordance: on mobile there's no Shift+Enter and send is a tap, so hide the
     idle hint. visibility (not display:none) keeps its line height reserved so
     the composer doesn't jump up when idle and back down when a transient status
     ("Agent is working") takes the same line. */
  .composer-hint.ready {
    visibility: hidden;
  }

  /* Off-canvas sidebar: slides over the chat, scrim closes it. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(300px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }

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

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .sidebar-scrim.open {
    opacity: 1;
    pointer-events: auto;
  }

  .panel-scrim {
    background: rgba(0, 0, 0, 0.45);
    z-index: 25;
  }

  /* The service detail panel becomes an overlay sheet from the right
     instead of squeezing the chat column. */
  .service-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 30;
    width: min(340px, 92vw);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }

  .chat-header {
    padding: 10px 12px 0;
  }

  /* The 34px serif headline is a touch too large on phones and crowds the
     composer margins; ease it down a step. */
  .chat-greeting h1 {
    font-size: 28px;
  }

  .chat-column {
    padding: 20px 14px 12px;
  }

  .composer-wrap {
    padding: 8px 10px 14px;
  }

  .msg.user .bubble {
    max-width: 92%;
  }

  /* Anything below 16px makes iOS Safari zoom into the field on focus. */
  .composer textarea {
    font-size: 16px;
  }

  .login-card {
    width: calc(100vw - 32px);
  }
}

/* ---------- settings overlay ---------- */

.settings-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.settings-card {
  width: min(640px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.settings-section {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.settings-keyname {
  font-size: 14px;
}

.about-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.about-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.about-key {
  color: var(--text-dim);
  flex-shrink: 0;
}

.about-val {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.about-val.muted {
  color: var(--text-dim);
  opacity: 0.6;
}

.about-val.link {
  color: var(--accent);
  text-decoration: none;
}

.about-val.link:hover {
  text-decoration: underline;
}

.scope-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scope-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.scope-chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  opacity: 0.6;
  flex-shrink: 0;
}

.scope-chip.granted {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  opacity: 1;
}

.scope-doc {
  font-size: 12px;
  color: var(--text-dim);
}

.settings-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.settings-hint code {
  background: var(--bg-input);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}

/* -- Feedback modal -- */
.fb-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.fb-kinds {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.fb-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}
.fb-chip:hover { color: var(--text); border-color: var(--accent); }
.fb-chip.selected {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.fb-textarea, .fb-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.fb-textarea { resize: vertical; min-height: 90px; }
.fb-textarea:focus, .fb-input:focus { border-color: var(--accent); outline: none; }
.fb-form-actions { display: flex; justify-content: flex-end; }
.fb-sent { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; align-items: flex-start; }
.fb-sent p { margin: 0; color: var(--text); }
.primary {
  padding: 7px 14px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.primary:hover:not(:disabled) { background: var(--accent); color: #1a1a17; }
.primary:disabled { opacity: 0.5; cursor: default; }

.config-path {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.config-editor {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  outline: none;
}

.config-editor:focus {
  border-color: var(--accent);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-actions .panel-btn {
  flex: 0 0 auto;
  padding: 7px 18px;
}

.save-ok {
  font-size: 12px;
  color: var(--running);
}

.sidebar-footer .cog {
  font-size: 15px;
}

/* ---------- test results ---------- */

.test-results {
  margin-top: 6px;
}

.test-result {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 5px 0;
}

.test-result .test-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-weight: 600;
}

.test-result.pass .test-icon {
  color: var(--running);
}

.test-result.fail .test-icon {
  color: var(--danger);
}

.test-result .test-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.test-result .test-duration {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.test-detail {
  padding: 2px 0 6px 24px;
}

.test-detail pre {
  margin: 0;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text-dim);
}

.trace-link {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  padding: 4px 0;
}
.trace-link:hover {
  text-decoration: underline;
}

.test-log {
  margin: 0;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.5;
  overflow: auto;
  max-height: calc(100vh - 280px);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}

.test-list-sidebar {
  padding: 0 8px;
}

.test-sidebar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

.test-sidebar-row:hover {
  background: rgba(255,255,255,0.05);
}

.test-sidebar-row.running {
  color: #b0b0b0;
}

.test-sidebar-row.pass .test-sidebar-icon {
  color: #4caf50;
}

.test-sidebar-row.fail .test-sidebar-icon {
  color: #e57373;
}

.test-sidebar-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.test-sidebar-time {
  color: #888;
  font-size: 11px;
  flex-shrink: 0;
}

/* ---------- agent sign-in (auth_required) ---------- */
.signin-card {
  max-width: 560px;
  margin: 24px auto;
  padding: 20px 22px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.signin-card h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--text);
}

.signin-card p {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.signin-card .connect {
  background: var(--accent);
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.signin-card .connect:hover {
  filter: brightness(1.05);
}

/* ---------- login terminal modal ---------- */
.login-modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.login-modal {
  width: min(820px, 92vw);
  background: #0b0b0d;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

.login-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.login-term {
  height: 60vh;
  padding: 8px;
}

.login-modal-hint {
  padding: 8px 14px 12px;
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* ---------- agent accounts (settings) ---------- */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.account-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account-agent {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  text-transform: capitalize;
}

.account-status {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status.muted {
  font-style: italic;
  opacity: 0.7;
}

.account-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.account-btn {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.account-btn:hover {
  background: var(--border);
}

.account-btn.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
}

.account-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- login modal warning / error copy ---------- */
.login-modal-warn {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}

.login-modal-warn strong {
  color: var(--text);
  font-weight: 600;
}

.login-modal-warn code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-hover);
  padding: 1px 4px;
  border-radius: 4px;
}

.login-modal-hint.error {
  color: var(--danger);
}

/* ---------- health (ryra doctor) ---------- */

.footer-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.health-btn {
  position: relative;
}

.health-badge {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--stopped);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

.health-badge.blocker {
  background: var(--danger);
}

.health-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.health-summary {
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0 10px;
}

.health-clear {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  font-size: 14px;
  color: var(--text);
}

.health-clear-icon {
  color: var(--running);
  font-weight: 700;
}

.health-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.health-issue {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--bg-input);
}

.health-issue.blocker {
  border-left-color: var(--danger);
}

.health-issue.warning {
  border-left-color: var(--stopped);
}

.health-issue.info {
  border-left-color: var(--text-dim);
}

.health-issue-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.health-sev {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.health-sev.blocker {
  background: rgba(248, 113, 113, 0.16);
  color: var(--danger);
}

.health-sev.warning {
  background: rgba(250, 204, 21, 0.16);
  color: var(--stopped);
}

.health-sev.info {
  background: var(--bg-hover);
  color: var(--text-dim);
}

.health-issue-service {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.health-msg {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.health-fix {
  flex: initial;
  margin-top: 8px;
  padding: 6px 12px;
}

/* ---------- host stats ---------- */

.stats-icon {
  width: 15px;
  height: 15px;
  display: block;
}

.stat-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 2px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-label {
  flex: 0 0 56px;
  font-size: 13px;
  color: var(--text);
}

.stat-bar {
  flex: 1 1 auto;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--running);
  transition: width 0.3s ease;
}

.stat-bar-fill.warn {
  background: var(--stopped);
}

.stat-bar-fill.crit {
  background: var(--danger);
}

.stat-detail {
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-detail.dim {
  color: var(--text-dim);
  flex: 0 0 auto;
  min-width: 92px;
  text-align: right;
}

/* ---------- revert ---------- */

.revert-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 8px;
}

.revert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.revert-ts {
  font-size: 12px;
  color: var(--text);
}

.revert-actions {
  display: flex;
  gap: 6px;
}

.revert-row .panel-btn {
  flex: initial;
  padding: 5px 12px;
}

/* ---------- config reconcile ---------- */

.reconcile-box {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
}

.reconcile-head {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 8px;
}

.reconcile-service {
  margin-bottom: 8px;
}

.reconcile-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.reconcile-change {
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 10px;
  word-break: break-word;
}

.reconcile-key {
  color: var(--text);
}

/* ---------- first-run onboarding ---------- */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.onboarding-card {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.onboarding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.onboarding-progress {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

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

.onboarding-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.onboarding-step h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.onboarding-step p {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.onboarding-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.onboarding-choice {
  flex: 1 1 auto;
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  text-transform: capitalize;
  transition: border-color 0.12s, background 0.12s;
}

.onboarding-choice:hover {
  border-color: var(--accent);
}

.onboarding-choice.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.onboarding-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.onboarding-check {
  color: var(--running);
  font-weight: 700;
}

.onboarding-step p.onboarding-connected {
  color: var(--running);
  font-size: 14px;
}

.onboarding-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-input);
}

.onboarding-skip {
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 4px;
}

.onboarding-skip:hover {
  color: var(--text);
}

/* Skill level chips in Settings (same field the walkthrough sets). */
.skill-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-choice {
  flex: 1 1 auto;
  min-width: 90px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
}

.skill-choice:hover {
  border-color: var(--accent);
}

.skill-choice.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Onboarding: Tailscale multi-part step (install / connect / token). */
.onboarding-substep {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.onboarding-substep-title {
  font-weight: 600;
  font-size: 14px;
}

/* Links styled as panel buttons (install links). */
a.panel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.onboarding-qr {
  align-self: center;
  flex: 0 0 auto;
  width: 160px;
  height: 160px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  line-height: 0;
}

.onboarding-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.onboarding-link {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.onboarding-link:hover {
  text-decoration: underline;
}

.onboarding-token-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.onboarding-token-row .registry-input {
  flex: 1;
  font-family: var(--mono);
}
