/* Workspace skin: restrained surfaces, compact geometry, and a clear type hierarchy.
   Loaded after the functional styles so this visual treatment is easy to revise. */
:root {
  --st-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --st-r-sm: 4px; --st-r-md: 6px; --st-r-lg: 8px; --st-r-xl: 10px;
  --st-bg: #f7f8fa; --st-surface: #fff; --st-surface-2: #f1f3f5;
  --st-line: #dde1e6; --st-line-soft: #e9ecf0;
  --st-ink: #20242b; --st-ink-soft: #343b45; --st-ink-muted: #626c79;
  --st-accent: #168263; --st-accent-hover: #106b50; --st-accent-text: #126e54;
  --st-accent-tint: #e8f3ef; --st-accent-ink: #fff;
  --st-sh-card: none; --st-sh-bar: 0 2px 8px rgb(20 28 40 / 5%);
  --st-sh-pop: 0 8px 28px rgb(20 28 40 / 12%);
}
[data-theme="dark"] {
  --st-bg: #131518; --st-surface: #1a1d21; --st-surface-2: #22262c;
  --st-line: #343a43; --st-line-soft: #2b3037;
  --st-ink: #edf0f4; --st-ink-soft: #d0d5dd; --st-ink-muted: #a0a9b6;
  --st-accent: #58c4a1; --st-accent-hover: #75d2b3; --st-accent-text: #75d2b3;
  --st-accent-tint: #203a32; --st-accent-ink: #10271e;
  --st-sh-card: none; --st-sh-bar: 0 2px 8px rgb(0 0 0 / 14%);
  --st-sh-pop: 0 8px 28px rgb(0 0 0 / 30%);
}
.st-header { height: 54px; gap: 14px; }
.st-header__brand { font-weight: 700; letter-spacing: -.025em; }
.st-header .st-pill { border-radius: 5px; background: transparent; border-color: transparent; padding-inline: 6px; }
.st-header #account-email { height: 32px; border-color: transparent; font-size: 12px; letter-spacing: .035em; }
.st-header > .st-tabs:not(:has(.st-tab:not([hidden]))) { display: none; }
.st-btn { height: 36px; font-weight: 600; }
.st-btn--icon { height: 30px; width: 30px; border-radius: 5px; }
.st-btn--primary { box-shadow: none; }
.st-btn--secondary { border-width: 1px; }
.st-input { border-width: 1px; height: 36px; }
.conversation-sidebar { background: var(--st-surface); padding: 16px 10px; }
#conversation-new { background: var(--st-bg); font-size: 13px; margin-bottom: 18px; }
.conversation-row { border-radius: 5px; margin-bottom: 3px; }
.conversation-select { font: 400 13px/1.5 var(--st-font); }
.conversation-row.selected { background: var(--st-accent-tint); box-shadow: inset 2px 0 var(--st-accent); }
.conversation-row.selected .conversation-select { font-weight: 600; color: var(--st-accent-text); }
.conversation-row .st-btn--icon { width: 28px; height: 28px; }
.conversation-heading { min-height: 48px; padding: 12px 24px; box-shadow: none; background: var(--st-surface); }
#conversation-heading-title { font-size: 14px; }
.st-msg .st-bubble { border-radius: 8px; box-shadow: none; font-size: 15px; line-height: 1.65; padding: 14px 16px; }
[data-theme] .st-msg--user .st-bubble { background: var(--st-surface-2); color: var(--st-ink); border-color: var(--st-line-soft); }
.st-msg--assistant .st-bubble { border-color: var(--st-line-soft); }
.st-msg .response-model, .st-msg .user-name { font-family: var(--st-font); }
.message-timestamp { font-variant-numeric: tabular-nums; }
.st-msg:not(.response-collapsed) .response-heading { border-bottom-color: var(--st-line); }
.reasoning-toggle { border-color: var(--st-line); border-radius: 4px; font-weight: 500; }
[data-theme="dark"] .reasoning-toggle { border-color: var(--st-line); }
.reasoning-toggle[aria-expanded="true"] { border-color: var(--st-accent); }
.st-composer { border-radius: 8px; padding: 12px; box-shadow: var(--st-sh-bar); }
.st-composer textarea { font-size: 15px; }
.st-composer:focus-within { border-color: var(--st-accent); box-shadow: 0 0 0 2px var(--st-accent-tint); }
.view--chat > .st-drawer { background: var(--st-surface); }
.st-drawer__head { padding: 0 20px; min-height: 44px; }
.sidebar-tabs { gap: 20px; padding: 0; background: transparent; border: 0; border-radius: 0; }
.sidebar-tabs .st-tab { height: 44px; padding: 0 2px; border-radius: 0; font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; }
.sidebar-tabs .st-tab[aria-selected="true"] { background: transparent; box-shadow: none; color: var(--st-ink); border-bottom-color: var(--st-accent); font-weight: 600; }
.st-drawer__body { padding: 20px; gap: 20px; }
.config-fieldset { border-radius: 6px; border-color: var(--st-line); padding: 14px 12px; }
.config-fieldset > legend { font-size: 12px; letter-spacing: .02em; padding: 0 6px; }
#s-thinking { border-radius: 5px; }
#s-thinking button { font-size: 12px; height: 32px; }
#s-thinking button:first-child { border-radius: 4px 0 0 4px; }
#s-thinking button:last-child { border-radius: 0 4px 4px 0; }
.generation-row .st-input, .cfg-setting .st-input { border-radius: 4px; }
.toggle-row { font-size: 13px; }
.st-card { box-shadow: none; border-radius: 8px; }
.config-confirm { border-radius: 10px; box-shadow: var(--st-sh-pop); }
.config-confirm h2 { font-size: 18px; font-weight: 600; }
.account-menu-content { border-radius: 7px; }
.account-menu-content > .st-btn { justify-content: flex-start; border: 0; height: 34px; font-size: 13px; }
.account-menu-divider { margin: 5px 0; }
@media (max-width: 700px) {
  .st-header { gap: 8px; }
  .conversation-heading { padding: 12px 16px; }
  .sidebar-tabs { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .st-btn, .reasoning-toggle { transition: none; }
}

/* Keep chat scrolling discoverable without a high-contrast scrollbar. */
.chat-scroll { --chat-scroll-thumb: #dce0e5; scrollbar-color: var(--chat-scroll-thumb) var(--st-bg); }
[data-theme="dark"] .chat-scroll { --chat-scroll-thumb: #30353d; }
.chat-scroll::-webkit-scrollbar { width: 12px; }
.chat-scroll::-webkit-scrollbar-track { background: var(--st-bg); }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--chat-scroll-thumb); border: 3px solid var(--st-bg); border-radius: 8px; }
.chat-scroll::-webkit-scrollbar-button { background-color: var(--st-bg); color: var(--chat-scroll-thumb); }

/* Sidebar hover and keyboard feedback, without shifting the layout. */
#conversation-new, .conversation-row { transition: background-color 140ms ease, border-color 140ms ease; }
#conversation-new:hover:not(:disabled) { background: var(--st-surface-2); border-color: var(--st-ink-muted); }
.conversation-row:hover, .conversation-row:focus-within { background: var(--st-surface-2); }
.conversation-row.selected:hover, .conversation-row.selected:focus-within { background: color-mix(in srgb, var(--st-accent) 16%, var(--st-surface)); }
#conversation-new:focus-visible, .conversation-select:focus-visible { outline: 2px solid var(--st-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #conversation-new, .conversation-row { transition: none; } }

/* Make sidebar navigation visibly interactive while retaining its active underline. */
.sidebar-tabs .st-tab { transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease; }
.sidebar-tabs .st-tab:hover { background: var(--st-surface-2); color: var(--st-ink); border-bottom-color: var(--st-ink-muted); }
.sidebar-tabs .st-tab[aria-selected="true"]:hover { background: var(--st-accent-tint); border-bottom-color: var(--st-accent); }
.sidebar-tabs .st-tab:focus-visible { outline: 2px solid var(--st-accent); outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { .sidebar-tabs .st-tab { transition: none; } }
.sidebar-tabs .st-tab[aria-selected="true"] { background: var(--st-accent-tint); color: var(--st-accent-text); }

.generation-status { min-height: 18px; margin: 0 0 6px; color: var(--st-ink-muted); font-size: 11px; line-height: 18px; font-variant-numeric: tabular-nums; }
.st-msg__meta .meta-text:empty { display: none; }

/* User bubbles already use the secondary surface, so actions need a distinct hover. */
.st-msg--user .st-msg__meta .st-btn--icon:hover:not(:disabled),
.st-msg--user .st-msg__meta .st-btn--icon:focus-visible {
  background: color-mix(in srgb, var(--st-ink) 10%, var(--st-surface-2));
  color: var(--st-ink);
}

/* Outline message actions so their button boundaries are visible at rest. */
.st-msg__meta .st-btn--icon {
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--st-ink-muted) 55%, var(--st-line));
  border-radius: 3px;
  background: transparent;
}
.st-msg__meta .st-btn--icon:hover:not(:disabled) { border-color: var(--st-ink-muted); }

