/*
  AI Likeba workspace foundation.
  Keep shared shell, tokens, and reusable UI here so every workspace page can
  be adjusted from one place while older inline page styles are phased out.
*/

:root {
  color-scheme: light;
  --ai-bg: #f8fafc;
  --ai-surface: #ffffff;
  --ai-surface-soft: #f8fafc;
  --ai-ink: #0f172a;
  --ai-muted: #64748b;
  --ai-weak: #94a3b8;
  --ai-line: #e2e8f0;
  --ai-line-strong: #cbd5e1;
  --ai-green: #10b981;
  --ai-green-strong: #059669;
  --ai-green-dark: #047857;
  --ai-green-soft: #ecfdf5;
  --ai-yellow-soft: #fffbeb;
  --ai-yellow: #b45309;
  --ai-blue-soft: #eaf3ff;
  --ai-blue: #2368d9;
  --ai-red-soft: #fff0ee;
  --ai-red: #d83a2e;
  --ai-shadow-soft: 0 1px 2px rgba(15, 23, 42, .04);
  --ai-ease: cubic-bezier(.16, 1, .3, 1);
  --ai-sidebar-width: 240px;
  --ai-bottom-safe: 0px;
  --ai-radius-sm: 4px;
  --ai-radius-md: 6px;
  --ai-radius-lg: 8px;
  --ai-topbar-height: 64px;
  --ai-right-panel-width: 288px;

  /* Legacy aliases used by the current static pages. */
  --bg: var(--ai-bg);
  --surface: var(--ai-surface);
  --surface-soft: var(--ai-surface-soft);
  --ink: var(--ai-ink);
  --ink-soft: #26372f;
  --muted: var(--ai-muted);
  --weak: var(--ai-weak);
  --line: var(--ai-line);
  --line-strong: var(--ai-line-strong);
  --green: var(--ai-green);
  --green-strong: var(--ai-green-strong);
  --green-dark: var(--ai-green-dark);
  --green-soft: var(--ai-green-soft);
  --yellow-soft: var(--ai-yellow-soft);
  --yellow: var(--ai-yellow);
  --blue-soft: var(--ai-blue-soft);
  --blue: var(--ai-blue);
  --red-soft: var(--ai-red-soft);
  --red: var(--ai-red);
  --shadow-soft: var(--ai-shadow-soft);
  --ease: var(--ai-ease);
  --sidebar-width: var(--ai-sidebar-width);
  --bottom-safe: var(--ai-bottom-safe);
}

* {
  box-sizing: border-box;
}

html.ai-workspace-page,
body.ai-workspace-page {
  width: 100%;
  height: 100%;
}

body.ai-workspace-page {
  margin: 0;
  overflow: hidden;
  overflow-x: hidden;
  background: var(--ai-bg);
  color: var(--ai-ink);
  font-family: "PingFang SC", "HarmonyOS Sans", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:where(.ai-workspace-page a) {
  color: inherit;
  text-decoration: none;
}

:where(.ai-workspace-page button, .ai-workspace-page input, .ai-workspace-page textarea, .ai-workspace-page select) {
  font: inherit;
}

:where(.ai-workspace-page button) {
  cursor: pointer;
}

.ai-workspace-page :where(svg) {
  max-width: 100%;
}

.ai-workspace-page .app {
  width: 100vw;
  max-width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: linear-gradient(180deg, var(--ai-bg) 0%, #f7faf3 100%);
}

.ai-workspace-page .app .workspace-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--ai-sidebar-width) minmax(0, 1fr) var(--ai-right-panel-width);
  grid-template-rows: minmax(0, 1fr);
}

.ai-workspace-page .app.is-locked .workspace-shell {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.ai-workspace-page .sidebar {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ai-line);
  background: rgba(255, 255, 253, .94);
}

.ai-workspace-page .side-top {
  padding: 20px 20px 14px;
}

.ai-workspace-page .brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  margin-bottom: 20px;
}

.ai-workspace-page .brand img {
  width: 122px;
  max-width: 100%;
  display: block;
}

.ai-workspace-page .ghost-icon,
.ai-workspace-page .icon-button {
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #5f6f67;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s var(--ai-ease);
}

.ai-workspace-page .ghost-icon:hover,
.ai-workspace-page .icon-button:hover {
  background: #f0f5ed;
  border-color: var(--ai-line);
  color: var(--ai-ink);
}

