/*
 * Octop-style theme overlay for Dify
 * Palette extracted from the octop dashboard design tokens.
 * Injected into every page by the Dify nginx container (see conf.d/default.conf).
 * Edit this file, then run: docker compose restart nginx  (no rebuild needed)
 * Bump ?v= below in default.conf to bust browser cache.
 */

/* ============ Shared: octop radius scale + dialog stability ============ */
:root,
:host {
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
}

/*
 * Dialog stability fix.
 * Symptom: on some Chrome builds / zoom levels / GPUs the dialog panel and its
 * dim layer are painted fully transparent, so page content shows through the
 * modal and the text looks like garbled overlapping text.
 * Cause: the compositor drops the panel's background paint while the panel runs
 * its scale/opacity entrance transition and owns a blurred layer.
 * Fix: no blur, no entrance transition on the panel, explicit opaque colours
 * (never inherited from a token that may be missing in that layer), and a
 * stable paint layer via translateZ(0).
 */
[role="dialog"] {
  background-color: #ffffff !important;
  background-image: none !important;
  opacity: 1 !important;
  scale: 1 !important;
  transition: none !important;
  animation: none !important;
  will-change: auto !important;
  isolation: isolate;
  transform: translateZ(0);
  border: 1px solid var(--color-components-panel-border, #e5e7eb);
  box-shadow: 0 24px 64px -16px rgba(15, 23, 42, .35), 0 4px 16px -4px rgba(15, 23, 42, .12);
}
[role="dialog"] * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html[data-theme="dark"] [role="dialog"] {
  background-color: #141414 !important;
  border-color: #262626;
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, .7), 0 4px 16px -4px rgba(0, 0, 0, .4);
}

/* the dim layer behind dialogs must never depend on a token resolving */
.bg-background-overlay {
  background-color: rgba(15, 23, 42, .45) !important;
}
html[data-theme="dark"] .bg-background-overlay {
  background-color: rgba(0, 0, 0, .62) !important;
}

/*
 * Same compositing defect on floating menus / tooltips: their surface relies on
 * bg-components-panel-bg-blur (95% white) plus backdrop-blur while fading in, so
 * the whole panel gets dropped and only the dark text is painted.
 * Give them an explicit opaque surface and drop the blur + entrance transition.
 */
[role="menu"],
[role="tooltip"],
[role="listbox"] {
  background-color: #ffffff !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  opacity: 1 !important;
  scale: 1 !important;
  transition: none !important;
}
html[data-theme="dark"] [role="menu"],
html[data-theme="dark"] [role="tooltip"],
html[data-theme="dark"] [role="listbox"] {
  background-color: #1c1c20 !important;
}

/* ============ Light theme (octop: #f5f6f8 page / #fff cards) ============ */
html[data-theme="light"] {
  /* surfaces */
  --color-background-body: #f5f6f8;
  --color-background-default: #ffffff;
  --color-background-default-hover: #f7f8fa;
  --color-background-default-subtle: #fcfcfd;
  --color-background-default-lighter: #ffffffcc;
  --color-background-section: #f5f6f8;
  --color-background-soft: #f7f8fa;

  --color-components-panel-bg: #ffffff;
  --color-components-panel-bg-alt: #f7f8fa;
  --color-components-panel-on-panel-item-bg: #ffffff;
  --color-components-panel-on-panel-item-bg-hover: #f7f8fa;
  --color-components-panel-on-panel-item-bg-alt: #f7f8fa;
  --color-components-input-bg: #ffffff;
  --color-components-input-bg-hover: #f7f8fa;

  /* borders — octop hairlines */
  --color-components-panel-border: #e5e7eb;
  --color-components-panel-border-subtle: #eef0f2;
  --color-components-input-border: #d1d5db;
  --color-components-input-border-hover: #9ca3af;
  --color-components-input-border-active: #3b82f6;

  /* text — octop neutral scale */
  --color-text-primary: #141414;
  --color-text-secondary: #3f4451;
  --color-text-tertiary: #6b7280;
  --color-text-quaternary: #9ca3af;

  /* accent — 科技蓝 #3b82f6 */
  --color-components-button-primary-bg: #3b82f6;
  --color-components-button-primary-bg-hover: #2563eb;
  --color-components-button-primary-bg-disabled: #3b82f640;
  --color-components-button-primary-border: #3b82f6;
  --color-components-button-primary-border-hover: #2563eb;
  --color-components-button-secondary-accent-text: #3b82f6;
  --color-components-button-secondary-accent-border: #93c5fd;
  --color-components-button-secondary-accent-bg: #eff6ff;
  --color-components-button-secondary-accent-bg-hover: #dbeafe;

  /* modal backdrop — solid dim instead of washed-out gray */
  --color-background-overlay-backdrop: #0f172a80;
}