.st-msg--assistant .st-msg__meta .st-btn--icon:hover:not(:disabled) { background: var(--st-surface-2); }

/* Compact action outlines, retaining icon size and footer anchoring. */
.st-msg__meta { gap: 2px; }
.st-msg__meta .st-btn--icon { width: 26px; height: 26px; padding: 0; }
.st-msg__meta .st-btn--icon + .st-btn--icon { margin-left: 0; }
.st-msg--user .st-bubble > .st-msg__meta,
.st-msg--assistant .st-bubble > .st-msg__meta { right: 9px; bottom: 9px; }

/* Strong action icons at rest, with a transparent button surface. */
.st-msg__meta .st-btn--icon { color: var(--st-ink); }

/* Shared transparent action group, ready for group-level hover effects. */
.st-msg--user .st-bubble > .st-msg__meta,
.st-msg--assistant .st-bubble > .st-msg__meta {
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* Fade message actions as a group, preserving keyboard visibility. */
.st-msg__meta { opacity: .5; transition: opacity 150ms ease; }
.st-msg__meta:hover, .st-msg__meta:has(.st-btn:focus-visible) { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .st-msg__meta { transition: none; } }

/* Administration, monitoring, and dialogs share the workspace treatment. */
.admin-nav, .admin-settings-children > .st-btn { font-size: 13px; font-weight: 500; border-color: transparent; border-radius: 5px; min-height: 36px; }
.admin-nav:hover, .admin-settings-children > .st-btn:hover { background: var(--st-surface-2); }
.admin-nav.selected { background: var(--st-accent-tint); border-color: transparent; box-shadow: inset 2px 0 var(--st-accent); font-weight: 600; }
.admin-settings-nav > summary { padding: 0 12px; }
.admin-settings-children { padding-left: 22px; gap: 3px; }
.monitor .st-card, .about .st-card, .img-form { padding: 20px; }
.card-title, .st-metric__label { font-weight: 600; }
.st-metric__value { font-weight: 600; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.metric-smoothing-select { border-radius: 4px; background: var(--st-surface); }
.st-table th { font-size: 11px; font-weight: 600; letter-spacing: .035em; }
.st-table td { font-size: 13px; }
.about .facts { font-size: 13px; gap: 12px 24px; }
.about .facts dt { color: var(--st-ink-muted); }
.about .facts dd { color: var(--st-ink); }
.config-confirm { padding: 24px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.config-confirm::backdrop { background: rgb(10 15 22 / 45%); backdrop-filter: blur(2px); }
.config-confirm h2 { line-height: 1.4; margin-bottom: 16px; letter-spacing: -.02em; }
.config-confirm p { font-size: 13px; color: var(--st-ink-muted); }
.config-confirm .st-label { font-size: 13px; font-weight: 500; }
.config-confirm .st-input { border-radius: 5px; }
.config-confirm .cfg-setting .st-input { height: 28px; }
.config-confirm-actions { padding-top: 16px; margin-top: 20px; border-top: 1px solid var(--st-line-soft); gap: 8px; }
.config-confirm .cfg-actions { padding-top: 12px; border-top: 1px solid var(--st-line-soft); }
.config-confirm .config-fieldset { border-radius: 6px; }
.config-confirm [role="alert"]:not(:empty) { color: var(--st-danger-text); }
.st-toast { border-radius: 8px; box-shadow: var(--st-sh-pop); font-size: 13px; }

/* The separate API request inspector uses the same palette and geometry. */
.api-monitor header { height: 54px; padding-inline: 24px; }
.api-monitor .brand { font-size: 14px; letter-spacing: -.025em; }
.api-monitor h1 { font-size: 24px; font-weight: 600; }
.api-monitor h2 { font-size: 15px; font-weight: 600; }
.api-monitor button, .api-monitor input, .api-monitor select { border-radius: 5px; font-size: 13px; }
.api-monitor .card, .api-monitor .panel { border-radius: 8px; box-shadow: none; }
.api-monitor .notice, .api-monitor pre, .api-monitor .fact { border-radius: 6px; }
.api-monitor .request { border-radius: 0; }
.api-monitor .tabs button[aria-selected="true"] { background: var(--st-accent-tint); border-bottom-color: var(--st-accent); }
.api-monitor .value { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .config-confirm { padding: 20px; }
  .api-monitor header { padding-inline: 16px; }
}

/* Consistent separation for expandable groups and standalone Admin links. */
#admin-sidebar > .admin-nav, #admin-sidebar > .admin-settings-nav { margin: 0; }
#admin-sidebar > * + .admin-nav, #admin-sidebar > * + .admin-settings-nav { margin-top: 4px; }
#admin-sidebar .admin-settings-children { padding-bottom: 0; }

.password-control { display: block; position: relative; min-width: 0; width: 100%; }
.password-control > input { width: 100%; box-sizing: border-box; padding-right: 38px; }
.password-reveal { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 28px; height: 28px; padding: 4px; border: 0; border-radius: 4px; background: transparent; color: var(--st-ink-muted); cursor: pointer; touch-action: none; user-select: none; }
.password-reveal svg { width: 18px; height: 18px; }
.password-reveal:hover, .password-reveal[aria-pressed="true"] { color: var(--st-ink); background: var(--st-surface-2); }
.password-reveal:focus-visible { outline: 2px solid var(--st-accent); }

/* A quiet activity indicator during both reasoning and answer streaming. */
.generation-dots { display: inline-flex; align-items: center; gap: 4px; height: 18px; margin: 4px 0; vertical-align: middle; }
.generation-dots > .generation-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--st-ink-muted); animation: generation-dot 1.2s ease-in-out infinite; }
.generation-dots > .generation-dot:nth-child(3) { animation-delay: .15s; }
.generation-dots > .generation-dot:nth-child(4) { animation-delay: .3s; }
@keyframes generation-dot { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .generation-dots > .generation-dot { animation: none; opacity: .65; } }

.response-collapsed .generation-dots { display: none; }

/* The composer action becomes Stop for the active request. */
.st-btn--send.is-stopping { background: #d32f45; color: #fff; }
.st-btn--send.is-stopping:hover { background: #b52539; }

.generation-label { margin-right: 4px; font-size: 12px; line-height: 18px; color: var(--st-ink-muted); }

/* Keep the submitted draft readable while making its locked state clear. */
.st-composer textarea:disabled {
  color: var(--st-ink-muted);
  -webkit-text-fill-color: var(--st-ink-muted);
  background: var(--st-surface-2);
  border-radius: 4px;
  cursor: not-allowed;
  opacity: 1;
}

.prefill-status.is-active, .generation-result.is-active { color: var(--st-ink); font-weight: 600; }

.generation-status > span { display: block; font-weight: 400; }
.generation-status > .is-active { font-weight: 600; color: var(--st-ink); }

.conversation-heading-actions { display: flex; align-items: center; flex: none; gap: 6px; margin-left: auto; }

.st-btn--send { width: 31.5px; height: 27px; padding: 0; }
.st-btn--send .st-icon { width: 15px; height: 15px; }

#attach-btn, #record-btn { border: 1px solid var(--st-ink-muted); }

.composer-actions { display: flex; align-items: center; gap: 6px; padding: 0; background: transparent; border: 0; box-shadow: none; }

/* The input owns the composer surface; actions float over its lower corner. */
.st-composer { position: relative; padding: 0; gap: 0; }
.st-composer textarea { width: 100%; box-sizing: border-box; min-height: 79px; padding: 8px 20px 12px 12px; border-radius: inherit; }
.st-composer__bar { position: absolute; right: 12px; bottom: 12px; }
.st-composer__bar > .spacer { display: none; }
.st-composer > .attachments:not([hidden]) { margin: 12px 12px 0; }

/* Keep a clear gap above statistics as attachments expand the composer. */
.composer-wrap { padding-top: 12px; background: var(--st-bg); }

.generation-status { padding-left: 13px; }

[data-theme] .st-msg .st-bubble {
  border-color: color-mix(in srgb, var(--st-ink-muted) 70%, var(--st-line));
}

.conversation-heading {
  border-bottom-color: color-mix(in srgb, var(--st-ink-muted) 70%, var(--st-line));
}

#admin-sidebar .admin-nav, #admin-sidebar .admin-settings-children > .st-btn { padding-left: 12px; padding-right: 12px; }
#admin-sidebar .admin-settings-children { padding-left: 0; }

#admin-sidebar .admin-settings-children { padding: 2px 0 0 16px; gap: 1px; }
#admin-sidebar .admin-settings-children > .st-btn { height: 30px; min-height: 30px; }

.conversation-heading { border-top: 1px solid color-mix(in srgb, var(--st-ink-muted) 70%, var(--st-line)); }
#conversation-sidebar { border-right: 1px solid color-mix(in srgb, var(--st-ink-muted) 70%, var(--st-line)); }
.view--chat > .st-drawer { border-left: 1px solid color-mix(in srgb, var(--st-ink-muted) 70%, var(--st-line)); }
.view--chat > .st-drawer { border-top: 1px solid color-mix(in srgb, var(--st-ink-muted) 70%, var(--st-line)); }

.view--chat > .st-drawer > .st-drawer__head { padding-top: 16px; }

.st-composer textarea { max-height: max(79px, 30vh); }
#composer-resizer { position: absolute; top: -4px; left: 8px; right: 8px; height: 8px; z-index: 2; cursor: ns-resize; touch-action: none; border-radius: 4px; }
#composer-resizer:hover, #composer-resizer:focus-visible { background: var(--st-accent-tint); }
#composer-resizer:focus-visible { outline: 1px solid var(--st-accent); }

.context-meter { margin: 2px 0 10px; }
.context-meter-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--st-ink); font-size: 11px; line-height: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.context-meter-track { position: relative; height: 16px; overflow: hidden; border-radius: 3px; background: var(--st-line); }
.context-meter-fill { height: 100%; width: 0; background: var(--st-ink-muted); opacity: .25; transition: width 150ms ease; }
.context-meter[data-level="high"] .context-meter-fill { background: #c58b20; }
.context-meter[data-level="full"] .context-meter-fill { background: var(--st-danger); }
@media (prefers-reduced-motion: reduce) { .context-meter-fill { transition: none; } }

.message-token-stats { margin-top: 5px; padding-left: 17px; color: var(--st-ink-muted); font-size: 11px; line-height: 18px; font-variant-numeric: tabular-nums; }
.message-token-stats:empty { display: none; }
.message-token-stats.is-active { color: var(--st-ink); font-weight: 600; }

.st-msg--user .message-token-stats { margin-top: 12px; padding-left: 0; padding-right: 64px; min-height: 18px; white-space: normal; }
.st-msg--user.response-collapsed .message-token-stats { display: none; }

.st-msg--assistant .message-token-stats { margin-top: 12px; padding-left: 0; padding-right: 64px; min-height: 18px; }
.st-msg--assistant.response-collapsed .message-token-stats { display: none; }
.st-msg--assistant > .generation-dots { margin: 5px 0 0 17px; }

/* Shared account and workspace notifications. */
.st-toasts { right: 24px; bottom: 24px; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.st-toast { --toast-accent: var(--st-info); width: 100%; max-width: none; box-sizing: border-box; padding: 14px; gap: 12px; border: 1px solid var(--st-line); border-left: 3px solid var(--toast-accent); pointer-events: auto; }
.st-toast--success { --toast-accent: var(--st-accent); }
.st-toast--warn { --toast-accent: var(--st-warn); }
.st-toast--error { --toast-accent: var(--st-danger); }
.st-toast__symbol { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 6px; background: color-mix(in srgb, var(--toast-accent) 12%, transparent); }
.st-toast__body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.st-toast__title { font-weight: 600; line-height: 1.5; }
.st-toast .t-text { margin-top: 3px; color: var(--st-muted); line-height: 1.5; }
.st-toast__close { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--st-muted); font: inherit; font-size: 20px; cursor: pointer; }
.st-toast__close:hover { color: var(--st-ink); background: var(--st-surface-2); }
.st-toast__close:focus-visible { outline: 2px solid var(--toast-accent); outline-offset: 2px; }
.st-toast__action { margin-top: 8px; min-height: 30px; }
@media (prefers-reduced-motion: reduce) { .st-toast { animation: none; } }
@media (max-width: 600px) { .st-toasts { right: 16px; bottom: 16px; } }

#record-btn.is-recording { background: #b42332; border-color: #b42332; color: #fff; }

.st-msg--user .message-token-stats { font-size: 11px; line-height: 16px; }
.st-msg--user .message-token-stats,
.st-msg--user .message-token-stats.is-active { font-weight: 400; }
.st-msg--user .message-token-stats { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.st-msg--user .message-token-stats strong { font-weight: 700; }
.st-msg--assistant .message-token-stats,
.st-msg--assistant .message-token-stats.is-active { font-weight: 400; font-size: 11px; line-height: 16px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.st-msg--assistant .message-token-stats strong { font-weight: 700; }