.ai-workspace-page .new-chat {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--ai-radius-md);
  background: linear-gradient(180deg, #65e715, var(--ai-green));
  color: #061006;
  font-size: 14px;
  font-weight: 950;
  box-shadow: 0 12px 26px rgba(79, 210, 8, .22);
  transition: transform .18s var(--ai-ease), box-shadow .18s ease;
}

.ai-workspace-page .new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(79, 210, 8, .28);
}

.ai-workspace-page .nav-section {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 14px 12px 190px;
}

.ai-workspace-page .nav-item {
  position: relative;
  height: 44px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-radius: var(--ai-radius-sm);
  color: #42534b;
  font-size: 14px;
  font-weight: 740;
  transition: background .18s ease, color .18s ease;
}

.ai-workspace-page .nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-workspace-page .nav-item:hover {
  background: #f2f6ef;
  color: var(--ai-ink);
}

.ai-workspace-page .nav-item.active {
  color: var(--ai-green-dark);
  background: var(--ai-green-soft);
  font-weight: 950;
}

.ai-workspace-page .nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 99px;
  background: var(--ai-green-strong);
}

.ai-workspace-page .side-bottom {
  flex: 0 0 auto;
  position: fixed;
  left: 0;
  bottom: var(--ai-bottom-safe);
  z-index: 5;
  width: var(--ai-sidebar-width);
  display: grid;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--ai-line);
  background: rgba(255, 255, 253, .96);
}

.ai-workspace-page .account-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ai-ink);
  text-align: left;
}

.ai-workspace-page .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #dfe8db;
  background:
    radial-gradient(circle at 50% 28%, #ffd8a6 0 15%, transparent 16%),
    radial-gradient(circle at 50% 78%, #1d2d25 0 28%, transparent 29%),
    #eef5eb;
}

.ai-workspace-page .account-name {
  min-width: 0;
  display: block;
}

.ai-workspace-page .account-name strong,
.ai-workspace-page .account-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-workspace-page .account-name strong {
  font-size: 13px;
  font-weight: 950;
}

.ai-workspace-page .member-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: var(--ai-green-dark);
  font-size: 12px;
  font-weight: 800;
}

.ai-workspace-page .balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius-md);
  background: var(--ai-surface-soft);
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-workspace-page .balance-card strong {
  color: var(--ai-ink);
  font-size: 16px;
  font-weight: 950;
}

.ai-workspace-page .main {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--ai-bg);
}

.ai-workspace-page .topbar {
  min-width: 0;
  min-height: var(--ai-topbar-height);
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--ai-line);
  background: rgba(255, 255, 253, .72);
  backdrop-filter: blur(14px);
}

.ai-workspace-page .title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-workspace-page .topbar h1,
.ai-workspace-page .title-row h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ai-ink);
  font-size: 19px;
  line-height: 1.2;
  font-weight: 950;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-workspace-page .page-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-surface-soft);
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 850;
}

.ai-workspace-page .search {
  min-width: 0;
  height: 42px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-surface);
  color: var(--ai-weak);
}

.ai-workspace-page .search span {
  min-width: 0;
  overflow: hidden;
  color: var(--ai-muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-workspace-page .search kbd {
  flex: 0 0 auto;
  min-width: 42px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-surface-soft);
  color: var(--ai-weak);
  font-size: 11px;
  font-weight: 800;
}

.ai-workspace-page .user-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.ai-workspace-page .content-scroll,
.ai-workspace-page .main-scrollable {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  scroll-behavior: smooth;
}

.ai-workspace-page .content-scroll::-webkit-scrollbar,
.ai-workspace-page .main-scrollable::-webkit-scrollbar,
.ai-workspace-page .right-panel::-webkit-scrollbar,
.ai-workspace-page .nav-section::-webkit-scrollbar {
  width: 8px;
}

.ai-workspace-page .content-scroll::-webkit-scrollbar-thumb,
.ai-workspace-page .main-scrollable::-webkit-scrollbar-thumb,
.ai-workspace-page .right-panel::-webkit-scrollbar-thumb,
.ai-workspace-page .nav-section::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #dbe5d8;
}

.ai-workspace-page .page-content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.ai-workspace-page .page-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.ai-workspace-page .page-action-row h2 {
  margin: 0;
  color: var(--ai-ink);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 950;
  letter-spacing: 0;
}