/* ============ Dark theme (octop: #0e0e0e page / #141414 cards / #1e1e1e elevated) ============ */
html[data-theme="dark"] {
  /* surfaces */
  --color-background-body: #0e0e0e;
  --color-background-default: #141414;
  --color-background-default-hover: #1a1a1a;
  --color-background-default-subtle: #121212;
  --color-background-default-burn: #0a0a0a;
  --color-background-section: #141414;
  --color-background-soft: #1a1a1a;

  --color-components-panel-bg: #141414;
  --color-components-panel-bg-alt: #1a1a1a;
  --color-components-panel-on-panel-item-bg: #1a1a1a;
  --color-components-panel-on-panel-item-bg-hover: #202020;
  --color-components-panel-on-panel-item-bg-alt: #1a1a1a;
  --color-components-input-bg: #1a1a1a;
  --color-components-input-bg-hover: #202020;

  /* borders — octop dark hairlines */
  --color-components-panel-border: #262626;
  --color-components-panel-border-subtle: #1f1f1f;
  --color-components-input-border: #333333;
  --color-components-input-border-hover: #404040;
  --color-components-input-border-active: #3b82f6;

  /* text — octop dark neutral scale */
  --color-text-primary: #fafafa;
  --color-text-secondary: #d4d4d8;
  --color-text-tertiary: #a1a1aa;
  --color-text-quaternary: #71717a;

  /* accent — 科技蓝 #3b82f6 */
  --color-components-button-primary-bg: #3b82f6;
  --color-components-button-primary-bg-hover: #2563eb;
  --color-components-button-primary-bg-disabled: #3b82f640;
  --color-components-button-primary-border: #3b82f6;
  --color-components-button-primary-border-hover: #2563eb;
  --color-components-button-secondary-accent-text: #60a5fa;
  --color-components-button-secondary-accent-border: #1e3a5f;
  --color-components-button-secondary-accent-bg: #0f1c2e;
  --color-components-button-secondary-accent-bg-hover: #16283f;

  /* modal backdrop */
  --color-background-overlay-backdrop: #000000d9;
}

/* ====================================================================
 * Professional polish layer (v2)
 * ==================================================================== */

