:root {
  color-scheme: light;
  --ui-bg: #f8fafc;
  --ui-surface: #ffffff;
  --ui-surface-subtle: #f9fbfd;
  --ui-sidebar: #edf2fa;
  --ui-sidebar-hover: #dfeaf7;
  --ui-sidebar-active: #ffffff;
  --ui-text: #111827;
  --ui-text-soft: #374151;
  --ui-muted: #6f6f71;
  --ui-placeholder: #9ca3af;
  --ui-border: #d8dee8;
  --ui-border-strong: #c7ced9;
  --ui-primary: #1681ef;
  --ui-primary-dark: #1051a6;
  --ui-primary-soft: #e5f0ff;
  --ui-primary-hover: #0d6fd4;
  --ui-success: #138a5b;
  --ui-success-soft: #e7f7f0;
  --ui-warning: #9a6700;
  --ui-warning-soft: #fff6dd;
  --ui-danger: #b42318;
  --ui-danger-soft: #fff0ee;
  --ui-shadow-sm: 0 1px 2px rgb(15 23 42 / 5%);
  --ui-shadow-md: 0 10px 30px rgb(15 23 42 / 9%);
  --ui-radius-xs: 6px;
  --ui-radius-sm: 8px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 16px;
  --ui-radius-xl: 22px;
  --ui-font: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
input,
textarea,
button,
select {
  font-family: var(--ui-font);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text-soft);
  font: 400 14px/1.55 var(--ui-font);
}

body.app-body {
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
}

body.navigation-open {
  overflow: hidden;
}

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

button,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
}

img,
svg,
.ui-icon {
  display: block;
  max-width: 100%;
}

.ui-icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  font-size: 20px;
}

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

h1,
h2,
h3,
h4 {
  color: var(--ui-text);
  line-height: 1.25;
}

button,
[role="button"],
a,
input,
textarea,
select,
summary {
  outline: none;
}

button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid rgb(15 23 42 / 34%);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 0;
}

[hidden] {
  display: none !important;
}

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

/* Controls */

.button,
button.button,
input[type="submit"] {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.button:hover,
button.button:hover,
input[type="submit"]:hover {
  background: var(--ui-primary-hover);
  box-shadow: 0 4px 12px rgb(22 129 239 / 18%);
}

.button:active,
button.button:active,
input[type="submit"]:active {
  transform: translateY(1px);
}

.button--primary,
button.button--primary {
  background: var(--ui-primary);
  color: #fff;
}

.button--secondary,
button.button--secondary {
  border-color: var(--ui-border-strong);
  background: var(--ui-surface);
  color: var(--ui-text-soft);
  box-shadow: var(--ui-shadow-sm);
}

.button--secondary:hover,
button.button--secondary:hover {
  border-color: #aab4c2;
  background: #f5f7fa;
  box-shadow: var(--ui-shadow-sm);
}

.button--ghost,
button.button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ui-muted);
}

.button--ghost:hover,
button.button--ghost:hover {
  background: #eef2f7;
  color: var(--ui-text);
  box-shadow: none;
}

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

.button--danger:hover,
button.button--danger:hover {
  background: #fee4e2;
  box-shadow: none;
}

.button--compact,
button.button--compact {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 12px;
}

.button--xs,
button.button--xs {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 6px;
  gap: 4px;
}

.figma-icon-button,
.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  padding: 8px;
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.figma-icon-button:hover,
.icon-button:hover {
  background: rgb(22 129 239 / 9%);
}

.figma-icon-button img,
.icon-button img,
.figma-icon-button .ui-icon,
.icon-button .ui-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.text-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.text-button--danger {
  color: var(--ui-danger);
}

/* Application shell */

.app-shell {
  display: flex;
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background: var(--ui-bg);
}

.app-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  margin: 16px 16px 16px 2px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.app-main {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.mobile-header {
  display: none;
}

.sidebar {
  position: relative;
  z-index: 40;
  display: flex;
  width: 292px;
  min-width: 292px;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  transition: width 220ms ease, min-width 220ms ease, transform 220ms ease;
}

.sidebar-brand-row {
  display: flex;
  height: 58px;
  flex: 0 0 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 20px;
}

.brand,
.mobile-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  color: var(--ui-text);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

.brand-logo {
  width: 32px;
  height: 25px;
  flex: 0 0 auto;
  object-fit: contain;
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.sidebar-mobile-close {
  display: none;
}

.sidebar-panel {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  margin: 0 16px 16px;
  padding: 12px 10px 10px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-sidebar);
}

.new-workspace-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid rgb(17 24 39 / 8%);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--ui-shadow-sm);
  transition: background-color 150ms ease, border-color 150ms ease;
}

.new-workspace-button:hover {
  border-color: #a8c8ed;
  background: #f8fbff;
}

.new-workspace-button__icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.new-workspace-button__icon .ui-icon {
  font-size: 16px;
}

.sidebar-search__field {
  display: flex;
  height: 40px;
  flex: 0 0 40px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-sm);
  background: rgb(255 255 255 / 72%);
  transition: background-color 150ms ease, border-color 150ms ease;
}

.sidebar-search__field:focus-within {
  border-color: #aeb7c4;
  background: var(--ui-surface);
  box-shadow: 0 0 0 3px rgb(15 23 42 / 5%);
}

.sidebar-search__field img,
.sidebar-search__field .ui-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.65;
}

.sidebar-search__field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ui-text);
  font-size: 13px;
}

.sidebar-search__field input::placeholder {
  color: var(--ui-muted);
}

.workspace-navigation {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding: 2px 1px 68px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.workspace-navigation::-webkit-scrollbar {
  display: none;
}

.workspace-nav-item {
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-md);
  background: rgb(255 255 255 / 45%);
  transition: background-color 150ms ease, border-color 150ms ease;
}