.ai-workspace-page .page-action-row p {
  max-width: 680px;
  margin: 7px 0 0;
  color: var(--ai-muted);
  font-size: 14px;
  line-height: 1.75;
  font-weight: 650;
}

.ai-workspace-page .right-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  border-left: 1px solid var(--ai-line);
  background: rgba(255, 255, 253, .9);
}

.ai-workspace-page .panel,
.ai-workspace-page .side-card,
.ai-workspace-page .stat-card,
.ai-workspace-page .info-card,
.ai-workspace-page .mini-stat-card {
  min-width: 0;
  border: 1px solid var(--ai-line);
  background: var(--ai-surface);
  box-shadow: var(--ai-shadow-soft);
}

.ai-workspace-page .panel,
.ai-workspace-page .side-card {
  border-radius: var(--ai-radius-lg);
}

.ai-workspace-page .side-card {
  padding: 18px;
}

.ai-workspace-page .side-card + .side-card {
  margin-top: 14px;
}

.ai-workspace-page .side-card h3 {
  margin: 0 0 12px;
  color: var(--ai-ink);
  font-size: 15px;
  font-weight: 950;
  letter-spacing: 0;
}

.ai-workspace-page .stat-card {
  border-radius: var(--ai-radius-md);
}

.ai-workspace-page .primary-button,
.ai-workspace-page .green-button,
.ai-workspace-page .soft-button,
.ai-workspace-page .outline-button,
.ai-workspace-page .danger-button {
  min-width: 0;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border-radius: var(--ai-radius-md);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition: transform .18s var(--ai-ease), box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

:where(.icon) {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

:where(.account-card) {
  color: inherit;
  text-decoration: none;
}

:where(.primary-button, .green-button, .soft-button, .outline-button, .danger-button) {
  min-width: 0;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.ai-workspace-page .primary-button,
.ai-workspace-page .green-button,
:where(.primary-button, .green-button) {
  background: linear-gradient(180deg, #65e715, #55d80b);
  color: #061006;
  border: 1px solid transparent;
  box-shadow: 0 10px 24px rgba(79, 210, 8, .2);
}

.ai-workspace-page .primary-button:hover,
.ai-workspace-page .green-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(79, 210, 8, .25);
}

.ai-workspace-page .soft-button,
.ai-workspace-page .outline-button {
  border: 1px solid var(--ai-line);
  background: var(--ai-surface);
  color: var(--ai-ink);
}

.ai-workspace-page .soft-button:hover,
.ai-workspace-page .outline-button:hover {
  border-color: var(--ai-line-strong);
  background: var(--ai-surface-soft);
  transform: translateY(-1px);
}

.ai-workspace-page .danger-button {
  border: 1px solid #ffd7d2;
  background: var(--ai-red-soft);
  color: var(--ai-red);
}

.ai-workspace-page .filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-workspace-page .filter-tab {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-surface);
  color: var(--ai-muted);
  font-size: 13px;
  font-weight: 850;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.ai-workspace-page .filter-tab:hover,
.ai-workspace-page .filter-tab.active {
  border-color: #cceac4;
  background: var(--ai-green-soft);
  color: var(--ai-green-dark);
}

:where(.panel, .info-card, .stat-card, .mini-stat-card, .side-card) {
  min-width: 0;
}

.ai-workspace-page .modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 16, 12, .34);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.ai-workspace-page .modal-layer.open,
.ai-workspace-page .modal-layer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ai-workspace-page .modal-card {
  width: min(560px, 100%);
  max-height: min(760px, calc(100dvh - 40px));
  overflow-y: auto;
  border: 1px solid var(--ai-line);
  border-radius: 20px;
  background: var(--ai-surface);
  box-shadow: 0 24px 70px rgba(8, 17, 12, .2);
  transform: translateY(10px) scale(.98);
  transition: transform .22s var(--ai-ease);
}

.ai-workspace-page .modal-layer.open .modal-card,
.ai-workspace-page .modal-layer.is-open .modal-card {
  transform: translateY(0) scale(1);
}

.ai-workspace-page .toast,
.ai-workspace-page .workspace-toast,
:where(.toast, .workspace-toast) {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 80;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 999px;
  background: #111a15;
  color: #fff;
  box-shadow: 0 14px 32px rgba(8, 17, 12, .2);
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity .18s ease, transform .18s var(--ai-ease);
}

.ai-workspace-page .toast.show,
.ai-workspace-page .workspace-toast.show,
:where(.toast.show, .workspace-toast.show) {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1280px) {
  .ai-workspace-page .app .workspace-shell {
    grid-template-columns: var(--ai-sidebar-width) minmax(0, 1fr);
  }

  .ai-workspace-page .right-panel {
    display: none;
  }
}

@media (max-width: 960px) {
  .ai-workspace-page {
    overflow-x: hidden;
  }

  .ai-workspace-page .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .ai-workspace-page .app .workspace-shell {
    display: block;
    min-height: 100dvh;
    overflow: visible;
  }

  .ai-workspace-page .sidebar,
  .ai-workspace-page .side-bottom {
    display: none;
  }

  .ai-workspace-page .main {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  .ai-workspace-page .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 253, .9);
  }

  .ai-workspace-page .title-row {
    justify-content: space-between;
  }

  .ai-workspace-page .search {
    width: 100%;
  }

  .ai-workspace-page .user-tools {
    display: none;
  }

  .ai-workspace-page .content-scroll,
  .ai-workspace-page .main-scrollable {
    height: auto;
    overflow: visible;
    padding: 16px;
  }

  .ai-workspace-page .page-action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-workspace-page .page-action-row h2 {
    font-size: 22px;
  }

  .ai-workspace-page .primary-button,
  .ai-workspace-page .green-button,
  .ai-workspace-page .soft-button,
  .ai-workspace-page .outline-button,
  .ai-workspace-page .danger-button {
    white-space: normal;
  }

  :where(.workspace-shell, .main, .content-scroll, .main-scrollable) {
    max-width: 100vw;
    overflow-x: hidden;
  }
}

@media (max-width: 560px) {
  .ai-workspace-page .topbar h1,
  .ai-workspace-page .title-row h1 {
    font-size: 18px;
  }

  .ai-workspace-page .page-badge,
  .ai-workspace-page .search kbd {
    display: none;
  }

  .ai-workspace-page .search {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .ai-workspace-page .modal-layer {
    align-items: end;
    padding: 12px;
  }

  .ai-workspace-page .modal-card {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }
}

/*
  Workspace foundation v2.
  Baseline: the current AI assistant workspace. Keep cross-page shell and
  components here; page inline CSS should only own page-specific modules.
*/

:root {
  --ai-bg: #f8fafc;
  --ai-surface: #ffffff;
  --ai-surface-soft: #f8fafc;
  --ai-surface-muted: #f1f5f9;
  --ai-ink: #0f172a;
  --ai-ink-soft: #334155;
  --ai-muted: #64748b;
  --ai-weak: #94a3b8;
  --ai-line: #e2e8f0;
  --ai-line-strong: #cbd5e1;
  --ai-green: #10b981;
  --ai-green-strong: #059669;
  --ai-green-dark: #047857;
  --ai-green-soft: #ecfdf5;
  --ai-yellow-soft: #fffbeb;
  --ai-yellow: #b45309;
  --ai-blue-soft: #eff6ff;
  --ai-blue: #2563eb;
  --ai-red-soft: #fff1f2;
  --ai-red: #e11d48;
  --ai-shadow-soft: 0 1px 2px rgba(15, 23, 42, .04);
  --ai-shadow-card: 0 12px 28px rgba(15, 23, 42, .06);
  --ai-sidebar-width: 240px;
  --ai-right-panel-width: 288px;
  --ai-topbar-height: 64px;
  --ai-bottom-safe: 0px;
  --ai-radius-sm: 4px;
  --ai-radius-md: 6px;
  --ai-radius-lg: 8px;
  --ai-ease: cubic-bezier(.16, 1, .3, 1);

  --bg: var(--ai-bg);
  --panel: var(--ai-surface);
  --panel-soft: var(--ai-surface-soft);
  --panel-muted: var(--ai-surface-muted);
  --surface: var(--ai-surface);
  --surface-soft: var(--ai-surface-soft);
  --ink: var(--ai-ink);
  --ink-soft: var(--ai-ink-soft);
  --text: #172033;
  --muted: var(--ai-muted);
  --weak: var(--ai-weak);
  --line: var(--ai-line);
  --line-soft: var(--ai-line);
  --line-strong: var(--ai-line-strong);
  --green: var(--ai-green);
  --green-strong: var(--ai-green-strong);
  --green-dark: var(--ai-green-dark);
  --green-soft: var(--ai-green-soft);
  --blue: var(--ai-blue);
  --violet: #4f46e5;
  --red: var(--ai-red);
  --shadow: var(--ai-shadow-card);
  --shadow-soft: var(--ai-shadow-soft);
  --ease: var(--ai-ease);
  --sidebar-width: var(--ai-sidebar-width);
  --right-width: var(--ai-right-panel-width);
  --topbar-height: var(--ai-topbar-height);
  --bottom-safe: var(--ai-bottom-safe);
}

body.ai-workspace-page {
  background: var(--ai-bg);
  color: var(--ai-ink);
  letter-spacing: 0;
}

.ai-workspace-page .app {
  width: 100vw;
  max-width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #f1f5f9;
}

.ai-workspace-page .app .workspace-shell {
  grid-template-columns: var(--ai-sidebar-width) minmax(0, 1fr) var(--ai-right-panel-width);
  grid-template-rows: minmax(0, 1fr);
  background: var(--ai-bg);
}

.ai-workspace-page .sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--ai-line);
  background: var(--ai-surface);
}

