:root {
  color-scheme: light;
  --bg: #f6f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #111827;
  --muted: #6b7280;
  --faint: #94a3b8;
  --brand: #111827;
  --accent: #2563eb;
  --accent-soft: #eaf2ff;
  --success: #059669;
  --warning: #b45309;
  --danger: #dc2626;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --sidebar-width: 228px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body[data-auth="false"] .app-shell,
body[data-auth="true"] .landing-screen {
  display: none;
}

.landing-screen {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.94) 38%, #eef2f7 100%);
  color: #0b1220;
}

.landing-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.62);
  background: rgba(255, 255, 255, 0.72);
  padding: 0 clamp(20px, 5vw, 86px);
  backdrop-filter: blur(22px);
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #111827;
  font-size: 15px;
  font-weight: 850;
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(203, 213, 225, 0.58);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 5px;
}

.landing-nav a,
.landing-nav button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.landing-nav a:hover,
.landing-nav button:hover {
  background: #fff;
}

.landing-main {
  padding: 40px clamp(20px, 5vw, 86px) 72px;
}

.landing-hero {
  display: grid;
  min-height: calc(100vh - 150px);
  grid-template-columns: 1fr;
  align-items: start;
  gap: 30px;
}

.landing-copy {
  display: grid;
  justify-items: center;
  max-width: 760px;
  margin: 0 auto;
  padding-top: 28px;
  text-align: center;
}

.landing-eyebrow {
  display: inline-flex;
  margin-bottom: 16px;
  border: 1px solid rgba(244, 63, 94, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #9f1239;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.02em;
  backdrop-filter: blur(16px);
}

.landing-copy h1 {
  margin: 0;
  max-width: 540px;
  color: #111827;
  font-size: clamp(42px, 5vw, 72px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

.landing-copy p {
  margin: 18px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.75;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 26px;
}

.landing-actions a {
  text-decoration: none;
}

.landing-actions button {
  cursor: pointer;
}

.landing-primary,
.landing-secondary {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 850;
}

.landing-primary {
  border: 1px solid #111827;
  background: #111827;
  color: #fff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.16);
}

.landing-secondary {
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: rgba(255, 255, 255, 0.68);
  color: #0b1220;
}

.landing-secondary:hover,
.landing-primary:hover {
  transform: translateY(-1px);
}

.landing-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}

.landing-metrics div {
  display: grid;
  min-width: 116px;
  gap: 3px;
  border: 1px solid rgba(226, 232, 240, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  padding: 11px 14px;
  backdrop-filter: blur(18px);
}

.landing-metrics strong {
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0;
}

.landing-metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.landing-visual {
  position: relative;
  width: min(1120px, 100%);
  min-height: 390px;
  margin: 0 auto;
  border: 1px solid rgba(203, 213, 225, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.42)),
    linear-gradient(135deg, rgba(244, 63, 94, 0.06), rgba(17, 24, 39, 0.04));
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.landing-visual img {
  display: block;
  width: min(92%, 940px);
  margin: 24px auto 0;
  filter: saturate(0.94) contrast(1.02);
}

.landing-login {
  position: absolute;
  right: 26px;
  bottom: 24px;
  display: grid;
  width: min(340px, calc(100% - 52px));
  gap: 13px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 18px;
  box-shadow: 0 22px 68px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(28px);
}

.landing-login.auth-modal {
  position: relative;
  right: auto;
  bottom: auto;
  width: min(360px, 100%);
  background: rgba(255, 255, 255, 0.94);
}

.auth-backdrop {
  z-index: 80;
}

.auth-close {
  font-size: 20px;
  line-height: 1;
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.login-head h2 {
  margin: 0;
  font-size: 18px;
}

.login-head span {
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid rgba(203, 213, 225, 0.78);
  border-radius: 8px;
  background: rgba(241, 245, 249, 0.84);
  padding: 4px;
}

.auth-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-weight: 900;
}

.auth-switch button.is-active {
  background: #fff;
  color: #0b1220;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.landing-login[data-mode="login"] .register-only {
  display: none;
}

.landing-login label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.landing-login input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  padding: 9px 11px;
}

.landing-login p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: min(1120px, 100%);
  margin: 26px auto 0;
}

.value-grid article {
  border: 1px solid rgba(226, 232, 240, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  padding: 20px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(18px);
}

.value-grid span {
  color: #64748b;
  font-weight: 900;
}

.value-grid h2 {
  margin: 10px 0 8px;
  font-size: 18px;
  letter-spacing: 0;
}

.value-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

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

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  height: 100vh;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-width) 1fr;
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f1f3f7;
  padding: 18px 10px 12px;
  overflow: hidden;
}

.brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  font-size: 16px;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.brand-mark svg,
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-mark img {
  object-fit: cover;
}

.new-chat {
  flex: 0 0 auto;
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 3px 14px rgba(15, 23, 42, 0.04);
}

.new-chat .icon {
  font-size: 22px;
  line-height: 1;
}

.conversation-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 34px 8px 16px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.conversation-empty {
  color: var(--muted);
  font-size: 14px;
}

.conversation-list {
  display: grid;
  gap: 8px;
}

.conversation-list:empty {
  display: none;
}

.conversation-list:not(:empty) + .conversation-empty,
.conversation-panel:has(.conversation-list:not(:empty)) .conversation-empty {
  display: none;
}

.conversation-group-label {
  margin: 8px 8px 2px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 750;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 4px;
  width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 2px;
  text-align: left;
}

.conversation-item.is-active,
.conversation-item:hover {
  background: #e8ebf3;
}

.conversation-main,
.conversation-delete {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.conversation-main {
  display: grid;
  min-width: 0;
  gap: 2px;
  padding: 8px;
  text-align: left;
}

.conversation-title,
.conversation-time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title {
  color: var(--text);
  font-weight: 650;
}

.conversation-time {
  color: var(--faint);
  font-size: 12px;
}

.conversation-delete {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
}

.conversation-delete:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--danger);
}

.nav-section {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.nav-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 13px;
}

.nav-item {
  display: grid;
  width: 100%;
  min-height: 38px;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.is-active {
  background: #e8eaf5;
}

.nav-icon {
  display: inline-flex;
  color: #475569;
}

.connection-count {
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
}

.user-strip {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 30px;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 0;
  font-weight: 700;
}

.user-profile {
  display: grid;
  min-width: 0;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 4px;
  text-align: left;
}

.user-profile:hover {
  background: #e8ebf3;
}

.user-profile span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
}

.workspace {
  min-width: 0;
  background: var(--bg);
  overflow: auto;
}

.topbar {
  display: flex;
  height: 56px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  padding: 0 24px;
}

.topbar-title {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #475569;
}

.icon-button:hover {
  background: #e8ebf3;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero-chat {
  position: relative;
  display: flex;
  min-height: calc(100vh - 56px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 120px;
}

.hero-chat h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: 0;
}

