/*
 * Workspace shell (2026-10-22, Pin's layout): the sidebar carries the work on top
 * and settings at the bottom; there is no desktop top bar.
 *   top    — brand, the company you are in, the work views
 *   bottom — the local-environment green light, then you, a gear and sign-out
 * Everything else (environment, models & tools, team, account, language,
 * refresh) opens from the gear — or the 设置 tab on phones, as a sheet.
 * The market keeps its title, scene and category pinned while browsing.
 */

.app-shell {
  --shell-night-text: #f2ecdd;
  --shell-night-2: #cfc6b2;
  --shell-night-3: #8a8171;
  --shell-night-line: rgba(238, 228, 200, 0.09);
  --shell-night-fill: rgba(255, 248, 235, 0.045);
  --view-gutter: clamp(28px, 4vw, 72px);
}

.app-shell .topbar { display: none; }

/* ---- Sidebar: who and where, then the work ----------------------------- */

.app-shell .sidebar { display: flex; flex-direction: column; overflow-y: auto; padding: 24px 14px 14px; }
.app-shell .sidebar .brand-lockup { margin: 0 6px 18px; }

.app-shell .sidebar .platform-context {
  margin: 0 0 22px; padding: 10px 12px;
  border: 1px solid var(--shell-night-line); border-radius: 14px; background: var(--shell-night-fill);
}
.app-shell .sidebar .platform-context span { margin-bottom: 3px; color: var(--shell-night-3); font: 600 9px/1.3 var(--cortex-mono); letter-spacing: 0.14em; }
.app-shell .sidebar .platform-context strong { color: var(--shell-night-text); font-size: 13.5px; }

.app-shell .sidebar .workspace-label { margin: 0; padding: 0 12px 9px; font-size: 9.5px; letter-spacing: 0.26em; }
.app-shell .main-nav { margin: 0; }
.app-shell .main-nav .settings-tab { display: none; }

/* ---- Sidebar bottom: the green light, then you ------------------------- */