.ai-workspace-page .side-top {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.ai-workspace-page .brand {
  min-height: 42px;
  margin: 0 0 12px;
  padding: 0;
  justify-content: space-between;
}

.ai-workspace-page .brand a {
  min-width: 0;
  display: inline-flex;
  align-items: center;
}

.ai-workspace-page .brand img {
  width: 142px;
  height: auto;
  display: block;
}

.ai-workspace-page .ghost-icon,
.ai-workspace-page .icon-button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--ai-radius-sm);
  color: var(--ai-weak);
  box-shadow: none;
}

.ai-workspace-page .ghost-icon:hover,
.ai-workspace-page .icon-button:hover {
  border-color: var(--ai-line);
  background: var(--ai-surface-soft);
  color: var(--ai-ink);
}

.ai-workspace-page .new-chat,
.ai-workspace-page .primary-button,
.ai-workspace-page .green-button {
  background: var(--ai-green);
  color: #ffffff;
  border: 1px solid transparent;
  box-shadow: none;
}

.ai-workspace-page .new-chat {
  height: 36px;
  gap: 8px;
  border-radius: var(--ai-radius-md);
  font-size: 14px;
  font-weight: 760;
}

.ai-workspace-page .new-chat:hover,
.ai-workspace-page .primary-button:hover,
.ai-workspace-page .green-button:hover {
  background: var(--ai-green-strong);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: none;
}