/* typography */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { letter-spacing: -0.01em; }
::selection { background: #3b82f633; }

/* smooth micro-interactions on all interactive elements */
button, a, [role="button"], input, select, textarea,
[role="switch"], [role="checkbox"], [role="tab"] {
  transition: background-color .15s ease, border-color .15s ease,
              color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
tr, [role="row"] { transition: background-color .12s ease; }

/* accent-blue focus rings */
:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }

/* slim octop-style scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #c7ccd4;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #9aa2ad; background-clip: content-box; }
* { scrollbar-width: thin; scrollbar-color: #c7ccd4 transparent; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2e2e33; background-clip: content-box; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3a3a40; background-clip: content-box; }
html[data-theme="dark"] * { scrollbar-color: #2e2e33 transparent; }

/* popover / dropdown menus */
[data-radix-popper-content-wrapper] > * {
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 2px 8px -2px rgba(15, 23, 42, .10);
}

/* whisper of depth on panels (light mode only, dialogs keep their own shadow) */
html[data-theme="light"] [class*="bg-components-panel-bg"]:not([role="dialog"]) {
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

/* ====================================================================
 * Left navigation rail — tech gradient
 * Deep navy rail with a blue/cyan glow and a faint engineering grid.
 * All nav tokens are re-scoped inside the rail so labels stay readable.
 * ==================================================================== */
aside[class*="w-60"][class*="bg-background-body"] {
  background-color: #0a1424;
  background-image:
    linear-gradient(rgba(148, 197, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 197, 255, .045) 1px, transparent 1px),
    radial-gradient(120% 55% at 0% 0%, rgba(56, 132, 255, .30) 0%, rgba(56, 132, 255, 0) 62%),
    radial-gradient(90% 45% at 100% 100%, rgba(0, 214, 255, .14) 0%, rgba(0, 214, 255, 0) 68%),
    linear-gradient(180deg, #0b1730 0%, #0d1f3a 48%, #08111f 100%);
  background-size: 26px 26px, 26px 26px, auto, auto, auto;
  border-right: 1px solid rgba(96, 165, 250, .16);
  box-shadow: inset -1px 0 0 rgba(96, 165, 250, .08), 8px 0 32px -24px rgba(2, 12, 30, .9);

  /* inner elements that inherit colour instead of using a token */
  color: #ecf3fd;

  /* surfaces + hairlines inside the rail */
  --color-background-body: #0b1730;
  --color-background-body-transparent: rgba(11, 23, 48, 0);
  --color-background-section: rgba(255, 255, 255, .05);
  --color-background-section-burn: rgba(255, 255, 255, .02);
  --color-components-card-bg: rgba(255, 255, 255, .06);
  --color-components-card-border: rgba(148, 197, 255, .16);
  --color-components-panel-border: rgba(148, 197, 255, .16);
  --color-components-input-bg: rgba(255, 255, 255, .08);
  --color-components-input-bg-hover: rgba(255, 255, 255, .12);
  --color-components-input-border: rgba(148, 197, 255, .22);
  --color-divider-subtle: rgba(148, 197, 255, .16);
  --color-state-base-hover: rgba(255, 255, 255, .09);
  --color-state-base-hover-alt: rgba(255, 255, 255, .14);
  --color-state-base-active: rgba(59, 130, 246, .22);

  /* text */
  --color-text-primary: #ecf3fd;
  --color-text-secondary: #c9d8ea;
  --color-text-tertiary: #94a9c3;
  --color-text-quaternary: #7489a5;

  /* nav items */
  --color-components-main-nav-text: #c3d3e6;
  --color-components-main-nav-text-active: #ffffff;
  --color-components-main-nav-nav-button-text: #b3c6dc;
  --color-components-main-nav-nav-button-text-active: #ffffff;
  --color-components-main-nav-nav-button-bg-hover: rgba(120, 170, 255, .14);
  --color-components-main-nav-nav-button-bg-active: rgba(59, 130, 246, .22);

  /* active pill: blue glass that reads on a dark rail */
  --color-saas-dify-blue-inverted: #ffffff;
  --color-saas-dify-blue-inverted-dimmed: rgba(255, 255, 255, .88);
  --color-saas-dify-blue-accessible: #8ec2ff;
  --color-saas-dify-blue-static-hover: #a9d2ff;
  --color-components-main-nav-glass-surface-first: rgba(59, 130, 246, .22);
  --color-components-main-nav-glass-surface-middle-1: rgba(59, 130, 246, .34);
  --color-components-main-nav-glass-surface-middle-2: rgba(56, 189, 248, .24);
  --color-components-main-nav-glass-surface-end: rgba(59, 130, 246, .20);
  --color-components-main-nav-glass-edge-reflection-first: rgba(96, 165, 250, 0);
  --color-components-main-nav-glass-edge-reflection-middle: rgba(96, 165, 250, .75);
  --color-components-main-nav-glass-edge-reflection-end: rgba(96, 165, 250, 0);
  --color-components-main-nav-glass-edge-highlight-first: rgba(255, 255, 255, .55);
  --color-components-main-nav-glass-edge-highlight-middle: rgba(255, 255, 255, 0);
  --color-components-main-nav-glass-edge-highlight-end: rgba(255, 255, 255, .18);
  --color-components-main-nav-glass-inner-glow: rgba(96, 165, 250, .30);
  --color-components-main-nav-glass-shadow-reflection: rgba(37, 99, 235, .28);
  --color-components-main-nav-glass-shadow-reflection-glow: rgba(56, 189, 248, .10);
  --color-components-main-nav-glass-text-glow: rgba(147, 197, 253, .55);
}

html[data-theme="dark"] aside[class*="w-60"][class*="bg-background-body"] {
  background-color: #070d18;
  background-image:
    linear-gradient(rgba(148, 197, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 197, 255, .035) 1px, transparent 1px),
    radial-gradient(120% 55% at 0% 0%, rgba(37, 99, 235, .34) 0%, rgba(37, 99, 235, 0) 62%),
    radial-gradient(90% 45% at 100% 100%, rgba(0, 214, 255, .10) 0%, rgba(0, 214, 255, 0) 68%),
    linear-gradient(180deg, #0a1424 0%, #0c1930 50%, #070d18 100%);
  background-size: 26px 26px, 26px 26px, auto, auto, auto;
}

/* Brand logo: keep the real colours (red) in dark mode instead of the default white silhouette */
html[data-theme="dark"] img[src$="/logo/logo.svg"],
html[data-theme="dark"] img[src$="/logo/logo-site.png"] {
  filter: none !important;
}

/* Console left nav: the brand logo is the primary identity, show it larger than the default 48x22 */
aside a[aria-label="Dify"] {
  height: auto !important;
  min-height: 4rem;
  overflow: visible !important;
}

aside a[aria-label="Dify"] > img[src$="/logo/logo.svg"] {
  height: 4rem !important;
  width: auto !important;
  max-width: 22rem;
}

/* Auth pages (signin / forgot-password / init): enlarge the brand logo 1x.
 * Markup: <header class="flex ..."><img src="/logo/logo.svg" class="... h-7 w-16" alt="Dify"/>
 * The wrapping header has no fixed height, so growing the img is safe. */
html.octop-auth-page header > img[src="/logo/logo.svg"] {
  height: 3.5rem !important;
  width: auto !important;
  max-width: 16rem;
}

/* ===== Home hero banner (console home / 工作室) ===== */
header.octop-hero {
  position: relative !important;
  /* the home layout is a scrollable flex column: never let the banner be shrunk */
  flex: 0 0 auto !important;
  width: auto !important;
  min-height: 340px;
  height: auto;
  margin: 22px 32px 6px !important;
  padding: 26px 30px 22px !important;
  gap: 0 !important;
  border-radius: 16px;
  overflow: hidden;
  background-color: #16255e;
  /* reference-site recipe: pure gradient base + right 34% photo column with
     cover/top anchor (the dark lower band of the photo is cropped away) and a
     left mask fade -- no baked artwork, no tint layers */
  background-image: linear-gradient(105deg, #16255e 0%, #1d3a8f 48%, #2b57c9 100%);
  background-repeat: no-repeat;
  background-position: left center;
  background-size: auto;
  box-shadow: 0 14px 34px rgba(10, 28, 78, .22);
}

/* founder photo column: identical to the reference site's heroPhoto */
header.octop-hero::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 34%;
  background: url('/octop-assets/hero.jpg') center 30% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 26%);
  mask-image: linear-gradient(to right, transparent 0%, #000 26%);
  pointer-events: none;
}

/* vertical name caption over the photo column (reference-site style) */
.octop-hero-caption {
  position: absolute;
  z-index: 1;
  top: 42px;
  right: 32px;
  writing-mode: vertical-rl;
  text-orientation: upright;
  pointer-events: none;
}

.octop-hero-caption-name {
  display: block;
  font-size: 21px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 16px;
  color: #fff;
  /* gap toward the role column (name sits left of role in vertical-rl flow) */
  margin-right: 18px;
}

.octop-hero-caption-role {
  display: block;
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 8px;
  color: rgba(255, 255, 255, .88);
  text-shadow: 0 1px 6px rgba(10, 20, 60, .45);
}

header.octop-hero > h1,
header.octop-hero > p {
  display: none !important;
}

.octop-hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  max-width: calc(100% - 360px);
  min-height: 0;
  color: #fff;
}

.octop-hero-kicker {
  font-size: 11.5px;
  line-height: 15px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, .66);
  margin-bottom: 8px;
}

.octop-hero-lead {
  font-size: 22px;
  line-height: 33px;
  font-weight: 600;
  margin-bottom: 2px;
  color: rgba(255, 255, 255, .92);
}

.octop-hero-title {
  font-size: 30px;
  line-height: 46px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  margin-bottom: 8px;
}

.octop-hero-desc {
  max-width: 560px;
  font-size: 13px;
  line-height: 22px;
  color: rgba(255, 255, 255, .72);
  margin: 0 0 14px;
}

.octop-hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.octop-hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 37px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, opacity .15s;
}

.octop-hero-btn svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.octop-hero-btn.is-primary {
  background: #fff;
  color: #1d3a8f;
  font-weight: 600;
}

.octop-hero-btn.is-primary:hover {
  background: rgba(255, 255, 255, .88);
}

.octop-hero-btn.is-ghost {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .55);
  background: transparent;
}