.app-shell .sidebar .environment-line {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-width: 0; height: auto; min-height: 40px; margin: auto 0 0; padding: 8px 12px;
  border: 1px solid var(--shell-night-line); border-radius: 12px; background: var(--shell-night-fill);
  box-shadow: none; color: var(--shell-night-text); text-align: left;
}
.app-shell .sidebar .environment-line:hover { border-color: rgba(255, 208, 112, 0.22); background: rgba(255, 248, 235, 0.07); }
.app-shell .sidebar .environment-line > span:not(.status-dot) { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.app-shell .sidebar .environment-line small { color: var(--shell-night-3); font: 600 9px/1 var(--cortex-mono); letter-spacing: 0.14em; white-space: nowrap; }
.app-shell .sidebar .environment-line b { overflow: hidden; color: var(--shell-night-text); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .sidebar .environment-line i { display: none; }
/* A newer connection assistant is out: say so where everyone looks (bridge-update.js). */
.app-shell .sidebar .environment-line.has-update { border-color: rgba(255, 208, 112, 0.5); }
/* Room for the badge: the dot and the status still say what this entry is. */
.app-shell .sidebar .environment-line.has-update small { display: none; }
.app-shell .sidebar .environment-line .environment-update { flex: none; margin-left: auto; padding: 3px 8px; border-radius: 999px; background: #ffd070; color: #1b1916; font: 700 11px/1.2 var(--cortex-sans, inherit); font-style: normal; white-space: nowrap; }
.app-shell .sidebar .environment-line .environment-update.hidden { display: none; }

.app-shell .sidebar-account {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px;
  margin-top: 12px; padding: 12px 2px 0 6px; border-top: 1px solid var(--shell-night-line);
}
.app-shell .sidebar .environment-line.hidden + .sidebar-account { margin-top: auto; }
.app-shell .sidebar .sidebar-account .user-card {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px;
  margin: 0; padding: 0; border: 0; background: none; box-shadow: none;
}
.app-shell .sidebar-account .user-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .sidebar-account .settings-button,
.app-shell .sidebar-account .logout-button {
  display: grid; place-items: center; width: 36px; height: 36px; min-height: 0; margin: 0; padding: 0;
  border: 0; border-radius: 10px; background: transparent; box-shadow: none; color: var(--shell-night-2); cursor: pointer;
}
.app-shell .sidebar-account .settings-button:hover,
.app-shell .sidebar-account .logout-button:hover { background: rgba(255, 248, 235, 0.07); color: var(--shell-night-text); }
.app-shell .sidebar-account .settings-button[aria-expanded="true"] { background: rgba(255, 208, 112, 0.12); color: #ffd070; }
.app-shell .sidebar-account .settings-icon,
.app-shell .sidebar-account .logout-icon { width: 18px; height: 18px; transition: transform 0.3s ease; }
.app-shell .sidebar-account .settings-button[aria-expanded="true"] .settings-icon { transform: rotate(45deg); }
.app-shell .sidebar-account .logout-button span {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- The settings menu (a popover above you on desktop) ---------------- */

.app-shell .settings-menu {
  position: fixed; left: 14px; bottom: 76px; z-index: 60;
  display: grid; gap: 2px; width: 264px; max-height: calc(100vh - 120px); overflow-y: auto; padding: 8px;
  border: 1px solid rgba(238, 228, 200, 0.12); border-radius: 16px;
  background: linear-gradient(180deg, #1d1914, #14110d); color: var(--shell-night-text);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.25);
  animation: settings-menu-in 0.18s ease;
}
@keyframes settings-menu-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.app-shell .settings-scrim { display: none; }
.app-shell .settings-menu-title { display: block; padding: 6px 10px 8px; color: var(--shell-night-3); font: 600 9.5px/1 var(--cortex-mono); letter-spacing: 0.26em; }

.app-shell #settingsMenu .settings-row {
  display: flex; align-items: center; gap: 11px; width: 100%; min-width: 0; min-height: 40px; margin: 0; padding: 8px 10px;
  border: 0; border-radius: 10px; background: transparent; box-shadow: none;
  color: var(--shell-night-2); font: 600 13.5px/1.2 var(--cortex-font); text-align: left; white-space: nowrap; cursor: pointer;
}
.app-shell #settingsMenu .settings-row:hover,
.app-shell #settingsMenu .settings-row:focus-visible { background: rgba(255, 248, 235, 0.05); color: var(--shell-night-text); }
.app-shell #settingsMenu .settings-row.active { background: rgba(255, 208, 112, 0.1); color: #ffd070; }
.app-shell #settingsMenu .settings-row::before {
  content: ""; flex: none; width: 18px; height: 18px; background: currentColor; opacity: 0.9;
  -webkit-mask: var(--row-icon) center / contain no-repeat; mask: var(--row-icon) center / contain no-repeat;
}
.app-shell #settingsMenu .settings-row > span { flex: 0 0 auto; }
.app-shell #settingsMenu .settings-row[data-meta]::after {
  content: attr(data-meta); flex: 0 1 auto; min-width: 0; margin-left: auto; overflow: hidden;
  color: var(--shell-night-3); font-size: 11px; font-weight: 500; text-overflow: ellipsis;
}
.app-shell #settingsMenu .settings-row em {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; margin-left: auto; overflow: hidden;
  color: var(--shell-night-3); font-size: 11px; font-style: normal; font-weight: 500;
}
.app-shell #settingsMenu .settings-row em > span { overflow: hidden; text-overflow: ellipsis; }
.app-shell #settingsMenu .settings-row em > i { flex: none; }
.app-shell #settingsMenu .settings-dot { width: 6px; height: 6px; border-radius: 50%; background: #a1a1a6; }
.app-shell #settingsMenu .settings-dot.online { background: #34c759; }
.app-shell #settingsMenu .settings-update { margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: #ffd070; color: #1b1916; font-size: 11px; font-weight: 700; }
.app-shell #settingsMenu .settings-update.hidden { display: none; }
.app-shell #settingsMenu .settings-badge { padding: 3px 7px; border-radius: 999px; background: rgba(255, 176, 40, 0.14); color: #ffd070; font: 600 10px/1 var(--cortex-mono); letter-spacing: 0.06em; }

.app-shell #settingsMenu .settings-environment { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='11' rx='1.5'/%3E%3Cpath d='M2.5 19h19'/%3E%3C/svg%3E"); }
.app-shell #settingsMenu .settings-profile { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='2'/%3E%3Cpath d='M8 8h8M8 12h8M8 16h5'/%3E%3C/svg%3E"); }
.app-shell #settingsMenu .tool-settings-button { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='7' y='7' width='10' height='10' rx='2'/%3E%3Cpath d='M12 3v3M12 18v3M3 12h3M18 12h3M10 10h4v4h-4z'/%3E%3C/svg%3E"); }
.app-shell #settingsMenu .team-button { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M3.5 19c.7-3 2.9-4.6 5.5-4.6s4.8 1.6 5.5 4.6'/%3E%3Ccircle cx='17' cy='9' r='2.4'/%3E%3Cpath d='M15.6 14.6c2.3.1 4.1 1.5 4.7 4.4'/%3E%3C/svg%3E"); }
.app-shell #settingsMenu .settings-wallet { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='6' width='18' height='13' rx='2'/%3E%3Cpath d='M3 10h18M16 14.5h2'/%3E%3C/svg%3E"); }
.app-shell #settingsMenu .settings-language { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M3.5 12h17M12 3.5c2.4 2.4 3.4 5.3 3.4 8.5s-1 6.1-3.4 8.5c-2.4-2.4-3.4-5.3-3.4-8.5s1-6.1 3.4-8.5z'/%3E%3C/svg%3E"); cursor: default; }
.app-shell #settingsMenu .settings-refresh { --row-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7'/%3E%3Cpath d='M20 5v6h-6'/%3E%3C/svg%3E"); margin-top: 4px; border-top: 1px solid var(--shell-night-line); border-radius: 0 0 10px 10px; padding-top: 12px; color: var(--shell-night-3); }
.app-shell #settingsMenu .settings-refresh:disabled { opacity: 0.55; cursor: progress; }

.app-shell #settingsMenu .settings-language .app-language {
  width: 68px; height: 28px; margin-left: auto; padding: 3px; border: 0;
  background: rgba(255, 248, 235, 0.06); box-shadow: none;
}
.app-shell #settingsMenu .settings-language .app-language a { height: 22px; min-height: 0; color: var(--shell-night-2); font-size: 10px; }
.app-shell #settingsMenu .settings-language .app-language a.active { background: linear-gradient(100deg, #ffb028, #ffd070); color: #1d1403; box-shadow: none; }

.app-shell #settingsMenu .organization-switch {
  display: grid; gap: 6px; min-height: 0; margin: 0 0 6px; padding: 8px 10px 10px;
  border: 0; border-bottom: 1px solid var(--shell-night-line); border-radius: 0; background: transparent;
  color: var(--shell-night-3); font: 600 9.5px/1 var(--cortex-mono); letter-spacing: 0.14em;
}
.app-shell #settingsMenu .organization-switch.hidden { display: none; }
.app-shell #settingsMenu .organization-switch select {
  min-width: 0; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--shell-night-line); border-radius: 9px;
  background: rgba(255, 248, 235, 0.06); color: var(--shell-night-text); font: 600 13px/1.2 var(--cortex-font); letter-spacing: 0;
}