.ai-workspace-page .nav-section {
  gap: 2px;
  padding: 16px 8px;
}

.ai-workspace-page .nav-group-title {
  margin: 24px 16px 8px;
  color: var(--ai-weak);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.ai-workspace-page .nav-item {
  height: 36px;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 12px;
  padding: 0 16px;
  border-radius: var(--ai-radius-sm);
  color: #475569;
  font-size: 14px;
  font-weight: 560;
}

.ai-workspace-page .nav-item .icon {
  width: 16px;
  height: 16px;
  color: currentColor;
}

.ai-workspace-page .nav-item:hover {
  background: var(--ai-surface-soft);
  color: var(--ai-ink);
}

.ai-workspace-page .nav-item.active {
  background: var(--ai-surface-soft);
  color: var(--ai-ink);
  font-weight: 700;
}

.ai-workspace-page .nav-item.active::before {
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0;
  background: var(--ai-green);
}

.ai-workspace-page .side-bottom {
  position: static;
  width: auto;
  display: block;
  min-height: 130px;
  padding: 16px;
  border-top: 1px solid var(--ai-line);
  background: var(--ai-surface-soft);
}

.ai-workspace-page .account-card {
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
  color: var(--ai-ink);
}

.ai-workspace-page .account-card > .icon {
  display: none;
}

.ai-workspace-page .avatar {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius-sm);
  background:
    radial-gradient(circle at 42% 22%, rgba(255, 214, 132, .95) 0 8%, transparent 9%),
    radial-gradient(circle at 48% 88%, #0d1723 0 26%, transparent 27%),
    linear-gradient(135deg, #20d1c1, #0f172a 58%, #f59e0b);
}

.ai-workspace-page .account-name strong {
  color: var(--ai-ink);
  font-size: 12px;
  font-weight: 850;
}

.ai-workspace-page .account-name span,
.ai-workspace-page .member-badge {
  color: var(--ai-muted);
  font-size: 10px;
  font-weight: 560;
}

.ai-workspace-page .balance-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ai-muted);
  font-size: 10px;
  font-weight: 650;
}

