/* ==========================================================================
   MangaCore 工作台外壳（/）
   顶部应用条 + iframe 舞台。站点页面用 ?embed=1 去掉自己的头尾，
   DSH 助手 / 内容后台 / 文件库 用各自域名嵌入，切换标签只显示/隐藏。
   ========================================================================== */

:root {
  --bg: #0a0c11;
  --bg-soft: #0d1017;
  --surface: #12161f;
  --surface-2: #171d29;
  --surface-3: #1d2433;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9edf6;
  --text-soft: #c3cadb;
  --muted: #98a2b8;
  --faint: #6b7488;
  --brand: #7f97ff;
  --brand-2: #b387ff;
  --brand-soft: rgba(127, 151, 255, 0.12);
  --brand-glow: rgba(127, 151, 255, 0.3);
  --bad: #ff6b7a;
  --radius: 14px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.8);
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --bar-h: 56px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f8;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #101728;
  --text-soft: #2c3648;
  --muted: #5a6478;
  --faint: #8a93a6;
  --brand: #4f63f0;
  --brand-2: #8b5cf6;
  --brand-soft: rgba(79, 99, 240, 0.1);
  --brand-glow: rgba(79, 99, 240, 0.2);
  --bad: #d42f40;
  --shadow: 0 18px 44px -26px rgba(15, 23, 42, 0.3);
  color-scheme: light;
}

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

html,
body {
  height: 100%;
}

body.shell-body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --------------------------------------------------------------- layout */

.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
}

/* ------------------------------------------------------------- app bar */

.shell-bar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  height: var(--bar-h);
  padding: 0 clamp(12px, 2vw, 20px);
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
}

.shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  min-width: 0;
  padding: 4px 6px 4px 2px;
  border-radius: 10px;
}

.shell-brand:hover {
  background: var(--brand-soft);
}

.shell-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
  flex: none;
  box-shadow: 0 6px 18px -8px var(--brand-glow);
}

.shell-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shell-avatar-brand {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.shell-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 12px;
}

.shell-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.18;
  min-width: 0;
}

.shell-brand-name {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.shell-brand-tag {
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  margin-left: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

.shell-tab {
  position: relative;
  flex: none;
  padding: 7px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.16s ease, background 0.16s ease;
}

.shell-tab:hover {
  color: var(--text);
  background: var(--brand-soft);
}

.shell-tab.is-active {
  color: var(--text);
  background: var(--brand-soft);
}

.shell-tab.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--brand);
}

.shell-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  margin-left: auto;
}

.shell-assistant {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid rgba(127, 151, 255, 0.34);
  background: linear-gradient(135deg, rgba(127, 151, 255, 0.18), rgba(179, 135, 255, 0.14));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

:root[data-theme="light"] .shell-assistant {
  border-color: rgba(79, 99, 240, 0.28);
  background: linear-gradient(135deg, rgba(79, 99, 240, 0.12), rgba(139, 92, 246, 0.1));
}

.shell-assistant svg {
  color: var(--brand);
}

.shell-assistant:hover {
  border-color: var(--brand);
  box-shadow: 0 8px 22px -12px var(--brand-glow);
}

.shell-assistant.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 10px 26px -12px var(--brand-glow);
}

.shell-assistant.is-active svg {
  color: #fff;
}

.shell-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.shell-icon:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.shell-theme-light {
  display: none;
}

:root[data-theme="light"] .shell-theme-dark {
  display: none;
}

:root[data-theme="light"] .shell-theme-light {
  display: block;
}

.shell-login {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.shell-login:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* ------------------------------------------------------------ account */

.shell-user {
  position: relative;
  flex: none;
}

.shell-user > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 9px 0 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  list-style: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.shell-user > summary::-webkit-details-marker {
  display: none;
}

.shell-user > summary:hover,
.shell-user[open] > summary {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.shell-user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-soft);
}

.shell-caret {
  display: grid;
  place-items: center;
  color: var(--faint);
}

.shell-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 60;
  width: 242px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.shell-menu-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}

.shell-menu-head b {
  font-size: 13px;
  font-weight: 600;
}

.shell-menu-head span {
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-soft);
  transition: background 0.14s ease, color 0.14s ease;
}

.shell-menu-item svg {
  color: var(--faint);
}

.shell-menu-item:hover {
  background: var(--brand-soft);
  color: var(--text);
}

.shell-menu-item:hover svg {
  color: var(--brand);
}

.shell-menu-item.danger {
  color: var(--bad);
}

.shell-menu-item.danger svg {
  color: var(--bad);
}

.shell-menu-btn {
  display: none;
}

/* -------------------------------------------------------------- stage */

.shell-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.shell-pane {
  position: absolute;
  inset: 0;
}

.shell-pane[hidden] {
  display: none;
}

.shell-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

.shell-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background:
    radial-gradient(620px 320px at 50% 30%, rgba(127, 151, 255, 0.1), transparent 70%),
    var(--bg);
  transition: opacity 0.35s ease;
}

.shell-veil.is-gone {
  opacity: 0;
  pointer-events: none;
}

.shell-veil-label {
  margin: 0;
  font-size: 12.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.shell-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  animation: shell-spin 0.8s linear infinite;
}

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

/* 登录 / 权限提示 */

.shell-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(700px 380px at 50% 22%, rgba(127, 151, 255, 0.12), transparent 72%),
    var(--bg);
}

.shell-gate[hidden] {
  display: none;
}

.shell-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(420px, 100%);
  padding: 34px 30px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: var(--shadow);
  text-align: center;
}

.shell-gate-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
}

.shell-gate-card h2 {
  margin: 4px 0 0;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.shell-gate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.shell-gate-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.shell-gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.shell-gate-btn:hover {
  border-color: var(--brand);
}

.shell-gate-btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}

.shell-noscript {
  padding: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.shell-noscript a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .shell-brand-tag {
    display: none;
  }
}

@media (max-width: 860px) {
  :root {
    --bar-h: 52px;
  }

  .shell-tabs {
    position: absolute;
    top: calc(100% + 8px);
    left: 10px;
    right: 10px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: visible;
    z-index: 50;
  }

  .shell-tabs.is-open {
    display: flex;
  }

  .shell-tab {
    padding: 11px 12px;
    font-size: 14px;
  }

  .shell-tab.is-active::after {
    left: 4px;
    top: 50%;
    bottom: auto;
    margin-top: -2px;
  }

  .shell-menu-btn {
    display: grid;
  }

  .shell-user-name {
    display: none;
  }

  .shell-user > summary {
    padding: 0 7px 0 4px;
  }

  .shell-caret {
    display: none;
  }
}

@media (max-width: 560px) {
  .shell-brand-text {
    display: none;
  }

  .shell-assistant span {
    display: none;
  }

  .shell-assistant {
    padding: 7px 10px;
  }

  .shell-bar {
    gap: 6px;
  }

  .shell-gate-card {
    padding: 28px 20px;
  }
}
.shell-veil-hint {
  position: absolute;
  right: 0;
  bottom: 34px;
  left: 0;
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
}

.shell-veil-hint[hidden] {
  display: none;
}

.shell-veil-hint a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}