.workspace-nav-item:hover {
  background: var(--ui-sidebar-hover);
}

.workspace-nav-item--active {
  border-color: rgb(17 24 39 / 6%);
  background: var(--ui-sidebar-active);
  box-shadow: var(--ui-shadow-sm);
}

.workspace-nav-item--active:hover {
  background: var(--ui-sidebar-active);
}

.workspace-nav-item--active .workspace-nav-item__row {
  background: #cfe2ff;
}

.workspace-nav-item--dragging {
  opacity: 0.58;
  box-shadow: 0 10px 24px rgb(15 23 42 / 18%);
}

.workspace-nav-item__row {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 3px;
  padding: 5px 6px;
  border-radius: 10px;
}

.workspace-nav-item__link {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 7px;
  padding: 0 5px;
  color: var(--ui-muted);
  font-size: 13px;
  font-weight: 600;
}

.workspace-nav-item--active .workspace-nav-item__link {
  color: var(--ui-text);
}

.workspace-nav-item__name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-drag-handle,
.workspace-nav-action {
  display: grid;
  width: 27px;
  height: 30px;
  flex: 0 0 27px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-xs);
  background: transparent;
  color: var(--ui-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.workspace-drag-handle {
  cursor: grab;
  touch-action: none;
}

.workspace-drag-handle:active {
  cursor: grabbing;
}

.workspace-drag-handle:hover,
.workspace-nav-action:hover {
  background: rgb(255 255 255 / 58%);
  color: var(--ui-primary-dark);
}

.workspace-drag-handle .ui-icon,
.workspace-nav-action .ui-icon {
  font-size: 18px;
}

.workspace-subnav {
  display: grid;
  gap: 3px;
  padding: 4px 8px 10px;
  border-top: 1px solid #e7ebf0;
}

.workspace-subnav__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px 3px;
  color: var(--ui-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.workspace-subnav__heading a {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 5px;
  color: var(--ui-muted);
}

.workspace-subnav__heading a .ui-icon {
  font-size: 17px;
}

.workspace-subnav__heading a:hover {
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.workspace-chat-link,
.workspace-chat-empty {
  display: flex;
  min-width: 0;
  min-height: 31px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--ui-radius-xs);
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 500;
}

.workspace-chat-link:hover,
.workspace-chat-link--active {
  background: #eef4fb;
  color: var(--ui-primary-dark);
}

.workspace-chat-link__icon {
  color: #8491a2;
  font-size: 14px;
}

.workspace-chat-link--active .workspace-chat-link__icon {
  color: var(--ui-primary);
}

.workspace-chat-link > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-chat-empty {
  color: var(--ui-placeholder);
}

.sidebar-empty {
  padding: 28px 16px;
  color: var(--ui-muted);
  text-align: center;
}

.sidebar-empty p {
  margin-bottom: 8px;
}

.sidebar-empty a {
  color: var(--ui-primary-dark);
  font-weight: 600;
}

.sidebar-profile {
  position: absolute;
  z-index: 5;
  right: 10px;
  bottom: 10px;
  left: 10px;
}

.sidebar-profile > summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  border: 1px solid rgb(17 24 39 / 6%);
  border-radius: var(--ui-radius-sm);
  background: rgb(255 255 255 / 86%);
  box-shadow: var(--ui-shadow-sm);
  cursor: pointer;
  list-style: none;
  backdrop-filter: blur(12px);
}

.sidebar-profile > summary::-webkit-details-marker {
  display: none;
}

.user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ui-text);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.user-avatar img,
.user-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.sidebar-profile__identity {
  min-width: 0;
  flex: 1;
}