.ai-workspace-page .balance-card strong {
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.ai-workspace-page .main {
  grid-template-rows: var(--ai-topbar-height) minmax(0, 1fr);
  background: var(--ai-surface);
}

.ai-workspace-page .topbar {
  min-height: var(--ai-topbar-height);
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 256px) minmax(140px, 1fr);
  gap: 16px;
  padding: 0 32px;
  border-bottom: 1px solid var(--ai-line);
  background: var(--ai-surface);
  backdrop-filter: none;
}

.ai-workspace-page .title-row {
  gap: 16px;
}

.ai-workspace-page .topbar h1,
.ai-workspace-page .title-row h1 {
  color: var(--ai-ink);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 850;
}

.ai-workspace-page .page-badge {
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--ai-surface-soft);
  color: var(--ai-muted);
  font-size: 11px;
  font-weight: 700;
}

.ai-workspace-page .search {
  width: 100%;
  height: 34px;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 10px;
  border-radius: var(--ai-radius-sm);
  background: var(--ai-surface-soft);
  color: var(--ai-weak);
}

.ai-workspace-page .search span {
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 500;
}

.ai-workspace-page .search kbd {
  min-width: 34px;
  height: 20px;
  background: var(--ai-surface);
  color: var(--ai-weak);
  font-size: 10px;
  font-weight: 700;
}

.ai-workspace-page .user-tools {
  gap: 16px;
}

.ai-workspace-page .content-scroll,
.ai-workspace-page .main-scrollable {
  padding: 32px;
  background: rgba(248, 250, 252, .55);
}

.ai-workspace-page .page-content,
.ai-workspace-page .workspace-content {
  width: min(1152px, 100%);
  max-width: 1152px;
  margin: 0 auto;
}

.ai-workspace-page .page-action-row {
  gap: 16px;
  margin-bottom: 24px;
}

.ai-workspace-page .page-action-row h2 {
  color: var(--ai-ink);
  font-size: 24px;
  line-height: 1.25;
  font-weight: 850;
}

.ai-workspace-page .page-action-row p {
  color: var(--ai-muted);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 500;
}

.ai-workspace-page .right-panel {
  padding: 0;
  border-left: 1px solid var(--ai-line);
  background: var(--ai-surface);
}

.ai-workspace-page .right-panel > .side-card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ai-workspace-page .panel,
.ai-workspace-page .side-card,
.ai-workspace-page .stat-card,
.ai-workspace-page .info-card,
.ai-workspace-page .mini-stat-card {
  border-color: var(--ai-line);
  background: var(--ai-surface);
  box-shadow: var(--ai-shadow-soft);
}

.ai-workspace-page .panel,
.ai-workspace-page .side-card {
  border-radius: var(--ai-radius-lg);
}

.ai-workspace-page .primary-button,
.ai-workspace-page .green-button,
.ai-workspace-page .soft-button,
.ai-workspace-page .outline-button,
.ai-workspace-page .danger-button {
  min-height: 36px;
  border-radius: var(--ai-radius-md);
  font-size: 13px;
  font-weight: 760;
}

.ai-workspace-page .soft-button,
.ai-workspace-page .outline-button {
  border: 1px solid var(--ai-line);
  background: var(--ai-surface);
  color: var(--ai-ink);
  box-shadow: none;
}

.ai-workspace-page .soft-button:hover,
.ai-workspace-page .outline-button:hover {
  border-color: var(--ai-line-strong);
  background: var(--ai-surface-soft);
  color: var(--ai-ink);
  box-shadow: none;
}

.ai-workspace-page .filter-tab {
  min-height: 32px;
  border-radius: 999px;
  background: var(--ai-surface);
  color: var(--ai-muted);
}

.ai-workspace-page .filter-tab:hover,
.ai-workspace-page .filter-tab.active {
  border-color: rgba(16, 185, 129, .32);
  background: var(--ai-green-soft);
  color: var(--ai-green-dark);
}

.ai-workspace-page .modal-card {
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .18);
}

.ai-workspace-page .toast,
.ai-workspace-page .workspace-toast,
:where(.toast, .workspace-toast) {
  top: 18px;
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
}

@media (max-width: 1280px) {
  .ai-workspace-page .app .workspace-shell {
    grid-template-columns: var(--ai-sidebar-width) minmax(0, 1fr);
  }

  .ai-workspace-page .right-panel {
    display: none;
  }
}