/* Older phone rules gave the team button and company switcher an order; the menu keeps its own. */
.app-shell #settingsMenu > * { order: 0; max-width: none; }

/* Desktop shows you in the sidebar, so the menu skips you. The company profile lives in the menu on every
   page; the company card itself shows only at the top of 我的 AI 员工. */
.app-shell #settingsMenu .settings-account { display: none; }

/* The test-credit notice belongs to the account page now. */
.app-shell:not([data-view="wallet"]) #companyTestNotice { display: none; }

/* ---- Market: title as high as it goes; scene and category pinned -------- */

/* Only the filter bar pins, and pinning changes paint only (background and
   shadow), never its size. A pinned bar that shrank would move the cards up,
   browser scroll anchoring would pull the page back, the bar would unpin and
   grow again — the jitter Pin saw at the threshold (2026-10-22). */
.app-shell #marketplace.view { padding-top: 26px; }
.app-shell #marketplace .market-heading { margin-bottom: 6px; }
.app-shell .market-sticky-sentinel { height: 1px; margin-bottom: -1px; }
.app-shell #marketSticky {
  position: sticky; top: 0; z-index: 30;
  margin: 0 calc(-1 * var(--view-gutter)) 22px; padding: 12px var(--view-gutter);
  border-bottom: 1px solid var(--cortex-line);
  background-color: transparent;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, border-radius 0.2s ease, border-color 0.2s ease;
}
.app-shell #marketplace #marketSticky .market-browse-controls { margin: 0; padding: 0; border-bottom: 0; }
/* Pinned: frosted glass with softly rounded lower corners (2026-10-22, Pin). The cards blur through a warm,
   mostly opaque tint so the text on the bar stays easy to read. */
.app-shell #marketSticky.is-stuck {
  border-bottom-color: rgba(154, 106, 18, 0.12);
  border-radius: 0 0 22px 22px;
  background-color: rgba(247, 243, 234, 0.66);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  backdrop-filter: blur(24px) saturate(1.7);
  box-shadow: 0 16px 34px rgba(60, 40, 10, 0.09), inset 0 -1px 0 rgba(255, 255, 255, 0.55);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-shell #marketSticky.is-stuck { background-color: var(--cortex-bg); }
}
/* The view's fade-in (styles.css viewIn) used fill-mode both, which kept an identity transform on the
   market after it ended, and Chrome then left the pinned bar unblurred: headings showed through crisply.
   Fade in the same way, then let go. */
.app-shell #marketplace.view { animation-fill-mode: backwards; }

/* ---- Phones and tablets: bottom tabs, a slim header, settings as a sheet - */