.octop-hero-btn.is-ghost:hover {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .72);
}

.octop-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.octop-hero-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: transparent;
  font-size: 12px;
  line-height: 1;
  color: rgba(255, 255, 255, .85);
  text-decoration: none;
  transition: background-color .15s, border-color .15s;
}

.octop-hero-chip:hover {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .45);
}

@media (max-width: 1180px) {
  header.octop-hero {
    min-height: 0;
    padding-bottom: 26px !important;
  }

  header.octop-hero::before {
    display: none;
  }

  .octop-hero-caption {
    display: none;
  }

  .octop-hero-copy {
    max-width: 100%;
  }

  .octop-hero-desc {
    max-width: 100%;
  }
}

/* ====================================================================
 * Mobile (<768px) — the deployed console build has no responsive nav:
 * the desktop rail would permanently squeeze the content on phones.
 * octop-theme.js injects a slim top bar; the rail becomes a slide-in
 * drawer while <html class="octop-nav-open"> is set.
 * ==================================================================== */
#octop-mobile-bar {
  display: none;
}

#octop-nav-backdrop {
  display: none;
}

#octop-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #ecf3fd;
  cursor: pointer;
}

#octop-nav-toggle:hover {
  background: rgba(255, 255, 255, .10);
}

#octop-nav-toggle svg {
  width: 20px;
  height: 20px;
}