/*
  Desktop overflow guard.
  Keep the workspace shell locked to the viewport. Long pages scroll inside the
  content pane instead of stretching the whole app frame.
*/
@media (min-width: 961px) {
  html.ai-workspace-page,
  body.ai-workspace-page {
    width: 100%;
    height: 100%;
    max-width: 100%;
    overflow: hidden !important;
  }

  .ai-workspace-page .app {
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden !important;
  }

  .ai-workspace-page .app .workspace-shell {
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden !important;
    grid-template-columns: var(--ai-sidebar-width) minmax(0, 1fr) var(--ai-right-panel-width);
  }

  .ai-workspace-page .sidebar,
  .ai-workspace-page .main,
  .ai-workspace-page .right-panel {
    min-width: 0;
    min-height: 0;
    max-height: 100dvh;
  }

  .ai-workspace-page .sidebar,
  .ai-workspace-page .main {
    overflow: hidden !important;
  }

  .ai-workspace-page .content-scroll,
  .ai-workspace-page .main-scrollable {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .ai-workspace-page .content-scroll::-webkit-scrollbar,
  .ai-workspace-page .main-scrollable::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
  }

  .ai-workspace-page .page-content,
  .ai-workspace-page .workspace-content,
  .ai-workspace-page .create-content,
  .ai-workspace-page .optimize-content,
  .ai-workspace-page .knowledge-content,
  .ai-workspace-page .history-content,
  .ai-workspace-page .member-content,
  .ai-workspace-page .profile-content,
  .ai-workspace-page .projects-content,
  .ai-workspace-page .settings-content {
    width: min(100%, 1152px);
    max-width: 100%;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
  }

  .ai-workspace-page .right-panel {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-width: thin;
  }

  .ai-workspace-page .right-panel::-webkit-scrollbar {
    width: 8px;
  }

  .ai-workspace-page .right-panel::-webkit-scrollbar-track {
    background: transparent;
  }

  .ai-workspace-page .right-panel::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #cbd5e1;
    background-clip: content-box;
  }
}

@media (min-width: 961px) and (max-width: 1280px) {
  .ai-workspace-page .app .workspace-shell {
    grid-template-columns: var(--ai-sidebar-width) minmax(0, 1fr);
  }
}

/* Align the AI assistant page with the shared workspace shell. */
body.ai-workspace-page #stitchWorkspace .sidebar {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

body.ai-workspace-page #stitchWorkspace .side-top {
  height: auto;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f1f5f9;
}

body.ai-workspace-page #stitchWorkspace .brand {
  height: 42px;
  min-height: 42px;
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 0;
}

body.ai-workspace-page #stitchWorkspace .brand-logo {
  width: auto;
  height: auto;
  max-width: 142px;
}

body.ai-workspace-page #stitchWorkspace .brand-logo img {
  width: 142px;
  height: auto;
}

body.ai-workspace-page #stitchWorkspace .new-chat {
  height: 36px;
  border-radius: var(--ai-radius-md);
}

body.ai-workspace-page #stitchWorkspace .nav-section {
  padding: 16px 8px;
  gap: 2px;
}

body.ai-workspace-page #stitchWorkspace .nav-group-title,
body.ai-workspace-page #stitchWorkspace .new-chat-wrap {
  display: none;
}

body.ai-workspace-page #stitchWorkspace .side-bottom {
  min-height: 130px;
  padding: 16px;
}

body.ai-workspace-page #stitchWorkspace .account-card {
  grid-template-columns: 32px minmax(0, 1fr);
}

@media (max-width: 960px) {
  .ai-workspace-page .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .ai-workspace-page .app .workspace-shell {
    display: block;
    min-height: 100dvh;
    overflow: visible;
  }

  .ai-workspace-page .sidebar,
  .ai-workspace-page .side-bottom {
    display: none;
  }

  .ai-workspace-page .main {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  .ai-workspace-page .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
  }

  .ai-workspace-page .content-scroll,
  .ai-workspace-page .main-scrollable {
    height: auto;
    overflow: visible;
    padding: 16px;
  }

  .ai-workspace-page .page-action-row {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .ai-workspace-page .topbar h1,
  .ai-workspace-page .title-row h1 {
    font-size: 18px;
  }

  .ai-workspace-page .page-badge,
  .ai-workspace-page .search kbd {
    display: none;
  }
}