@media (max-width: 820px) {
  .app-shell { --view-gutter: 18px; }
  .app-shell .sidebar { overflow: visible; padding: 6px; }
  .app-shell .sidebar > :not(.main-nav) { display: none !important; }
  .app-shell .main-nav { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; }
  .app-shell .main-nav .settings-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
  .app-shell .main-nav .settings-tab[aria-expanded="true"] { background: rgba(255, 208, 112, 0.1); color: #ffd070; }
  .app-shell .settings-tab-dot {
    position: absolute; top: 8px; left: calc(50% + 7px); width: 8px; height: 8px;
    border: 2px solid #100e0c; border-radius: 50%; background: #a1a1a6;
  }
  .app-shell .settings-tab-dot.online { background: #34c759; }
  .app-shell .settings-tab-dot.has-update { background: #ffb028; }

  .app-shell .topbar {
    position: static; display: flex; align-items: center; height: auto; padding: 14px 18px 2px;
    border: 0; background: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .app-shell .topbar .mobile-cortex-brand { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
  .app-shell .topbar .mobile-cortex-brand img { width: 30px; height: 30px; border-radius: 8px; box-shadow: none; }
  .app-shell .topbar .mobile-cortex-brand > span { display: grid; gap: 2px; min-width: 0; }
  .app-shell .topbar .mobile-cortex-brand small { color: var(--cortex-dim); font: 600 9px/1 var(--cortex-mono); letter-spacing: 0.16em; }
  .app-shell .topbar .mobile-cortex-brand strong { display: block; overflow: hidden; color: var(--cortex-text); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; text-overflow: ellipsis; white-space: nowrap; }

  .app-shell .settings-scrim:not(.hidden) { position: fixed; inset: 0; z-index: 110; display: block; background: rgba(16, 12, 6, 0.4); }
  .app-shell .settings-menu {
    left: 0; right: 0; bottom: 0; z-index: 120; width: auto; max-height: min(86vh, 640px);
    padding: 12px 14px calc(16px + env(safe-area-inset-bottom, 0px)); border-radius: 24px 24px 0 0;
    box-shadow: 0 -20px 50px rgba(20, 12, 4, 0.35);
    animation-name: settings-sheet-in;
  }
  @keyframes settings-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .app-shell #settingsMenu .settings-row { min-height: 50px; font-size: 15px; }
  .app-shell #settingsMenu .settings-account {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px;
    margin-top: 8px; padding: 14px 10px 0; border-top: 1px solid var(--shell-night-line);
  }
  .app-shell .settings-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 208, 112, 0.12); color: #ffd070; font-weight: 700; }
  .app-shell .settings-account-copy { display: grid; gap: 2px; min-width: 0; }
  .app-shell .settings-account-copy strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
  .app-shell .settings-account-copy small { color: var(--shell-night-3); font-size: 11px; }
  .app-shell #settingsMenu .mobile-logout {
    display: inline-flex; align-items: center; gap: 6px; width: auto; min-width: 44px; min-height: 44px; margin: 0; padding: 0 10px;
    border: 0; border-radius: 10px; background: transparent; color: var(--shell-night-2); font-size: 13px;
  }
  .app-shell #settingsMenu .mobile-logout .logout-icon { width: 18px; height: 18px; }
  .app-shell #settingsMenu .organization-switch select { height: 44px; font-size: 16px; }
  .app-shell #settingsMenu .settings-language .app-language { width: 92px; height: 36px; }
  .app-shell #settingsMenu .settings-language .app-language a { height: 30px; font-size: 12px; }

  .app-shell #marketplace.view { padding-top: 6px; }
  .app-shell #marketSticky { padding: 10px var(--view-gutter); margin-bottom: 16px; }
}

@media (max-width: 360px) {
  .app-shell { --view-gutter: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell .settings-menu { animation: none; }
  .app-shell .sidebar-account .settings-icon { transition: none; }
}

/* 我的 AI 员工: the company card (logo, name, profile status) fills the top-left of the pinned bar where the
   industry tabs sit while browsing (2026-10-22, Pin). Phones already name the company in their header. */
.app-shell #marketSticky:not(.is-team) #companyProfileButton,
.app-shell #marketSticky.is-team #industryPicker { display: none; }
.app-shell #marketSticky #companyProfileButton { flex: 0 1 auto; min-height: 50px; margin-left: -5px; padding-right: 12px; }
.app-shell #marketSticky .company-profile-icon { width: 40px; height: 40px; flex-basis: 40px; }
.app-shell #marketSticky .company-profile-name strong { max-width: min(340px, 32vw); color: var(--cortex-ink, #1f1a12); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.app-shell #marketSticky .company-profile-badge.incomplete { background: #fbf0d8; color: #8a5a00; }
@media (max-width: 820px) {
  .app-shell #marketSticky #companyProfileButton { display: none; }
}

/* Show / hide password (login and password forms) */
.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 44px; }
.password-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted, #6b6b6b); cursor: pointer; }
.password-toggle:hover, .password-toggle:focus-visible { background: rgba(0, 0, 0, .06); color: var(--ink, #1d1d1f); }
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