.sidebar-profile__identity strong {
  display: block;
  overflow: hidden;
  color: var(--ui-text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chevron {
  color: var(--ui-muted);
  font-size: 14px;
}

.profile-menu__panel {
  position: absolute;
  z-index: 80;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
  color: var(--ui-text-soft);
  font-size: 12px;
}

.profile-menu__panel strong {
  overflow: hidden;
  padding: 4px 6px;
  font-size: 11px;
  text-overflow: ellipsis;
}

.profile-menu__panel hr {
  width: 100%;
  margin: 4px 0;
  border: 0;
  border-top: 1px solid var(--ui-border);
}

.profile-menu__panel a,
.profile-menu__disabled,
.profile-logout {
  display: flex;
  width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--ui-radius-xs);
  background: transparent;
  color: var(--ui-text-soft);
  text-align: left;
}

.profile-menu__panel form {
  margin: 0;
}

.profile-menu__panel .ui-icon {
  font-size: 16px;
}

.profile-menu__panel a:hover,
.profile-logout:hover {
  background: #eef2f7;
}

.profile-menu__disabled {
  color: var(--ui-placeholder);
}

.profile-logout {
  color: var(--ui-danger);
  cursor: pointer;
}

.app-shell--collapsed .sidebar {
  width: 0;
  min-width: 0;
  overflow: visible;
}

.app-shell--collapsed .sidebar-brand-row,
.app-shell--collapsed .sidebar-panel {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.stage-sidebar-toggle {
  display: none;
  position: absolute;
  top: 11px;
  left: 12px;
  z-index: 60;
  width: 36px;
  height: 36px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
  cursor: pointer;
}

.stage-sidebar-toggle:hover {
  background: #eef2f7;
}

.app-shell--collapsed .stage-sidebar-toggle {
  display: grid;
  place-items: center;
}

.app-shell--collapsed .chat-topbar,
.app-shell--collapsed .settings-tabs {
  padding-left: 54px;
}

.app-shell--collapsed .app-stage {
  margin-left: 16px;
}

/* Disable Turbo Drive top progress bar */
.turbo-progress-bar {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Circular Loading Spinner */
.spinner-ring {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spinner-rotate 0.6s linear infinite;
  vertical-align: middle;
  box-sizing: border-box;
}

.spinner-ring--dark {
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--ui-primary);
}

.spinner-ring--sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.spinner-ring--lg {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Notices */

.flash {
  position: fixed;
  z-index: 120;
  bottom: 24px;
  right: 28px;
  max-width: min(440px, calc(100% - 36px));
  padding: 12px 18px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
  color: var(--ui-text-soft);
  font-size: 13px;
}

.flash--alert {
  border-color: #f0b9b2;
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.flash--public {
  position: fixed;
}

.inline-alert,
.alert-panel {
  padding: 12px 14px;
  border: 1px solid #f0b9b2;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.alert-panel {
  display: flex;
  gap: 10px;
}

.alert-panel--spaced {
  margin: 18px 0;
}

.alert-panel__icon {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--ui-danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.alert-panel h2,
.alert-panel h3 {
  margin-bottom: 4px;
  color: var(--ui-danger);
  font-size: 14px;
}

.alert-panel p {
  margin-bottom: 0;
}

.alert-panel ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

/* Chat */

.chat-page {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
}

.chat-topbar {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px 10px 22px;
  border-bottom: 1px solid #e8ebef;
  background: rgb(255 255 255 / 92%);
}

.chat-topbar__identity {
  min-width: 0;
}

.chat-topbar__identity h1 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-topbar__identity p {
  margin: 2px 0 0;
  color: var(--ui-muted);
  font-size: 11px;
}

.chat-topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-topbar__actions form {
  margin: 0;
}

.chat-page--empty {
  display: block;
  position: relative;
}

.chat-page--empty .chat-topbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

.chat-empty-layout {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 96px clamp(24px, 6vw, 80px) 54px;
  overflow-y: auto;
}

.chat-empty-state {
  max-width: 690px;
  margin-bottom: 16px;
  text-align: center;
}

.chat-empty-state::before {
  display: none;
}

.chat-empty-logo {
  display: block;
  height: 192px;
  width: auto;
  max-width: 600px;
  margin: 0 auto -24px;
  object-fit: contain;
}

.chat-empty-state h2,
.chat-hero-title {
  margin-bottom: 10px;
  color: var(--ui-text);
  font-size: clamp(24px, 2.2vw, 32px);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.chat-empty-state p {
  margin: 0 auto;
  color: var(--ui-muted);
  font-size: 14px;
}

.chat-empty-composer {
  width: min(100%, 750px);
}

.composer {
  display: flex;
  min-height: 122px;
  flex-direction: column;
  padding: 15px 16px 12px;
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: 0 8px 28px rgb(15 23 42 / 7%);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer:focus-within {
  border-color: #aeb7c4;
  box-shadow: 0 0 0 3px rgb(15 23 42 / 5%), 0 10px 30px rgb(15 23 42 / 8%);
}

.composer textarea {
  width: 100%;
  min-height: 58px;
  flex: 1;
  padding: 2px 4px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--ui-text);
  font-size: 15px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: var(--ui-placeholder);
}

.composer__footer {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
}

.composer__model-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.composer__model-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--ui-text-soft);
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 22px 4px 6px;
  border-radius: var(--ui-radius-xs);
  cursor: pointer;
  outline: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.composer__model-select:hover {
  background: #f1f5f9;
  color: var(--ui-text);
}

.composer__model-icon {
  position: absolute;
  right: 5px;
  pointer-events: none;
  font-size: 11px;
  color: var(--ui-muted);
}

.composer__hint {
  color: var(--ui-muted);
  font-size: 11px;
}

.composer__submit {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ui-text);
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease;
}

.composer__submit:hover {
  background: var(--ui-primary-dark);
}

.composer__submit:active {
  transform: scale(0.96);
}

.composer__submit img,
.composer__submit .ui-icon {
  width: 18px;
  height: 18px;
  color: #fff;
  font-size: 18px;
}

.ai-disclaimer {
  margin: 9px 0 0;
  color: var(--ui-placeholder);
  font-size: 10px;
  text-align: center;
}

.chat-empty-layout .inline-alert {
  width: min(100%, 750px);
  margin-bottom: 12px;
}

.chat-layout {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.chat-layout--sources-open {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
}

.chat-conversation {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
}

.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-thread {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 34px 32px 18px;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  margin-bottom: 6px;
}

.chat-message--assistant {
  align-self: flex-start;
  margin-right: auto;
}

.chat-message--user {
  align-self: flex-end;
  margin-left: auto;
}

.chat-message__header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.chat-message--user .chat-message__header {
  flex-direction: row-reverse;
  text-align: right;
}

.chat-message--assistant .chat-message__header {
  flex-direction: row;
  text-align: left;
}

.chat-message__avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 50%;
  background: #eef1f5;
  color: var(--ui-text);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}

.chat-message__avatar--assistant {
  border: 1px solid var(--ui-border);
  background: #ffffff;
  padding: 2px;
}

.chat-avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.user-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-message__header h2 {
  margin: 0;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 700;
}

.chat-message__header time {
  color: var(--ui-placeholder);
  font-size: 9px;
}

.chat-message__content {
  color: var(--ui-text-soft);
  font-size: 14px;
  line-height: 1.75;
}

.chat-message--assistant .chat-message__content {
  padding-left: 41px;
  padding-right: 0;
  text-align: left;
}

.chat-message--user .chat-message__content {
  padding-left: 0;
  padding-right: 41px;
  color: var(--ui-text);
  font-weight: 400;
  text-align: left;
}

.chat-bullet-list {
  margin: 10px 0;
  padding-left: 20px;
  list-style-type: disc;
}

.chat-bullet-item {
  margin-bottom: 6px;
  line-height: 1.6;
}

.answer-copy strong {
  font-weight: 700;
  color: var(--ui-text);
}

.answer-copy p {
  margin-bottom: 0.85em;
}

.answer-copy p:last-child,
.message-error p:last-child {
  margin-bottom: 0;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.sources-trigger {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-xs);
  background: var(--ui-surface);
  color: var(--ui-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.sources-trigger:hover,
.sources-trigger[aria-expanded="true"] {
  border-color: #b8d0e9;
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.sources-trigger__count {
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 5px;
  border-radius: 9px;
  background: #d9e8f9;
  color: var(--ui-primary-dark);
  font-size: 9px;
}

.generation-details {
  color: var(--ui-muted);
  font-size: 10px;
}

.generation-details summary {
  padding: 5px 7px;
  cursor: pointer;
}

.generation-details p {
  margin: 4px 0 0;
}

.answer-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ui-muted);
  font-size: 13px;
}

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

.chat-composer-wrap {
  width: 100%;
  padding: 10px 20px 16px;
  background: linear-gradient(to top, #fff 82%, rgb(255 255 255 / 0%));
}

.chat-composer-wrap .composer,
.chat-composer-wrap .ai-disclaimer {
  width: min(100%, 900px);
  margin-right: auto;
  margin-left: auto;
}

.chat-composer-wrap .composer {
  min-height: 102px;
  padding: 13px 14px 10px;
}

.chat-composer-wrap .composer textarea {
  min-height: 46px;
  font-size: 14px;
}

.conversation-menu {
  position: relative;
}

.conversation-menu summary {
  cursor: pointer;
  list-style: none;
}

.conversation-menu summary::-webkit-details-marker {
  display: none;
}

.conversation-menu__panel {
  position: absolute;
  z-index: 25;
  top: calc(100% + 7px);
  right: 0;
  display: grid;
  width: 210px;
  gap: 5px;
  padding: 9px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
  font-size: 12px;
}

.conversation-menu__panel a,
.conversation-menu__panel .text-button {
  padding: 7px 8px;
  border-radius: var(--ui-radius-xs);
}

.conversation-menu__panel a:hover,
.conversation-menu__panel .text-button:hover {
  background: #eef2f7;
}

.sources-drawer {
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--ui-border);
  background: var(--ui-surface-subtle);
}

.sources-drawer__header {
  display: flex;
  min-height: 70px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
}

.sources-drawer__header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.sources-drawer__header p {
  margin: 3px 0 0;
  color: var(--ui-muted);
  font-size: 10px;
}

.sources-drawer__content {
  height: calc(100% - 70px);
  padding: 12px;
  overflow-y: auto;
}

.sources-list {
  display: grid;
  gap: 10px;
}

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

.source-card__header {
  padding: 12px 13px 9px;
  border-bottom: 1px solid #eef0f3;
}

.source-card__header h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.source-card__header a:hover {
  color: var(--ui-primary-dark);
  text-decoration: underline;
}

.source-card__header p {
  margin: 4px 0 0;
  color: var(--ui-muted);
  font-size: 9px;
}

.source-card__excerpt {
  padding: 10px 13px 12px;
  color: var(--ui-text-soft);
  font-size: 11px;
  line-height: 1.65;
}

.source-card__excerpt p:last-child {
  margin-bottom: 0;
}

/* Pages and cards */

.page-shell {
  width: min(100%, 1180px);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 58px) clamp(22px, 5vw, 58px) 64px;
}

.page-shell--narrow {
  display: grid;
  width: min(100%, 720px);
  place-items: center;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-heading__eyebrow {
  margin-bottom: 7px;
  color: var(--ui-primary-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.page-heading p:not(.page-heading__eyebrow) {
  max-width: 670px;
  margin-bottom: 0;
  color: var(--ui-muted);
}

.page-heading__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--ui-muted);
  font-size: 11px;
}

.breadcrumbs a:hover {
  color: var(--ui-primary-dark);
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.workspace-card {
  display: flex;
  min-height: 190px;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.workspace-card:hover {
  border-color: #b8cee6;
  box-shadow: 0 10px 24px rgb(15 23 42 / 7%);
  transform: translateY(-2px);
}

.workspace-card__header h2 {
  margin-bottom: 8px;
  font-size: 17px;
}

.workspace-card__header a:hover {
  color: var(--ui-primary-dark);
}

.workspace-card > p {
  color: var(--ui-muted);
  font-size: 12px;
}

.workspace-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #eef0f3;
  color: var(--ui-muted);
  font-size: 10px;
}

.workspace-card__footer a {
  color: var(--ui-primary-dark);
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  display: flex;
  min-height: 110px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
}

.stat-card span {
  color: var(--ui-muted);
  font-size: 11px;
  font-weight: 600;
}

.stat-card strong {
  color: var(--ui-text);
  font-size: 29px;
  line-height: 1;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.quick-action {
  display: flex;
  min-height: 58px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--ui-radius-md);
  background: var(--ui-sidebar);
  color: var(--ui-text-soft);
  font-size: 12px;
  transition: background-color 150ms ease, color 150ms ease;
}

a.quick-action:hover {
  background: var(--ui-sidebar-hover);
  color: var(--ui-primary-dark);
}

.surface-card {
  padding: 18px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.surface-card--spaced {
  margin-top: 18px;
}

.surface-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.surface-card__header h2 {
  margin-bottom: 4px;
  font-size: 15px;
}

.surface-card__header p {
  margin-bottom: 0;
  color: var(--ui-muted);
  font-size: 11px;
}

.table-shell {
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table tr + tr {
  border-top: 1px solid var(--ui-border);
}

.data-table td {
  padding: 12px 14px;
  vertical-align: middle;
}

.data-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.table-primary a {
  display: block;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 600;
}

.table-primary small {
  display: block;
  margin-top: 3px;
  color: var(--ui-muted);
  font-size: 9px;
}

.empty-state {
  display: grid;
  justify-items: center;
  max-width: 620px;
  margin: 42px auto;
  padding: 36px 24px;
  text-align: center;
}

.empty-state__icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 15px;
  background: var(--ui-sidebar);
  color: var(--ui-primary-dark);
  font-size: 21px;
  font-weight: 600;
}

.empty-state h1,
.empty-state h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.empty-state p {
  margin-bottom: 18px;
  color: var(--ui-muted);
}

/* Settings and forms */

.settings-page {
  min-height: 100%;
  padding: 0 0 54px;
}

.settings-tabs {
  position: sticky;
  z-index: 8;
  top: 0;
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 4px;
  padding: 8px 22px;
  overflow-x: auto;
  border-bottom: 1px solid var(--ui-border);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tabs__back,
.modal-back {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: var(--ui-radius-sm);
}

.settings-tabs__back:hover,
.modal-back:hover {
  background: #eef2f7;
}

.settings-tabs__back img,
.modal-back img,
.settings-tabs__back .ui-icon,
.modal-back .ui-icon {
  width: 20px;
  height: 20px;
  font-size: 20px;
}

.settings-tab {
  min-width: max-content;
  padding: 8px 14px;
  border-radius: var(--ui-radius-sm);
  color: var(--ui-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

a.settings-tab:hover {
  background: #eef2f7;
  color: var(--ui-text);
}

.settings-tab--active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.settings-section__header {
  margin-bottom: 24px;
}

.settings-section__header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ui-text);
  margin-bottom: 6px;
}

.settings-section__header p {
  color: var(--ui-muted);
  font-size: 14px;
  margin: 0;
}

.settings-content {
  display: grid;
  width: 100%;
  max-width: 1160px;
  gap: 20px;
  margin: 0 auto;
  padding: 24px clamp(20px, 3vw, 40px);
}

.settings-content--wide {
  max-width: 100%;
}

.settings-section {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.settings-section h1,
.settings-section h2 {
  margin-bottom: 7px;
  font-size: 19px;
}

.settings-section > p {
  margin-bottom: 22px;
  color: var(--ui-muted);
  font-size: 12px;
}

.account-settings-page {
  min-height: 100%;
  padding: 42px clamp(24px, 5vw, 72px) 60px;
  background: var(--ui-surface-subtle);
}

.account-settings-header {
  width: min(100%, 1060px);
  margin: 0 auto 28px;
}

.account-settings-header h1 {
  margin-bottom: 7px;
  font-size: clamp(25px, 2.6vw, 34px);
  letter-spacing: -0.035em;
}

.account-settings-header > div > p:last-child {
  margin: 0;
  color: var(--ui-muted);
}

.account-settings-layout {
  display: grid;
  width: min(100%, 1060px);
  grid-template-columns: 230px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  margin: 0 auto;
}

.account-settings-nav {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.account-settings-nav > p {
  margin: 12px 9px 4px;
  color: var(--ui-placeholder);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-settings-nav > p:first-child {
  margin-top: 2px;
}

.account-settings-nav__item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: var(--ui-radius-sm);
  color: var(--ui-muted);
}

a.account-settings-nav__item:hover {
  background: #eef3f8;
  color: var(--ui-text);
}

.account-settings-nav__item--active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.account-settings-nav__item--disabled {
  opacity: 0.52;
}

.account-settings-nav__item > .ui-icon {
  font-size: 18px;
}

.account-settings-nav__item > span {
  display: grid;
  min-width: 0;
}

.account-settings-nav__item strong {
  color: inherit;
  font-size: 11px;
}

.account-settings-nav__item small {
  font-size: 9px;
}

.account-settings-content {
  min-width: 0;
}

.settings-section--account {
  width: 100%;
  padding: clamp(22px, 4vw, 34px);
}

.settings-section__header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ui-border);
}

.settings-section__header h1,
.settings-section__header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ui-text);
  margin-bottom: 6px;
}

.settings-section__header p {
  color: var(--ui-muted);
  font-size: 14px;
  margin: 0;
}

.settings-section__icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.settings-section__icon .ui-icon {
  font-size: 21px;
}

.account-settings-divider {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
  padding-top: 20px;
  border-top: 1px solid var(--ui-border);
}

.account-settings-divider strong {
  color: var(--ui-text);
  font-size: 12px;
}

.account-settings-divider span {
  color: var(--ui-muted);
  font-size: 10px;
}

.form-stack {
  display: grid;
  gap: 17px;
}

.form-field,
.field {
  display: grid;
  gap: 7px;
}

.form-field label,
.field label {
  color: var(--ui-text);
  font-size: 11px;
  font-weight: 700;
}

.form-field input:not([type="checkbox"]):not([type="radio"]),
.form-field textarea,
.form-field select,
.field input:not([type="checkbox"]):not([type="radio"]),
.field textarea,
.field select,
.upload-title-field,
.inline-role-form select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  color: var(--ui-text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-field textarea,
.field textarea {
  min-height: 110px;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.upload-title-field:focus,
.inline-role-form select:focus {
  border-color: #aeb7c4;
  box-shadow: 0 0 0 3px rgb(15 23 42 / 5%);
}

.form-field input::placeholder,
.form-field textarea::placeholder,
.field input::placeholder,
.field textarea::placeholder,
.upload-title-field::placeholder {
  color: var(--ui-placeholder);
}

.form-field__hint {
  margin: -1px 0 0;
  color: var(--ui-muted);
  font-size: 10px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

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

.field--inline label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ui-muted);
  font-weight: 500;
}

/* Documents and members */

.codex-modal-layer {
  width: 100%;
  min-height: 100%;
  padding: clamp(20px, 4vw, 42px);
  overflow-y: auto;
  background: var(--ui-surface-subtle);
}

.codex-modal-card {
  width: min(100%, 1050px);
  min-height: min(760px, calc(100dvh - 116px));
  margin: 0 auto;
  padding: 0 24px 28px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: 0 14px 36px rgb(15 23 42 / 8%);
}

.modal-heading {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 -24px 22px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--ui-border);
}

.modal-heading__title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.modal-heading__title > div {
  min-width: 0;
}

.modal-heading h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-heading small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ui-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-list {
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
}

.resource-row {
  display: flex;
  min-height: 60px;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--ui-border);
}

.resource-primary {
  flex: 1;
  min-width: 0;
}

.resource-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.status-badge-slot {
  width: 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.doc-preview-btn {
  height: 28px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 5px;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.doc-preview-btn ion-icon,
.doc-preview-btn svg {
  width: 14px;
  height: 14px;
}

.resource-row:last-child {
  border-bottom: 0;
}

.resource-row:hover {
  background: #fafbfd;
}

.resource-checkbox {
  display: block;
  width: 15px;
  height: 15px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 4px;
  background: var(--ui-surface);
}

.resource-icon {
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: 6px;
  background: var(--ui-sidebar);
  color: var(--ui-primary-dark);
  font-size: 16px;
}

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

.resource-primary > a,
.resource-primary > strong {
  display: block;
  overflow: hidden;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-primary > a:hover {
  color: var(--ui-primary-dark);
}

.resource-primary small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ui-muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge,
.role-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 12px;
  background: #eef1f5;
  color: var(--ui-muted);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge--completed,
.role-badge--owner {
  background: var(--ui-success-soft);
  color: var(--ui-success);
}

.status-badge--pending,
.status-badge--processing,
.role-badge--admin {
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
}

.status-badge--failed {
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.upload-zone {
  display: grid;
  min-height: 270px;
  margin-top: 18px;
  place-items: center;
  padding: 28px;
  border: 1px dashed #9bb6d1;
  border-radius: var(--ui-radius-md);
  background: #f8fbff;
}

.upload-zone--standalone {
  min-height: 430px;
  margin-top: 0;
}

.upload-zone__inner {
  display: grid;
  width: min(100%, 560px);
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.upload-zone__icon {
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  padding: 10px;
  border-radius: 14px;
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
  font-size: 24px;
}

.upload-zone strong {
  color: var(--ui-text);
  font-size: 14px;
}

.upload-zone p {
  margin-bottom: 5px;
  color: var(--ui-muted);
  font-size: 10px;
}

.upload-title-field {
  max-width: 460px;
  text-align: left;
}

.upload-zone input[type="file"] {
  width: min(100%, 460px);
  padding: 7px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  color: var(--ui-muted);
  font-size: 10px;
}

.upload-zone input[type="file"]::file-selector-button {
  margin-right: 9px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--ui-sidebar);
  color: var(--ui-primary-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(150px, 0.38fr) minmax(0, 1fr);
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
}

.detail-list dt,
.detail-list dd {
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.detail-list dt:nth-last-of-type(1),
.detail-list dd:nth-last-of-type(1) {
  border-bottom: 0;
}

.detail-list dt {
  background: var(--ui-surface-subtle);
  color: var(--ui-muted);
  font-weight: 600;
}

.detail-list dd {
  color: var(--ui-text-soft);
}

.danger-zone {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #f0b9b2;
  border-radius: var(--ui-radius-md);
  background: var(--ui-danger-soft);
}

.danger-zone h2 {
  margin-bottom: 4px;
  color: var(--ui-danger);
  font-size: 14px;
}

.danger-zone p {
  margin-bottom: 12px;
  color: #8d332c;
  font-size: 11px;
}

.member-add-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  align-items: end;
  gap: 12px;
}

.member-add-form .form-field input,
.member-add-form .form-field select {
  min-height: 42px;
  height: 42px;
  box-sizing: border-box;
  font-size: 13px;
}

.member-add-form .button,
.member-add-form input[type="submit"] {
  min-height: 42px;
  height: 42px;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 600;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.member-resource-table {
  width: 100%;
  border-collapse: collapse;
}

.member-resource-table .resource-row {
  display: table-row;
}

.member-resource-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--ui-border);
  vertical-align: middle;
}

.member-resource-table tr:last-child td {
  border-bottom: 0;
}


.inline-role-form {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  vertical-align: middle;
}

.member-resource-table .resource-actions {
  display: table-cell;
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.member-resource-table .resource-actions > form {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}

.member-resource-table .resource-actions .inline-role-form {
  display: inline-flex;
}

.inline-role-form select {
  width: auto;
  min-height: 34px;
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
  box-sizing: border-box;
  vertical-align: middle;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-surface);
}

.inline-role-form .button,
.inline-role-form input[type="submit"],
.resource-actions .button,
.resource-actions button {
  min-height: 34px;
  height: 34px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.owner-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  box-sizing: border-box;
  border-radius: var(--ui-radius-sm);
  background: #f4f6f8;
  color: var(--ui-muted);
  vertical-align: middle;
}

/* Public and authentication */

.public-main {
  min-height: 100dvh;
  background: var(--ui-bg);
}

.landing {
  position: relative;
  display: flex;
  min-height: 100dvh;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 72px 24px 150px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgb(206 223 240 / 50%), transparent 34%),
    var(--ui-surface);
  text-align: center;
}

.landing__logo {
  width: 96px;
  height: 72px;
  margin-bottom: 16px;
  object-fit: contain;
}

.landing h1 {
  margin-bottom: 8px;
  font-size: clamp(38px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -0.055em;
}

.landing__tagline {
  margin-bottom: 36px;
  color: var(--ui-muted);
  font-size: 13px;
}

.landing-composer {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(100%, 750px);
  min-height: 128px;
  flex-direction: column;
  padding: 18px;
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-lg);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 18px 50px rgb(45 79 117 / 12%);
  text-align: left;
  backdrop-filter: blur(10px);
}

.landing-composer > p {
  flex: 1;
  margin-bottom: 18px;
  color: var(--ui-placeholder);
  font-size: 15px;
}

.landing-composer__footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.landing-composer__footer > img:first-child,
.landing-composer__footer > .ui-icon:first-child {
  width: 18px;
  height: 18px;
  font-size: 18px;
}

.landing-composer__model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ui-muted);
  font-size: 11px;
}

.landing-composer__model img,
.landing-composer__model .ui-icon {
  width: 9px;
  font-size: 9px;
}

.landing-composer__send {
  width: 34px;
  height: 34px;
  margin-left: auto;
  padding: 8px;
  border-radius: 50%;
  background: var(--ui-text);
  color: #fff;
  font-size: 18px;
}

.landing__actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.landing__footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100px;
  object-fit: cover;
  object-position: center bottom;
  pointer-events: none;
}

.auth-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 38px 20px;
  background:
    radial-gradient(circle at top left, rgb(206 223 240 / 70%), transparent 35%),
    radial-gradient(circle at bottom right, rgb(176 204 241 / 38%), transparent 30%),
    var(--ui-bg);
}

.auth-card {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 28px;
  color: var(--ui-text);
  font-size: 17px;
  font-weight: 700;
}

.auth-brand img {
  width: 31px;
  height: 24px;
  object-fit: contain;
}

.auth-card h1 {
  margin-bottom: 8px;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.auth-card__intro {
  margin-bottom: 22px;
  color: var(--ui-muted);
  font-size: 12px;
}

.auth-card form {
  display: grid;
  gap: 15px;
}

.auth-card .actions input {
  width: 100%;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 18px;
  color: var(--ui-primary-dark);
  font-size: 11px;
}

.auth-links a:hover,
.auth-back:hover {
  text-decoration: underline;
}

.auth-back {
  display: inline-block;
  margin-top: 18px;
  color: var(--ui-muted);
  font-size: 10px;
}

/* Responsive */

@media (max-width: 1100px) {
  .chat-layout--sources-open {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .member-add-form {
    grid-template-columns: minmax(0, 1fr) 160px;
  }

  .member-add-form > .button {
    grid-column: 1 / -1;
    justify-self: end;
  }
}

@media (max-width: 900px) {
  body.app-body {
    min-height: 0;
  }

  .app-stage {
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .mobile-header {
    position: absolute;
    z-index: 30;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    height: 56px;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--ui-border);
    background: rgb(255 255 255 / 94%);
    backdrop-filter: blur(12px);
  }

  .mobile-brand {
    margin-right: auto;
    margin-left: 6px;
    font-size: 16px;
  }

  .mobile-brand .brand-logo {
    width: 28px;
  }

  .app-main {
    padding-top: 56px;
  }

  .sidebar {
    position: fixed;
    z-index: 100;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 292px);
    min-width: min(86vw, 292px);
    background: var(--ui-bg);
    box-shadow: 18px 0 50px rgb(15 23 42 / 18%);
    transform: translateX(-105%);
  }

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

  .sidebar-mobile-close {
    display: grid;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 90;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgb(15 23 42 / 42%);
    backdrop-filter: blur(2px);
  }

  .app-shell--collapsed .sidebar {
    width: min(86vw, 292px);
    min-width: min(86vw, 292px);
  }

  .app-shell--collapsed .sidebar-brand-row,
  .app-shell--collapsed .sidebar-panel {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .app-shell--collapsed .app-stage {
    margin: 0;
  }

  .app-shell--collapsed .sidebar-toggle {
    display: none;
  }

  .chat-page {
    height: calc(100dvh - 56px);
  }

  .chat-page--empty {
    height: calc(100dvh - 56px);
  }

  .chat-topbar {
    min-height: 54px;
    padding: 8px 13px;
  }

  .chat-topbar__actions .button span {
    display: none;
  }

  .chat-layout--sources-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .sources-drawer {
    position: absolute;
    z-index: 50;
    inset: 0 0 0 auto;
    width: 100%;
    border-left: 1px solid var(--ui-border);
    box-shadow: -18px 0 48px rgb(15 23 42 / 18%);
  }

  .codex-modal-layer {
    min-height: calc(100dvh - 56px);
  }

  .settings-tabs {
    top: 0;
  }

  .account-settings-page {
    padding: 28px 18px 44px;
  }

  .account-settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-settings-nav {
    position: static;
    display: flex;
    padding: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .account-settings-nav::-webkit-scrollbar,
  .account-settings-nav > p {
    display: none;
  }

  .account-settings-nav__item {
    min-width: max-content;
  }

  .account-settings-nav__item small {
    display: none;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 26px 16px 44px;
  }

  .page-heading {
    display: grid;
  }

  .page-heading__actions {
    justify-content: stretch;
  }

  .page-heading__actions .button {
    flex: 1;
  }

  .workspace-grid,
  .dashboard-grid,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .chat-empty-layout {
    justify-content: flex-start;
    padding: 100px 16px 30px;
  }

  .chat-empty-state {
    margin-bottom: 24px;
  }

  .chat-empty-state h2 {
    font-size: 22px;
  }

  .composer {
    min-height: 112px;
    border-radius: var(--ui-radius-md);
  }

  .composer__model {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-thread {
    padding: 26px 16px 12px;
  }

  .chat-message__content {
    padding-left: 0;
  }

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

  .ai-disclaimer {
    display: none;
  }

  .settings-tabs {
    padding-inline: 12px;
  }

  .settings-content {
    padding: 24px 14px;
  }

  .settings-section {
    padding: 18px;
  }

  .codex-modal-layer {
    padding: 0;
    background: var(--ui-surface);
  }

  .codex-modal-card {
    min-height: calc(100dvh - 56px);
    padding: 0 14px 24px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .modal-heading {
    margin: 0 -14px 18px;
    padding: 10px 12px;
  }

  .modal-heading h1 {
    font-size: 16px;
  }

  .resource-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .resource-row .resource-checkbox {
    display: none;
  }

  .upload-zone {
    padding: 22px 14px;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .detail-list dt,
  .detail-list dd {
    border-bottom: 0;
  }

  .detail-list dd {
    padding-top: 0;
    border-bottom: 1px solid var(--ui-border);
  }

  .detail-list dd:last-child {
    border-bottom: 0;
  }

  .member-add-form {
    grid-template-columns: 1fr;
  }

  .member-add-form > .button {
    grid-column: auto;
    width: 100%;
  }

  .member-resource-table {
    min-width: 700px;
  }

  .resource-list:has(.member-resource-table) {
    overflow-x: auto;
  }

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

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

  .landing {
    justify-content: flex-start;
    padding: 76px 16px 130px;
  }

  .landing__logo {
    width: 78px;
    height: 58px;
  }

  .landing h1 {
    font-size: 42px;
  }

  .landing__tagline {
    margin-bottom: 28px;
  }

  .landing__actions {
    width: min(100%, 360px);
    flex-direction: column;
  }

  .landing__actions .button {
    width: 100%;
  }

  .auth-card {
    padding: 24px 20px;
  }
}

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

/* Inline Title Edit Styles */
.chat-topbar__identity--session {
  flex: 1;
  min-width: 0;
}

.title-display {
  display: block;
  cursor: text;
  padding: 2px 0;
  width: 100%;
}

.title-display:hover {
  background-color: transparent;
}

.title-form {
  width: 100%;
  margin-left: -6px;
}

.title-input {
  width: 100%;
  font-size: 15px;
  font-weight: 600;
  color: var(--ui-text);
  background: #ffffff;
  border: 1px solid var(--ui-primary);
  border-radius: 6px;
  padding: 2px 6px;
  outline: none;
  box-shadow: 0 0 0 3px var(--ui-primary-soft);
  box-sizing: border-box;
}

/* Avatar Upload Settings Styles */
.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.user-avatar--large {
  width: 56px;
  height: 56px;
  font-size: 20px;
  flex: 0 0 56px;
  border-radius: 50%;
  overflow: hidden;
}

.avatar-upload-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-upload-button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.user-avatar--large {
  width: 56px;
  height: 56px;
  font-size: 20px;
  flex: 0 0 56px;
  border-radius: 50%;
  overflow: hidden;
}

.avatar-upload-inputs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-file-input {
  font-size: 13px;
  color: var(--ui-text);
}

/* PDF Viewer Styles */
.pdf-viewer-container {
  width: 100%;
  height: 680px;
  border-radius: var(--ui-radius-sm);
  overflow: hidden;
  border: 1px solid var(--ui-border);
  background: #f8fafc;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.pdf-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Admin Portal Styles */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.admin-stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-xs);
}

.admin-stat-card__icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 12px;
  background: var(--ui-primary-soft);
  color: var(--ui-primary-dark);
  font-size: 22px;
  flex-shrink: 0;
}

.admin-stat-card__info {
  display: flex;
  flex-direction: column;
}

.admin-stat-card__value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ui-text);
  line-height: 1.2;
}

.admin-stat-card__label {
  font-size: 0.8rem;
  color: var(--ui-muted);
  margin-top: 2px;
}

/* Onboarding Tutorial Wizard Styles */
.onboarding-body {
  background: linear-gradient(135deg, #f0f4f9 0%, #e2eaf4 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.onboarding-wrapper {
  width: 100%;
  max-width: 580px;
}

.onboarding-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

.onboarding-header {
  text-align: center;
  margin-bottom: 28px;
}

.onboarding-logo {
  height: 64px;
  width: auto;
  margin: 0 auto 16px;
  display: block;
}

.onboarding-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ui-text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.onboarding-header p {
  color: var(--ui-muted);
  font-size: 14px;
  line-height: 1.5;
}

.onboarding-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.onboarding-step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.onboarding-step-indicator.is-active,
.onboarding-step-indicator.is-completed {
  opacity: 1;
}

.onboarding-step-indicator .step-num {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 700;
}

.onboarding-step-indicator.is-active .step-num {
  background: var(--ui-primary-dark);
  color: #ffffff;
}

.onboarding-step-indicator.is-completed .step-num {
  background: #10b981;
  color: #ffffff;
}

.onboarding-step-indicator .step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ui-text);
}

.onboarding-step-divider {
  width: 32px;
  height: 2px;
  background: #cbd5e1;
}

.onboarding-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ui-text);
  margin-bottom: 8px;
}

.onboarding-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border);
  font-size: 14px;
  background: #f8fafc;
  transition: border-color 0.2s, background-color 0.2s;
}

.onboarding-input:focus {
  outline: none;
  border-color: var(--ui-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.onboarding-step-content.is-hidden {
  display: none !important;
}