.hero-chat p {
  margin: 18px 0 30px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.assistant-avatar {
  position: absolute;
  width: 42px;
  height: 42px;
  border: 4px solid #e6f2ff;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, #ffd8c9 0 22%, transparent 23%),
    radial-gradient(circle at 43% 37%, #111827 0 3%, transparent 4%),
    radial-gradient(circle at 58% 37%, #111827 0 3%, transparent 4%),
    radial-gradient(circle at 50% 72%, #151823 0 28%, transparent 29%),
    linear-gradient(#f9c5b5, #f6b7a6);
  box-shadow: var(--shadow);
}

.avatar-top {
  right: 28px;
  top: 120px;
}

.avatar-mid {
  right: 18px;
  top: 50%;
}

.prompt-form,
.chat-composer {
  display: grid;
  width: min(680px, 100%);
  grid-template-columns: 1fr 42px;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 10px 8px 16px;
  box-shadow: var(--shadow);
}

textarea {
  width: 100%;
  min-height: 40px;
  max-height: 128px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  line-height: 1.6;
}

textarea::placeholder,
input::placeholder {
  color: #9ca3af;
}

.send-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.send-button:hover {
  background: var(--brand);
  color: #fff;
}

.send-button:active {
  transform: scale(0.96);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.7;
}

.send-button.is-loading svg {
  opacity: 0;
}

.send-button.is-loading::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: send-spin 0.75s linear infinite;
}

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

.slash-skill-menu {
  position: fixed;
  z-index: 90;
  transform: translateY(-100%);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
}

.slash-skill-head {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.slash-skill-menu button {
  display: grid;
  width: 100%;
  min-height: 52px;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
}

.slash-skill-menu button + button {
  border-top: 1px solid var(--line);
}

.slash-skill-menu button:hover,
.slash-skill-menu button.is-selected {
  background: var(--accent-soft);
}

.slash-skill-menu strong,
.slash-skill-menu span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-skill-menu strong {
  font-size: 13px;
}

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

.hint-line {
  margin-top: 14px;
  color: #9ca3af;
  font-size: 13px;
}

.ai-control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: min(860px, 100%);
  justify-self: center;
  margin: 0 auto 10px;
}

.ai-control-bar.compact {
  width: min(680px, 100%);
  margin-top: 10px;
  margin-bottom: 0;
  justify-content: center;
}

.ai-control-bar label {
  display: grid;
  min-width: 150px;
  grid-template-columns: auto minmax(96px, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 7px 9px;
}

.ai-control-bar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.ai-control-bar select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-weight: 850;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.quick-prompts button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: #475569;
  padding: 6px 18px;
  font-weight: 700;
}

.quick-prompts button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.page-wrap {
  padding: 28px 24px 56px;
}

.page-heading,
.skill-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

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

.skill-upload-button {
  cursor: pointer;
}

.skill-upload-button input {
  display: none;
}

.page-heading h1,
.skill-title-row h1,
.chat-header h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.page-heading p,
.chat-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.inline-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.inline-heading span {
  color: var(--muted);
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
}

.ghost-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.segmented {
  display: flex;
  gap: 4px;
  border-radius: 8px;
  background: #f1f5f9;
  padding: 4px;
}

.segmented button {
  min-width: 58px;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  padding: 6px 12px;
  font-weight: 700;
}

.segmented button.is-selected {
  background: #fff;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}

.metric-grid,
.skill-grid,
.connection-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.skill-grid,
.connection-grid {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

.metric-card,
.skill-card,
.connection-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  font-size: 28px;
  letter-spacing: 0;
}

.metric-card em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.metric-card .trend-up {
  color: var(--success);
}

.metric-card .trend-down {
  color: var(--danger);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.insight-list {
  display: grid;
  gap: 12px;
}

.insight-item {
  border-left: 3px solid var(--accent);
  background: var(--panel-soft);
  padding: 12px 14px;
}

.insight-item strong {
  display: block;
  margin-bottom: 5px;
}

.insight-item span {
  color: var(--muted);
  font-size: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
}

.data-table th {
  color: var(--muted);
  font-weight: 800;
}

.admin-page {
  display: grid;
  gap: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) minmax(260px, 0.9fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.admin-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.admin-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.admin-panel-head h2,
.admin-editor h2 {
  margin: 0;
  font-size: 18px;
}

.admin-panel-head span {
  max-width: 180px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

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

.admin-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.admin-item div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-item strong {
  font-size: 15px;
}

.admin-item span {
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.admin-item p,
.admin-item small {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.admin-item small {
  color: #475569;
}

.credit-form {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.credit-form input {
  width: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

.admin-editor form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.admin-editor label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.admin-editor label:nth-child(2),
.admin-editor label:nth-child(3),
.admin-editor label:nth-child(4) {
  grid-column: 1 / -1;
}

.admin-editor input,
.admin-editor textarea,
.admin-editor select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px;
}

.admin-editor button {
  justify-self: start;
}

.admin-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(239, 68, 68, 0.09), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #f5f7fb 48%, #eef2f7 100%);
}

.admin-console {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: grid;
  height: 100vh;
  grid-template-rows: auto auto 1fr;
  gap: 28px;
  border-right: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(255, 255, 255, 0.72);
  padding: 28px;
  backdrop-filter: blur(24px);
}

.admin-brand {
  align-items: start;
}

.admin-brand div:last-child {
  display: grid;
  gap: 4px;
}

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

.admin-nav {
  display: grid;
  gap: 8px;
}

.admin-nav a,
.admin-front-link {
  border-radius: 10px;
  color: #334155;
  font-size: 14px;
  font-weight: 850;
  padding: 11px 12px;
  text-decoration: none;
}

.admin-nav a:hover,
.admin-front-link:hover {
  background: #eef2f7;
}

.admin-front-link {
  align-self: end;
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
}

.admin-main {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 34px;
}

.admin-hero {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0 4px;
}

.admin-hero h1 {
  margin: 8px 0;
  color: #111827;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: 0;
}

.admin-hero p,
.admin-section-head p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.admin-section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-section-head h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.admin-counter {
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  padding: 7px 12px;
  white-space: nowrap;
}

.admin-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.2fr);
  gap: 18px;
}

.admin-store-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-store-form label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
}

.admin-store-form input,
.admin-store-form select {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

.admin-store-form button {
  align-self: end;
  min-height: 40px;
}

.skill-card {
  position: relative;
  display: grid;
  min-height: 170px;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 22px;
}

.skill-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skill-card h2,
.connection-card h2 {
  margin: 0;
  font-size: 18px;
}

.card-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #f1f5ff;
  color: #315f9d;
}

.skill-card p,
.connection-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.skill-card .example {
  color: #475569;
  font-weight: 700;
}

.skill-config-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.card-action-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.start-button,
.connect-button {
  min-width: 74px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 8px 14px;
  font-weight: 800;
}

.ghost-mini-button,
.icon-mini-button {
  min-height: 32px;
  border-radius: 8px;
  font-weight: 800;
}

.ghost-mini-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #475569;
  padding: 6px 10px;
}

.icon-mini-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #475569;
  padding: 5px 9px;
}

.icon-mini-button.danger {
  color: var(--danger);
}

.connection-card {
  display: grid;
  min-height: 142px;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 22px;
}

.connection-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.connection-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.connection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.connected {
  color: var(--success);
}

.status-pill.warning {
  color: var(--warning);
}

.settings-layout {
  display: grid;
  gap: 22px;
  padding: 28px 24px 56px;
}

.settings-tabs {
  display: inline-flex;
  width: fit-content;
  gap: 4px;
  border-radius: 8px;
  background: #f1f5f9;
  padding: 4px;
}

.settings-tabs button,
.theme-options button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  padding: 7px 14px;
  font-weight: 800;
}

.settings-tabs button.is-selected,
.theme-options button.is-selected {
  background: #fff;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}

.settings-panel {
  max-width: 980px;
}

.settings-panel h1 {
  margin: 0 0 18px;
  font-size: 26px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-card,
.settings-list-item,
.member-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.settings-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.account-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  max-width: 620px;
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.account-list dt,
.account-list dd {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.account-list dt {
  color: var(--muted);
  font-weight: 900;
}

.account-list dd {
  font-weight: 800;
}

.account-list dt:last-of-type,
.account-list dd:last-of-type {
  border-bottom: 0;
}

.settings-list,
.member-list {
  display: grid;
  gap: 10px;
}

.settings-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
}

.settings-list-item div:first-child {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.settings-list-item strong {
  font-size: 16px;
}

.settings-list-item span,
.settings-empty {
  color: var(--muted);
  font-size: 13px;
}

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

.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.member-create-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.member-create-form input,
.member-create-form select,
.member-item input,
.member-item select {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.member-item {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 110px 100px auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.member-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.member-main span,
.member-main small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-theme="dark"] {
  --bg: #101827;
  --panel: #142033;
  --panel-soft: #1a2940;
  --line: #2d3d55;
  --line-strong: #465873;
  --text: #f6f9ff;
  --muted: #a7b4c7;
  --faint: #7f8da3;
  --brand: #f8fafc;
  --accent-soft: #1e3558;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
}

body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .workspace {
  background: var(--bg);
}

body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .topbar {
  border-color: var(--line);
}

body[data-theme="dark"] .nav-item:hover,
body[data-theme="dark"] .nav-item.is-active,
body[data-theme="dark"] .conversation-item:hover,
body[data-theme="dark"] .conversation-item.is-active,
body[data-theme="dark"] .user-profile:hover,
body[data-theme="dark"] .icon-button:hover {
  background: #1e293b;
}

body[data-theme="dark"] .conversation-delete:hover {
  background: rgba(127, 141, 163, 0.24);
  color: #fca5a5;
}

body[data-theme="dark"] .new-chat,
body[data-theme="dark"] .prompt-form,
body[data-theme="dark"] .chat-composer,
body[data-theme="dark"] .settings-card,
body[data-theme="dark"] .settings-list-item,
body[data-theme="dark"] .member-item,
body[data-theme="dark"] .metric-card,
body[data-theme="dark"] .skill-card,
body[data-theme="dark"] .connection-card,
body[data-theme="dark"] .panel,
body[data-theme="dark"] .account-list,
body[data-theme="dark"] .modal,
body[data-theme="dark"] .message.assistant {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .settings-tabs,
body[data-theme="dark"] .theme-options,
body[data-theme="dark"] .segmented,
body[data-theme="dark"] .auth-switch {
  background: #1a2940;
  border-color: var(--line);
}

body[data-theme="dark"] .settings-tabs button,
body[data-theme="dark"] .theme-options button,
body[data-theme="dark"] .segmented button {
  color: #b8c6dc;
}

body[data-theme="dark"] .settings-tabs button.is-selected,
body[data-theme="dark"] .theme-options button.is-selected,
body[data-theme="dark"] .segmented button.is-selected {
  background: #e5edf7;
  color: #0f172a;
  box-shadow: none;
}

body[data-theme="dark"] .secondary-button,
body[data-theme="dark"] .ghost-button,
body[data-theme="dark"] .ghost-mini-button,
body[data-theme="dark"] .icon-mini-button,
body[data-theme="dark"] .quick-prompts button,
body[data-theme="dark"] .attach-button {
  border-color: var(--line-strong);
  background: #18243a;
  color: var(--text);
}

body[data-theme="dark"] .secondary-button:hover,
body[data-theme="dark"] .ghost-mini-button:hover,
body[data-theme="dark"] .icon-mini-button:hover,
body[data-theme="dark"] .quick-prompts button:hover {
  background: #22334f;
}

body[data-theme="dark"] .primary-button,
body[data-theme="dark"] .start-button,
body[data-theme="dark"] .connect-button,
body[data-theme="dark"] .toast {
  background: #e5edf7;
  color: #101827;
}

body[data-theme="dark"] input,
body[data-theme="dark"] textarea,
body[data-theme="dark"] select,
body[data-theme="dark"] .member-create-form input,
body[data-theme="dark"] .member-create-form select,
body[data-theme="dark"] .member-item input,
body[data-theme="dark"] .member-item select,
body[data-theme="dark"] .modal input,
body[data-theme="dark"] .modal select,
body[data-theme="dark"] .admin-editor input,
body[data-theme="dark"] .admin-editor textarea,
body[data-theme="dark"] .admin-editor select,
body[data-theme="dark"] .admin-store-form input,
body[data-theme="dark"] .admin-store-form select {
  border-color: var(--line-strong);
  background: #0f1727;
  color: var(--text);
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
  color: #7f8da3;
}

body[data-theme="dark"] option {
  background: #0f1727;
  color: var(--text);
}

body[data-theme="dark"] .card-icon,
body[data-theme="dark"] .attachment-chip > span,
body[data-theme="dark"] .login-head span {
  background: #20365b;
  color: #b9d6ff;
}

body[data-theme="dark"] .message-body code,
body[data-theme="dark"] .message.assistant .message-attachments > span,
body[data-theme="dark"] .artifact-link,
body[data-theme="dark"] .attachment-chip,
body[data-theme="dark"] .attachment-tray {
  background: #18243a;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .thinking-toggle:hover {
  background: #18243a;
}

body[data-theme="dark"] .thinking-panel {
  border-color: var(--line);
}

body[data-theme="dark"] .message-body pre {
  background: #07111f;
}

body[data-theme="dark"] .ai-control-bar label {
  background: #18243a;
  border-color: var(--line);
}

body[data-theme="dark"] .connection-auth-panel,
body[data-theme="dark"] .connection-detail-list {
  background: var(--panel-soft);
  border-color: var(--line);
}

body[data-theme="dark"] .connection-detail-list dt,
body[data-theme="dark"] .connection-detail-list dd {
  border-color: var(--line);
}

body[data-theme="dark"] .connection-auth-visual {
  border-color: var(--line-strong);
}

.chat-layout {
  display: grid;
  height: calc(100vh - 56px);
  grid-template-rows: auto 1fr auto;
  padding: 26px 24px 18px;
}

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

.messages {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 8px 0 24px;
}

.message-row {
  display: grid;
  align-items: start;
  gap: 8px;
  width: fit-content;
  max-width: min(820px, 100%);
}

.message-row.assistant {
  grid-template-columns: 32px minmax(0, 760px);
  align-self: flex-start;
}

.message-row.user {
  grid-template-columns: minmax(0, 760px) 32px;
  align-self: flex-end;
}

.message-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.message-avatar.assistant {
  background: #fee2e2;
  color: #991b1b;
}

.message-avatar.user {
  background: #111827;
  color: #fff;
}

.message {
  min-width: 0;
  max-width: 760px;
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
}

.message.assistant {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--panel);
}

.thinking-process {
  margin-top: 4px;
  white-space: normal;
}

.thinking-toggle {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  max-width: min(360px, 100%);
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.thinking-toggle:hover {
  background: #f1f5f9;
}

.thinking-toggle span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.thinking-toggle strong {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thinking-toggle small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.thinking-toggle::after {
  content: "+";
  justify-self: center;
  width: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.thinking-process.is-expanded .thinking-toggle::after {
  content: "-";
}

.thinking-panel {
  display: grid;
  gap: 8px;
  max-width: min(460px, 100%);
  max-height: 180px;
  margin-top: 6px;
  overflow: auto;
  border: 0;
  border-left: 2px solid var(--line);
  border-radius: 0;
  padding: 4px 0 4px 12px;
  background: transparent;
  overscroll-behavior: contain;
}

.thinking-panel[hidden] {
  display: none;
}

.thinking-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: -4px;
  z-index: 1;
  margin: -4px 0 2px;
  padding: 3px 0 6px;
  border-bottom: 0;
  background: inherit;
  color: var(--muted);
  font-size: 12px;
}

.thinking-panel-head strong {
  color: var(--text);
  font-size: 12px;
}

.thinking-step {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  padding: 2px 0;
}

.thinking-step strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
}

.thinking-step p {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.thinking-dot {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
}

.thinking-step.is-done .thinking-dot {
  border-color: #16a34a;
  background: #16a34a;
}

.thinking-step.is-current .thinking-dot {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

@keyframes pending-dots {
  0%, 100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.7;
  }
}

.message-body {
  display: grid;
  gap: 10px;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6,
.message-body p,
.message-body ul,
.message-body ol,
.message-body blockquote,
.message-body pre,
.message-body hr,
.message-body table {
  margin: 0;
}

.message-body h1 {
  font-size: 22px;
}

.message-body h2 {
  font-size: 18px;
}

.message-body h3 {
  font-size: 15px;
}

.message-body h4,
.message-body h5,
.message-body h6 {
  font-size: 14px;
}

.message-body ul,
.message-body ol {
  padding-left: 20px;
}

.message-body li + li {
  margin-top: 4px;
}

.message-body code {
  border-radius: 5px;
  background: #f1f5f9;
  padding: 2px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.message-body pre {
  overflow: auto;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
}

.message-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.message-body blockquote {
  border-left: 3px solid var(--line);
  color: var(--muted);
  padding-left: 10px;
}

.message-body hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
}

.md-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.message-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.message-body th,
.message-body td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

.message-body th {
  background: var(--panel-soft);
  font-weight: 800;
}

.message-body a {
  color: #b91c1c;
  font-weight: 800;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.message-attachments > span {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 9px;
  font-size: 12px;
}

.message.assistant .message-attachments > span {
  background: #f1f5f9;
  color: #475569;
}

.message-file-chip {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  max-width: min(360px, 100%);
}

.message-file-chip > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 10px;
  font-weight: 900;
}

.message.assistant .message-file-chip > span {
  background: #e0e7ff;
  color: #3730a3;
}

.message-file-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file-chip small {
  color: inherit;
  opacity: 0.72;
  white-space: nowrap;
}

.message-file-chip small:empty {
  display: none;
}

.message-artifacts {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.artifact-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
}

.artifact-link strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.artifact-link a {
  color: #b91c1c;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.attachment-tray {
  width: min(860px, 100%);
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.attachment-tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.attachment-tray-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.attachment-tray-head button,
.attachment-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.attachment-chip > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 900;
}

.attachment-chip.is-uploading > span::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: send-spin 0.75s linear infinite;
}

.attachment-chip.is-error {
  border-color: rgba(220, 38, 38, 0.42);
}

.attachment-chip.is-error > span {
  background: #fee2e2;
  color: #991b1b;
}

.attachment-chip.is-error small {
  color: var(--danger);
}

.attachment-chip strong,
.attachment-chip small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip strong {
  font-size: 13px;
}

.attachment-chip small {
  color: var(--muted);
  font-size: 12px;
}

.chat-composer {
  width: min(860px, 100%);
  grid-template-columns: 42px 1fr 42px;
  padding-left: 10px;
  justify-self: center;
}

.attach-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #64748b;
}

.attach-button:hover {
  background: #f1f5f9;
  color: var(--text);
}

#chatFiles {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.38);
  padding: 20px;
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(460px, 100%);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}

.connection-modal {
  width: min(520px, 100%);
}

.connection-auth-panel {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 16px;
}

.connection-auth-visual {
  display: grid;
  width: 120px;
  height: 120px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.connection-qr {
  display: block;
  width: 112px;
  height: 112px;
}

.qr-placeholder {
  display: grid;
  width: 92px;
  height: 92px;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.qr-placeholder i {
  border-radius: 3px;
  background: #e2e8f0;
}

.qr-placeholder i.is-dark {
  background: #0f172a;
}

.auth-check {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 50%;
  background: #dcfce7;
  color: #047857;
  font-size: 34px;
  font-weight: 900;
}

.connection-auth-copy {
  display: grid;
  gap: 8px;
}

.connection-auth-copy h3 {
  margin: 0;
  font-size: 18px;
}

.connection-auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.inline-auth-link {
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.inline-auth-link:hover {
  text-decoration: underline;
}

.connection-detail-list {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.connection-detail-list dt,
.connection-detail-list dd {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.connection-detail-list dt {
  color: var(--muted);
  font-weight: 900;
}

.connection-detail-list dd {
  font-weight: 800;
}

.connection-detail-list dt:last-of-type,
.connection-detail-list dd:last-of-type {
  border-bottom: 0;
}

.connection-space-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.connection-space-list div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.connection-space-list span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.modal label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.modal input,
.modal select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  transform: translateY(20px);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.app-shell[data-collapsed="true"] {
  grid-template-columns: 72px 1fr;
}

.app-shell[data-collapsed="true"] .sidebar {
  padding-inline: 8px;
}

.app-shell[data-collapsed="true"] .brand span,
.app-shell[data-collapsed="true"] .new-chat span:last-child,
.app-shell[data-collapsed="true"] .conversation-panel,
.app-shell[data-collapsed="true"] .nav-label,
.app-shell[data-collapsed="true"] .nav-item span:not(.nav-icon),
.app-shell[data-collapsed="true"] .user-strip span {
  display: none;
}

.app-shell[data-collapsed="true"] .brand,
.app-shell[data-collapsed="true"] .new-chat {
  justify-content: center;
}

.app-shell[data-collapsed="true"] .nav-item {
  grid-template-columns: 1fr;
  justify-items: center;
}

.app-shell[data-collapsed="true"] .user-strip {
  grid-template-columns: 1fr;
  justify-items: center;
}

@media (max-width: 1100px) {
  .skill-grid,
  .connection-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .admin-grid,
  .admin-editor form,
  .admin-split,
  .admin-store-form,
  .member-create-form,
  .member-item {
    grid-template-columns: 1fr;
  }

  .admin-editor label:nth-child(2),
  .admin-editor label:nth-child(3),
  .admin-editor label:nth-child(4) {
    grid-column: auto;
  }

  .landing-hero,
  .value-grid {
    grid-template-columns: 1fr;
  }

  .landing-visual {
    min-height: auto;
  }

  .landing-visual img {
    margin: 0 auto;
  }

  .landing-login {
    position: relative;
    right: auto;
    bottom: auto;
    width: min(460px, 100%);
    margin: -42px auto 0;
  }

  .landing-login.auth-modal {
    width: min(360px, 100%);
    margin: 0;
  }
}

@media (max-width: 760px) {
  .admin-console {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
    gap: 16px;
    padding: 18px;
  }

  .admin-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-nav a,
  .admin-front-link {
    text-align: center;
  }

  .admin-main {
    padding: 18px;
  }

  .admin-hero,
  .admin-section-head {
    display: grid;
  }

  .app-shell,
  .app-shell[data-collapsed="true"] {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .workspace {
    overflow: visible;
  }

  .conversation-panel {
    display: none;
  }

  .nav-section {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .nav-label {
    display: none;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 4px;
    padding: 8px 4px;
    font-size: 12px;
  }

  .connection-count {
    display: none;
  }

  .user-strip {
    display: none;
  }

  .topbar {
    padding: 0 16px;
  }

  .hero-chat {
    min-height: calc(100vh - 258px);
    padding: 44px 16px 84px;
  }

  .avatar-top,
  .avatar-mid {
    display: none;
  }

  .page-wrap,
  .chat-layout {
    padding-inline: 16px;
  }

  .page-heading,
  .skill-title-row,
  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    overflow: auto;
  }

  .settings-tabs {
    width: 100%;
    overflow: auto;
  }

  .settings-head,
  .settings-list-item {
    align-items: stretch;
    flex-direction: column;
  }

  .connection-auth-panel,
  .connection-detail-list {
    grid-template-columns: 1fr;
  }

  .connection-auth-visual {
    width: 100%;
  }

  .skill-grid,
  .connection-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .landing-main {
    padding-top: 28px;
  }

  .landing-hero {
    min-height: auto;
    gap: 28px;
  }

  .landing-copy h1 {
    font-size: 32px;
    line-height: 1.12;
  }

  .landing-visual img {
    width: 100%;
    margin-left: 0;
  }

  .landing-login {
    margin-top: -28px;
  }

  .landing-login.auth-modal {
    margin-top: 0;
  }

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

  .ai-control-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ai-control-bar label {
    width: 100%;
  }
}