.octop-mobile-brand {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}

.octop-mobile-brand img {
  height: 1.75rem !important;
  width: auto !important;
  max-width: 9rem;
}

@media (max-width: 767.98px) {
  /* shell that holds the rail becomes a column so the bar sits on top */
  .octop-nav-shell {
    flex-direction: column !important;
  }

  /* slim brand bar pinned to the top of the console layout */
  #octop-mobile-bar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    height: 48px;
    padding: 0 10px;
    background: #0a1424;
    border-bottom: 1px solid rgba(96, 165, 250, .16);
    z-index: 45;
  }

  /* rail off by default, back as a drawer while open */
  aside[class*="w-60"][class*="bg-background-body"] {
    display: none !important;
  }

  html.octop-nav-open aside[class*="w-60"][class*="bg-background-body"] {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 48px;
    bottom: 0;
    left: 0;
    z-index: 40 !important;
    width: min(80vw, 300px) !important;
    min-width: 0 !important;
    box-shadow: 18px 0 44px rgba(4, 12, 30, .45);
  }

  html.octop-nav-open #octop-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(6, 14, 32, .55);
  }

  /* hero: tighter phone metrics */
  header.octop-hero {
    margin: 12px 14px 4px !important;
    padding: 18px 18px 16px !important;
    min-height: 0;
  }

  .octop-hero-title {
    font-size: 24px !important;
  }

  .octop-hero-lead {
    font-size: 18px !important;
  }
}

/* ====================================================================
 * WebApp chat pages (/chat/{token} etc.)
 * Sidebar column class .w-59 is unique to the share layout (grep-verified
 * against deployed chunks); collapsed state adds w-0 which we must NOT
 * override, so no width is forced here — colours only.
 * ==================================================================== */
/* Standalone webapp pages only — inside the console the webapp renders in
 * an iframe (html.octop-embedded) right next to the navy console rail,
 * where a second navy column looks broken. */
html:not(.octop-embedded) .w-59,
html:not(.octop-embedded) .relative.grow > div[class*="w-[256px]"] {
  background-color: #0a1424;
  background-image:
    linear-gradient(rgba(148, 197, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 197, 255, .045) 1px, transparent 1px),
    radial-gradient(120% 55% at 0% 0%, rgba(56, 132, 255, .30) 0%, rgba(56, 132, 255, 0) 62%),
    radial-gradient(90% 45% at 100% 100%, rgba(0, 214, 255, .14) 0%, rgba(0, 214, 255, 0) 68%),
    linear-gradient(180deg, #0b1730 0%, #0d1f3a 48%, #08111f 100%);
  background-size: 26px 26px, 26px 26px, auto, auto, auto;
  border-right: 1px solid rgba(96, 165, 250, .16);
  color: #ecf3fd;
  --color-text-primary: #ecf3fd;
  --color-text-secondary: #c6d6f0;
  --color-text-tertiary: #9db0d4;
  --color-text-quaternary: #7183a8;
  --color-state-base-hover: rgba(255, 255, 255, .08);
  --color-state-active-bg: rgba(255, 255, 255, .12);
  --color-components-button-secondary-bg: rgba(255, 255, 255, .10);
  --color-components-button-secondary-bg-hover: rgba(255, 255, 255, .16);
  --color-components-button-secondary-border: rgba(150, 190, 255, .25);
  --color-components-panel-border: rgba(255, 255, 255, .10);
  --color-divider-subtle: rgba(255, 255, 255, .08);
  --color-divider-broken: rgba(255, 255, 255, .10);
}

/* hover flyout (desktop, sidebar collapsed) has no sibling rail to its left;
 * keep a left hairline instead */
html:not(.octop-embedded) .relative.grow > div[class*="w-[256px]"] {
  border-left: 1px solid rgba(96, 165, 250, .16);
}

/* floating input pill on the main area: a whisper of depth */
.relative.grow .pointer-events-auto.relative.rounded-xl {
  box-shadow: 0 18px 48px -20px rgba(15, 23, 42, .25), 0 2px 8px -2px rgba(15, 23, 42, .10);
}

/* ---- Mobile inset drawer (conversation list / chat settings).
 * Deployed class w-[calc(100vw-40px)] covers ~94vw of a phone screen and
 * looks broken (see user screenshot). Cap it to a real drawer width.
 * The element only renders when the app switches to its mobile layout,
 * so no media query is needed. Inline !important beats the Tailwind rule. */
[class*="w-[calc(100vw-40px)]"] {
  width: min(calc(100vw - 96px), 300px) !important;
}

/* drawer colours: standalone webapp pages only (see .w-59 note above) */
html:not(.octop-embedded) [class*="w-[calc(100vw-40px)]"] {
  background-color: #0a1424 !important;
  background-image:
    linear-gradient(rgba(148, 197, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 197, 255, .045) 1px, transparent 1px),
    radial-gradient(120% 55% at 0% 0%, rgba(56, 132, 255, .30) 0%, rgba(56, 132, 255, 0) 62%),
    linear-gradient(180deg, #0b1730 0%, #0d1f3a 48%, #08111f 100%) !important;
  border-color: rgba(96, 165, 250, .16) !important;
  color: #ecf3fd !important;
  --color-text-primary: #ecf3fd;
  --color-text-secondary: #c6d6f0;
  --color-text-tertiary: #9db0d4;
  --color-text-quaternary: #7183a8;
  --color-state-base-hover: rgba(255, 255, 255, .08);
  --color-state-active-bg: rgba(255, 255, 255, .12);
  --color-components-button-secondary-bg: rgba(255, 255, 255, .10);
  --color-components-button-secondary-bg-hover: rgba(255, 255, 255, .16);
  --color-components-button-secondary-border: rgba(150, 190, 255, .25);
  --color-components-panel-border: rgba(255, 255, 255, .10);
  --color-divider-subtle: rgba(255, 255, 255, .08);
  --color-divider-broken: rgba(255, 255, 255, .10);
}

/* ============ 权限管理面板 ============ */
.octop-perm-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px;
  padding: 8px 12px;
  border: 1px solid rgba(150, 190, 255, .25);
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: inherit;
  font-size: 13px;
  cursor: pointer;
}
.octop-perm-entry:hover {
  background: rgba(255, 255, 255, .16);
}
#octop-perm-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 12, 24, .55);
}
.octop-perm-card {
  width: min(720px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(2, 8, 20, .35);
  font-size: 14px;
  color: #1d2939;
}
.octop-perm-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: #101828;
}
.octop-perm-desc {
  margin: 0 0 14px;
  line-height: 1.6;
  color: #475467;
}
.octop-perm-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e4e7ec;
}
.octop-perm-tab {
  border: 0;
  background: none;
  padding: 8px 14px;
  font-size: 14px;
  color: #667085;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.octop-perm-tab.is-active {
  color: #155eef;
  border-bottom-color: #155eef;
  font-weight: 600;
}
.octop-perm-body {
  flex: 1;
  overflow: auto;
  min-height: 120px;
}
.octop-perm-pane {
  display: none;
}
.octop-perm-pane.is-active {
  display: block;
}
.octop-perm-row {
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: #f9fafb;
}
.octop-perm-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.octop-perm-restrict {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #b42318;
  cursor: pointer;
}
.octop-perm-target {
  color: #101828;
  font-weight: 500;
  word-break: break-all;
}
.octop-perm-row-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}
.octop-perm-row-body[hidden] {
  display: none;
}
.octop-perm-member {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  font-size: 13px;
  color: #344054;
  cursor: pointer;
}
.octop-perm-empty {
  color: #98a2b3;
  padding: 24px 0;
  text-align: center;
}
.octop-perm-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.octop-perm-cancel {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 8px 22px;
  background: #fff;
  color: #344054;
  font-size: 14px;
  cursor: pointer;
}
.octop-perm-save {
  border: 0;
  border-radius: 8px;
  padding: 8px 22px;
  background: #155eef;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.octop-perm-save:hover {
  background: #1249c7;
}
.octop-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 100000;
  padding: 10px 22px;
  border-radius: 10px;
  background: #101828;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(2, 8, 20, .3);
}
