:root {
  --shell-nav-width: 252px;
  --shell-nav-collapsed: 84px;
  --shell-radius-sm: 10px;
  --shell-radius-md: 14px;
  --shell-radius-lg: 20px;
  --shell-duration-fast: 160ms;
  --shell-duration: 220ms;
  --shell-ease: cubic-bezier(.2, .8, .2, 1);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --shell-canvas: #080a0f;
  --shell-panel: rgb(17 20 29 / 88%);
  --shell-panel-solid: #11141d;
  --shell-elevated: #181c27;
  --shell-hover: rgb(255 255 255 / 6%);
  --shell-active: rgb(124 92 255 / 14%);
  --shell-border: rgb(255 255 255 / 8%);
  --shell-border-strong: rgb(255 255 255 / 13%);
  --shell-text: #f5f7fb;
  --shell-text-secondary: #9da5b5;
  --shell-text-tertiary: #6f7787;
  --shell-accent: #8b7cff;
  --shell-accent-strong: #a89cff;
  --shell-accent-cyan: #5de4d7;
  --shell-shadow: 0 24px 80px rgb(0 0 0 / 32%);
  --shell-glow: 0 0 36px rgb(124 92 255 / 20%);
}

body[data-theme="light"] {
  color-scheme: light;
  --shell-canvas: #f4f5f8;
  --shell-panel: rgb(255 255 255 / 88%);
  --shell-panel-solid: #fff;
  --shell-elevated: #f8f9fb;
  --shell-hover: rgb(25 32 48 / 5%);
  --shell-active: rgb(91 72 224 / 10%);
  --shell-border: rgb(22 28 45 / 8%);
  --shell-border-strong: rgb(22 28 45 / 13%);
  --shell-text: #171a22;
  --shell-text-secondary: #677083;
  --shell-text-tertiary: #9298a6;
  --shell-accent: #6558e8;
  --shell-accent-strong: #5144d7;
  --shell-accent-cyan: #0baaa2;
  --shell-shadow: 0 24px 70px rgb(39 44 60 / 13%);
  --shell-glow: 0 0 30px rgb(101 88 232 / 13%);
}

body[data-theme="violet"],
body[data-theme="ocean"],
body[data-theme="sunset"] {
  color-scheme: light;
  --shell-panel-solid: #fff;
  --shell-elevated: #fff;
  --shell-text: #171a22;
  --shell-text-secondary: #677083;
  --shell-text-tertiary: #9298a6;
  --shell-shadow: 0 24px 70px rgb(39 44 60 / 13%);
}

body[data-theme="violet"] {
  --shell-canvas: #f4f0ff;
  --shell-panel: rgb(251 249 255 / 90%);
  --shell-hover: rgb(105 73 217 / 7%);
  --shell-active: rgb(112 78 226 / 13%);
  --shell-border: rgb(81 52 170 / 10%);
  --shell-border-strong: rgb(81 52 170 / 16%);
  --shell-accent: #7656e8;
  --shell-accent-strong: #6543dc;
  --shell-accent-cyan: #d05dd7;
  --shell-glow: 0 0 32px rgb(118 86 232 / 18%);
}

body[data-theme="ocean"] {
  --shell-canvas: #edf8fb;
  --shell-panel: rgb(247 253 255 / 91%);
  --shell-hover: rgb(13 123 151 / 7%);
  --shell-active: rgb(14 132 165 / 12%);
  --shell-border: rgb(15 102 126 / 10%);
  --shell-border-strong: rgb(15 102 126 / 16%);
  --shell-accent: #1289a8;
  --shell-accent-strong: #087692;
  --shell-accent-cyan: #20bfae;
  --shell-glow: 0 0 32px rgb(18 137 168 / 17%);
}

body[data-theme="sunset"] {
  --shell-canvas: #fff5ed;
  --shell-panel: rgb(255 251 247 / 92%);
  --shell-hover: rgb(218 91 48 / 7%);
  --shell-active: rgb(230 104 57 / 12%);
  --shell-border: rgb(151 73 42 / 10%);
  --shell-border-strong: rgb(151 73 42 / 16%);
  --shell-accent: #e36c3f;
  --shell-accent-strong: #d45529;
  --shell-accent-cyan: #f0a12f;
  --shell-glow: 0 0 32px rgb(227 108 63 / 18%);
}

html {
  background: var(--shell-canvas);
}

body {
  min-width: 0;
  overflow: hidden;
  color: var(--shell-text);
  background: var(--shell-canvas);
  transition: color var(--shell-duration) ease, background var(--shell-duration) ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 3000;
  padding: 9px 14px;
  border-radius: var(--shell-radius-sm);
  color: #fff;
  background: var(--shell-accent);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.app-ambient i {
  position: absolute;
  border-radius: 999px;
  opacity: .42;
  filter: blur(90px);
}

.app-ambient i:nth-child(1) {
  top: -18%;
  left: 8%;
  width: 36vw;
  height: 32vw;
  background: rgb(99 76 255 / 25%);
}

.app-ambient i:nth-child(2) {
  right: -12%;
  bottom: -22%;
  width: 38vw;
  height: 38vw;
  background: rgb(16 185 172 / 14%);
}

.app-ambient i:nth-child(3) {
  top: 28%;
  right: 22%;
  width: 22vw;
  height: 22vw;
  background: rgb(191 76 255 / 10%);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--shell-nav-width) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 0;
  background: transparent;
  transition: grid-template-columns var(--shell-duration) var(--shell-ease);
}

.app-shell.nav-collapsed {
  grid-template-columns: var(--shell-nav-collapsed) minmax(0, 1fr);
}

.main-nav {
  position: relative;
  z-index: 100;
  display: flex;
  width: auto;
  min-width: 0;
  height: 100vh;
  min-height: 0;
  align-items: stretch;
  gap: 0;
  overflow: visible;
  padding: 16px 14px 14px;
  border: 0;
  border-right: 1px solid var(--shell-border);
  color: var(--shell-text);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 3%), transparent 38%),
    var(--shell-panel);
  box-shadow: 12px 0 42px rgb(0 0 0 / 8%);
  backdrop-filter: blur(26px) saturate(130%);
  transition: padding var(--shell-duration) var(--shell-ease), background var(--shell-duration) ease;
}

.nav-brand {
  position: relative;
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 11px;
  padding: 0 4px 12px;
}

.brand-mark,
.brand-mark:hover {
  display: grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  place-items: center;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--shell-accent), var(--shell-accent-strong));
  box-shadow: var(--shell-glow), inset 0 1px rgb(255 255 255 / 20%);
}

.brand-mark img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  object-position: center 48%;
  transform: scale(1.08);
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.brand-copy strong {
  letter-spacing: .13em;
  color: var(--shell-text);
  font-size: 14px;
  line-height: 1.1;
}

.brand-copy span {
  margin-top: 4px;
  letter-spacing: .04em;
  color: var(--shell-text-tertiary);
  font-size: 10px;
}

.nav-collapse {
  position: absolute;
  top: 8px;
  right: -27px;
  display: grid;
  width: 24px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--shell-border-strong);
  border-left: 0;
  border-radius: 0 9px 9px 0;
  padding: 0;
  color: var(--shell-text-secondary);
  background: var(--shell-panel-solid);
  box-shadow: 8px 4px 18px rgb(0 0 0 / 10%);
}

.nav-collapse:hover {
  color: var(--shell-text);
  background: var(--shell-elevated);
}

.global-create {
  display: flex;
  width: 100%;
  height: 44px;
  align-items: center;
  gap: 9px;
  margin: 8px 0 18px;
  border: 1px solid color-mix(in srgb, var(--shell-accent) 30%, transparent);
  border-radius: 13px;
  padding: 0 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--shell-accent), var(--shell-accent-strong) 68%, color-mix(in srgb, var(--shell-accent-strong) 82%, #111));
  box-shadow: var(--shell-glow), inset 0 1px rgb(255 255 255 / 17%);
  transition: transform var(--shell-duration-fast) ease, box-shadow var(--shell-duration-fast) ease;
}

.global-create:hover {
  transform: translateY(-1px);
  box-shadow: 0 15px 38px color-mix(in srgb, var(--shell-accent) 32%, transparent), inset 0 1px rgb(255 255 255 / 20%);
}

.global-create > span {
  font-size: 20px;
  font-weight: 300;
}

.global-create strong {
  flex: 1;
  text-align: left;
  font-size: 13px;
}

.global-create kbd {
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 6px;
  color: rgb(255 255 255 / 68%);
  background: rgb(0 0 0 / 13%);
  font: 10px/1 inherit;
}

.module-navigation {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  overflow: hidden auto;
  scrollbar-width: none;
}

.module-navigation::-webkit-scrollbar {
  display: none;
}

.nav-section-label {
  display: block;
  margin: 2px 10px 5px;
  letter-spacing: .12em;
  color: var(--shell-text-tertiary);
  font-size: 9px;
  font-weight: 800;
}

.nav-library-label {
  margin-top: 15px;
}

.module-tab,
.module-tab:hover,
.module-tab.active {
  position: relative;
  display: flex;
  width: 100%;
  height: 54px;
  flex: 0 0 54px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0 10px;
  color: var(--shell-text-secondary);
  background: transparent;
  box-shadow: none;
  text-align: left;
  transition: color var(--shell-duration-fast) ease, background var(--shell-duration-fast) ease, border-color var(--shell-duration-fast) ease, transform var(--shell-duration-fast) ease;
}

.module-tab:hover {
  color: var(--shell-text);
  background: var(--shell-hover);
  transform: translateX(1px);
}

.module-tab.active {
  border-color: rgb(139 124 255 / 16%);
  color: var(--shell-text);
  background: linear-gradient(100deg, var(--shell-active), rgb(139 124 255 / 3%));
}

.module-tab.active::after {
  position: absolute;
  top: 13px;
  left: 0;
  width: 2px;
  height: 28px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--shell-accent-strong), var(--shell-accent-cyan));
  box-shadow: 0 0 14px var(--shell-accent);
  content: "";
}

.nav-icon,
.module-tab .nav-icon,
.module-tab.active .nav-icon {
  display: grid;
  width: 32px;
  min-width: 32px;
  height: 32px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  color: var(--shell-text-secondary);
  background: rgb(255 255 255 / 4%);
}

.module-tab.active .nav-icon {
  border-color: rgb(139 124 255 / 24%);
  color: var(--shell-accent-strong);
  background: rgb(139 124 255 / 12%);
  box-shadow: 0 6px 18px rgb(92 70 220 / 13%);
}

.app-icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.nav-icon svg,
.module-tab .nav-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .82;
}

.module-tab.active .nav-icon svg {
  opacity: 1;
}

.nav-icon-spark {
  font-size: 17px;
}

.nav-label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.module-tab .nav-label strong,
.module-tab.active .nav-label strong {
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
}

.nav-label small {
  overflow: hidden;
  color: var(--shell-text-tertiary);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.nav-footer {
  position: relative;
  display: grid;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--shell-border);
}

.membership-card {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  gap: 9px;
  overflow: hidden;
  border: 1px solid rgb(139 124 255 / 16%);
  border-radius: 14px;
  padding: 9px;
  color: inherit;
  background: linear-gradient(135deg, rgb(139 124 255 / 12%), rgb(93 228 215 / 4%));
  cursor: pointer;
  text-align: left;
}

.membership-center {
  position: relative;
  min-width: 0;
}

.membership-card:hover,
.membership-center.is-open .membership-card {
  border-color: rgb(139 124 255 / 34%);
  background: linear-gradient(135deg, rgb(139 124 255 / 18%), rgb(93 228 215 / 7%));
}

.membership-orb {
  display: grid;
  width: 30px;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  color: #dcd7ff;
  background: linear-gradient(145deg, var(--shell-accent), var(--shell-accent-strong));
  box-shadow: var(--shell-glow);
}

.membership-card > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.membership-card strong {
  color: var(--shell-text);
  font-size: 11px;
}

.membership-card small {
  overflow: hidden;
  color: var(--shell-text-tertiary);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
}

.membership-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 5px;
  padding: 2px 4px;
  color: var(--shell-accent-strong);
  background: rgb(139 124 255 / 9%);
  font-size: 7px;
  font-weight: 900;
}

.nav-utilities {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.theme-control {
  position: relative;
  min-width: 0;
}

.theme-control > .utility-button {
  width: 100%;
}

.theme-picker {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 0;
  z-index: 1300;
  display: grid;
  width: 176px;
  gap: 4px;
  border: 1px solid var(--shell-border-strong);
  border-radius: 14px;
  padding: 10px;
  color: var(--shell-text);
  background: var(--shell-elevated);
  box-shadow: var(--shell-shadow);
}

.theme-picker[hidden] {
  display: none;
}

.theme-picker > strong {
  padding: 3px 6px 7px;
  color: var(--shell-text-secondary);
  font-size: 11px;
}

.theme-picker button {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 9px;
  padding: 0 7px;
  color: var(--shell-text-secondary);
  background: transparent;
  font-size: 11px;
}

.theme-picker button:hover,
.theme-picker button.selected {
  color: var(--shell-text);
  background: var(--shell-hover);
}

.theme-swatch {
  width: 18px;
  height: 18px;
  border: 2px solid rgb(255 255 255 / 72%);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--shell-border-strong);
}

.theme-swatch.light { background: linear-gradient(135deg, #fff, #dfe3ea); }
.theme-swatch.violet { background: linear-gradient(135deg, #7656e8, #d05dd7); }
.theme-swatch.ocean { background: linear-gradient(135deg, #1289a8, #20bfae); }
.theme-swatch.sunset { background: linear-gradient(135deg, #e36c3f, #f0a12f); }
.theme-swatch.dark { background: linear-gradient(135deg, #202431, #080a0f); }

.utility-button {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 7px;
  color: var(--shell-text-secondary);
  background: transparent;
  font-size: 11px;
}

.utility-button:hover {
  border-color: var(--shell-border);
  color: var(--shell-text);
  background: var(--shell-hover);
}

.utility-button strong {
  font-size: 10px;
  font-weight: 600;
}

.account-menu {
  position: relative;
  top: auto;
  right: auto;
  z-index: 1200;
  width: 100%;
}

.account-trigger,
.account-trigger:hover,
.account-menu.is-open .account-trigger {
  display: flex;
  width: 100%;
  max-width: none;
  height: 48px;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 5px 7px;
  color: var(--shell-text);
  background: transparent;
  box-shadow: none;
  transform: none;
  backdrop-filter: none;
}

.account-trigger:hover,
.account-menu.is-open .account-trigger {
  border-color: var(--shell-border);
  background: var(--shell-hover);
}

.account-avatar {
  display: grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, #3a4255, #202634);
  box-shadow: inset 0 1px rgb(255 255 255 / 12%);
  font-size: 12px;
}

.account-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.account-copy strong {
  overflow: hidden;
  width: 100%;
  color: var(--shell-text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.account-copy small {
  color: var(--shell-text-tertiary);
  font-size: 9px;
}

.account-chevron {
  color: var(--shell-text-tertiary);
  letter-spacing: .08em;
  font-size: 9px;
}

.account-popover {
  top: auto;
  right: auto;
  bottom: calc(100% + 9px);
  left: 0;
  width: 224px;
  border-color: var(--shell-border-strong);
  color: var(--shell-text);
  background: var(--shell-elevated);
  box-shadow: var(--shell-shadow);
}

.account-popover::before {
  top: auto;
  right: auto;
  bottom: -7px;
  left: 24px;
  border: 0;
  border-right: 1px solid var(--shell-border-strong);
  border-bottom: 1px solid var(--shell-border-strong);
  background: var(--shell-elevated);
}

.account-popover-head {
  border-color: var(--shell-border);
}

.account-popover-head strong {
  color: var(--shell-text);
}

.account-popover-head small,
.account-logout-button {
  color: var(--shell-text-secondary);
}

.account-logout-button:hover {
  color: #ff9a9a;
  background: rgb(255 82 82 / 9%);
}

.workspace {
  position: relative;
  min-width: 0;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--shell-canvas);
}

.view {
  min-height: 0;
  height: 100%;
  overflow: hidden auto;
}

.view.active {
  animation: shell-view-in var(--shell-duration) var(--shell-ease) both;
}

@keyframes shell-view-in {
  from { opacity: .65; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-collapsed .main-nav {
  padding-inline: 12px;
}

.nav-collapsed .brand-copy,
.nav-collapsed .global-create strong,
.nav-collapsed .global-create kbd,
.nav-collapsed .nav-label,
.nav-collapsed .nav-section-label,
.nav-collapsed .membership-card > span:nth-child(2),
.nav-collapsed .membership-badge,
.nav-collapsed .utility-button strong,
.nav-collapsed .account-copy,
.nav-collapsed .account-chevron {
  display: none;
}

.nav-collapsed .nav-brand,
.nav-collapsed .global-create,
.nav-collapsed .module-tab,
.nav-collapsed .membership-card,
.nav-collapsed .account-trigger {
  justify-content: center;
}

.nav-collapsed .global-create {
  padding: 0;
}

.nav-collapsed .membership-card {
  min-height: 46px;
  padding: 7px;
}

.nav-collapsed .nav-utilities {
  grid-template-columns: 1fr;
}

.nav-collapsed .account-popover {
  left: 2px;
}

.nav-collapsed .membership-popover {
  width: 244px;
}

body[data-theme="dark"] .workspace::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 82% 4%, rgb(106 82 235 / 8%), transparent 32%),
    linear-gradient(180deg, rgb(255 255 255 / 1.5%), transparent 20%);
  content: "";
}

body[data-theme="violet"] .app-ambient i:nth-child(1) { background: rgb(118 86 232 / 28%); }
body[data-theme="violet"] .app-ambient i:nth-child(2) { background: rgb(208 93 215 / 18%); }
body[data-theme="ocean"] .app-ambient i:nth-child(1) { background: rgb(18 137 168 / 25%); }
body[data-theme="ocean"] .app-ambient i:nth-child(2) { background: rgb(32 191 174 / 20%); }
body[data-theme="sunset"] .app-ambient i:nth-child(1) { background: rgb(227 108 63 / 24%); }
body[data-theme="sunset"] .app-ambient i:nth-child(2) { background: rgb(240 161 47 / 22%); }

/* Membership details and server-side subscription error feedback. */
.membership-popover {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 0;
  z-index: 1450;
  width: 100%;
  max-height: min(58vh, 480px);
  overflow: hidden auto;
  border: 1px solid var(--shell-border-strong);
  border-radius: 16px;
  padding: 12px;
  color: var(--shell-text);
  background: var(--shell-elevated);
  box-shadow: var(--shell-shadow);
  overscroll-behavior: contain;
}

.membership-popover[hidden] {
  display: none;
}

.membership-center.is-open::after {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 22px;
  z-index: 1451;
  width: 11px;
  height: 11px;
  border-right: 1px solid var(--shell-border-strong);
  border-bottom: 1px solid var(--shell-border-strong);
  background: var(--shell-elevated);
  content: "";
  transform: rotate(45deg);
}

.membership-popover header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--shell-border);
  padding: 2px 2px 10px;
}

.membership-popover header > div {
  display: grid;
  gap: 3px;
}

.membership-popover header strong {
  font-size: 12px;
}

.membership-popover header small {
  color: var(--shell-text-tertiary);
  font-size: 9px;
}

.membership-card .membership-reserved-point {
  color: #7658d6;
  font-weight: 650;
}

.membership-popover header button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  color: var(--shell-text-secondary);
  background: transparent;
}

.membership-popover header button:hover {
  background: var(--shell-hover);
}

.membership-detail-list {
  display: grid;
  gap: 7px;
  margin: 10px 0;
}

.membership-detail-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.membership-detail-list dt {
  color: var(--shell-text-tertiary);
  font-size: 10px;
}

.membership-detail-list dd {
  margin: 0;
  color: var(--shell-text);
  text-align: right;
  font-size: 10px;
  font-weight: 650;
}

.membership-point-rule {
  margin: 0 0 10px;
  border: 1px solid rgb(129 102 233 / 14%);
  border-radius: 10px;
  padding: 8px;
  color: var(--shell-text-secondary);
  background: rgb(129 102 233 / 6%);
  font-size: 9px;
  line-height: 1.6;
}

.membership-reserved-breakdown {
  display: grid;
  gap: 5px;
  margin: 0 0 8px;
  border: 1px solid rgb(118 88 214 / 16%);
  border-radius: 10px;
  padding: 8px;
  background: rgb(118 88 214 / 5%);
}

.membership-reserved-breakdown[hidden] { display: none; }
.membership-reserved-breakdown p { margin: 0; color: var(--shell-text-secondary); font-size: 9px; }
.membership-reserved-breakdown strong { color: #7658d6; font-size: 9px; }

.membership-popover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.membership-popover-actions button {
  min-height: 30px;
  border: 1px solid var(--shell-border);
  border-radius: 9px;
  color: var(--shell-text-secondary);
  background: var(--shell-hover);
  font-size: 9px;
}

.membership-popover-actions button:first-child {
  grid-column: 1 / -1;
}

.membership-popover-actions button.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #7959e8, #557ee9);
}

.account-popover {
  width: min(248px, calc(100vw - 24px));
  padding: 12px;
}

.account-menu-actions {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--shell-border);
  padding-top: 8px;
}

.account-menu-actions button {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  padding: 0 8px;
  color: var(--shell-text-secondary);
  background: transparent;
  font-size: 10px;
  text-align: left;
}

.account-menu-actions button:hover {
  color: var(--shell-text);
  background: var(--shell-hover);
}

.subscription-dialog,
.point-logs-dialog {
  width: min(470px, calc(100vw - 32px));
  border: 1px solid rgb(121 91 222 / 18%);
  border-radius: 22px;
  padding: 0;
  color: #252334;
  background: #fff;
  box-shadow: 0 28px 80px rgb(48 37 91 / 24%);
}

.subscription-dialog::backdrop,
.point-logs-dialog::backdrop {
  background: rgb(25 22 42 / 42%);
  backdrop-filter: blur(4px);
}

.subscription-dialog form {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 34px 30px 28px;
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  color: #746f83;
  background: #f3f1f8;
  font-size: 18px;
}

.subscription-lock {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #8c62ed, #527ce8);
  box-shadow: 0 12px 28px rgb(112 83 220 / 25%);
  font-size: 25px;
}

.subscription-dialog h2 {
  margin: 18px 0 8px;
  font-size: 21px;
}

.subscription-dialog p {
  margin: 0;
  color: #777286;
  font-size: 13px;
  line-height: 1.7;
}

.subscription-dialog-actions {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 9px;
  margin-top: 24px;
}

.subscription-dialog-actions button {
  min-height: 38px;
  border: 1px solid #e3dff0;
  border-radius: 11px;
  padding: 0 16px;
  color: #655f73;
  background: #faf9fc;
}

.subscription-dialog-actions button.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #7b59e8, #557fe9);
}

.point-logs-dialog > section {
  max-height: min(680px, calc(100vh - 48px));
  padding: 18px;
  overflow: hidden;
}

.point-logs-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.point-logs-dialog header h2 {
  margin: 0;
  font-size: 18px;
}

.point-logs-dialog header button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: #f2f0f7;
  font-size: 18px;
}

#point-logs-list {
  display: grid;
  max-height: 560px;
  gap: 8px;
  margin-top: 14px;
  overflow: auto;
}

#point-logs-list article {
  border: 1px solid #ece9f3;
  border-radius: 13px;
  padding: 11px 12px;
  background: #fbfafe;
}

#point-logs-list article div {
  display: flex;
  justify-content: space-between;
}

#point-logs-list article b {
  color: #7657d7;
}

#point-logs-list article small,
#point-logs-list article p {
  display: block;
  margin: 4px 0 0;
  color: #817b8d;
  font-size: 10px;
}

.generation-cost-strip {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 4px 0;
  color: #7a7489;
  font-size: 10px;
}

.generation-cost-strip strong,
.generation-billing-status {
  color: #7357d5;
  font-size: 10px;
  font-weight: 650;
}

.generation-cost-strip strong[data-status="WAITING_FOR_POINTS"],
.generation-billing-status[data-status="WAITING_FOR_POINTS"] {
  color: #b67b1e;
}

.generation-cost-strip strong[data-status="POINT_REFUNDED"],
.generation-billing-status[data-status="POINT_REFUNDED"] {
  color: #248e68;
}

.generation-cost-hint {
  color: #746d83 !important;
  font-size: 10px !important;
}

.generation-billing-status {
  display: block;
  min-height: 16px;
  padding: 0 4px;
  line-height: 1.5;
}

/* 创意工坊成功结果只展示图片和操作栏，生成及存储数据保持在状态层。 */
.image-workbench .message-row.assistant .message.image-message {
  width: min(632px, calc(100% - 48px));
  max-width: min(632px, calc(100% - 48px));
}

.message.image-message.assistant .generated-image-gallery {
  display: grid;
  width: 100%;
  max-width: 632px;
  align-items: start;
  justify-content: start;
  gap: 16px;
  margin-top: 18px;
  overflow: visible;
}

.message.image-message.assistant:not(.is-pending):not(.is-failed) .generated-image-gallery {
  margin-top: 0;
}

.message.image-message.assistant .generated-image-gallery.is-single {
  grid-template-columns: minmax(0, 300px);
}

.message.image-message.assistant .generated-image-gallery.is-multiple {
  grid-template-columns: repeat(2, minmax(0, 300px));
}

.image-workbench .generated-image-result {
  display: grid;
  width: fit-content;
  max-width: min(300px, 100%);
  min-width: 0;
  align-content: start;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: generated-result-enter .32s ease-out both;
}

.message.image-message.assistant .generated-image-gallery .message-image-button {
  display: flex;
  width: fit-content;
  max-width: min(300px, 100%);
  max-height: 300px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  aspect-ratio: auto;
  overflow: hidden;
  border: 0 !important;
  border-radius: 16px;
  outline: 0 !important;
  padding: 0;
  background: #fff;
  box-shadow: 0 10px 32px rgb(15 23 42 / 9%);
}

.message.image-message.assistant .generated-image-gallery .message-image-button:focus,
.message.image-message.assistant .generated-image-gallery .message-image-button:focus-visible {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

.message.image-message.assistant .generated-image-gallery .message-image-button img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(300px, 100%);
  max-height: 300px;
  object-fit: contain;
  border: 0 !important;
  border-radius: 0;
  outline: 0 !important;
  background: #fff;
  box-shadow: none;
  transition: transform .24s ease, opacity .2s ease;
}

/* 独立大图预览器只加载当前图片，切换时再替换图片地址。 */
.image-preview-modal {
  position: fixed;
  z-index: 120000;
  inset: 0;
  display: grid;
  overflow: hidden;
  grid-template-columns: 88px minmax(0, 1fr) 88px;
  grid-template-rows: 64px minmax(0, 1fr);
  background: rgb(0 0 0 / 85%);
  opacity: 0;
  transition: opacity .2s ease;
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-modal.is-open {
  opacity: 1;
}

.image-preview-topbar {
  z-index: 3;
  display: grid;
  grid-column: 1 / -1;
  grid-row: 1;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 22px;
  pointer-events: none;
}

.image-preview-toolbar {
  display: flex;
  grid-column: 1;
  justify-self: start;
  gap: 6px;
  pointer-events: auto;
}

.image-preview-toolbar button {
  min-width: 38px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  padding: 0 10px;
  color: #fff;
  background: rgb(255 255 255 / 12%);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.image-preview-toolbar button:hover:not(:disabled) {
  background: rgb(255 255 255 / 20%);
}

.image-preview-toolbar button:disabled {
  cursor: default;
  opacity: .38;
}

.image-preview-count {
  grid-column: 2;
  border-radius: 999px;
  padding: 7px 13px;
  color: rgb(255 255 255 / 92%);
  background: rgb(255 255 255 / 10%);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.image-preview-close {
  grid-column: 3;
  justify-self: end;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgb(255 255 255 / 12%);
  pointer-events: auto;
  font-size: 26px;
  line-height: 1;
  transition: background .2s ease, transform .2s ease;
}

.image-preview-close:hover {
  background: rgb(255 255 255 / 20%);
  transform: scale(1.04);
}

.image-preview-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-column: 2;
  grid-row: 2;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
}

.image-preview-stage.is-zoomed {
  cursor: grab;
}

.image-preview-stage.is-dragging {
  cursor: grabbing;
}

.image-preview-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 88px);
  object-fit: contain;
  border: 0;
  border-radius: 12px;
  outline: 0;
  box-shadow: 0 24px 80px rgb(0 0 0 / 36%);
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transition: opacity .18s ease;
}

.image-preview-image.is-loading {
  opacity: .28;
}

.image-preview-nav {
  z-index: 2;
  align-self: center;
  justify-self: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgb(255 255 255 / 12%);
  backdrop-filter: blur(12px);
  font-size: 23px;
  transition: background .2s ease, transform .2s ease;
}

.image-preview-nav:hover {
  background: rgb(255 255 255 / 22%);
  transform: scale(1.05);
}

.image-preview-prev {
  grid-column: 1;
  grid-row: 2;
}

.image-preview-next {
  grid-column: 3;
  grid-row: 2;
}

@media (max-width: 680px) {
  .image-preview-modal {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .image-preview-topbar {
    padding: 0 10px;
  }

  .image-preview-stage {
    grid-column: 1 / -1;
    padding: 0 10px 12px;
  }

  .image-preview-image {
    max-width: 100%;
    max-height: calc(100vh - 76px);
    border-radius: 10px;
  }

  .image-preview-nav {
    width: 38px;
    height: 38px;
    font-size: 19px;
  }

  .image-preview-prev,
  .image-preview-next {
    grid-row: 2;
  }
}

.image-workbench .generated-image-footer {
  display: flex;
  margin-top: 8px;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  padding: 0;
  background: transparent;
}

.image-workbench .generated-image-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  transition: opacity .2s ease, transform .2s ease;
}

.image-workbench .generated-image-item-actions .edit-from-message {
  margin-top: 0;
}

.image-workbench .generated-image-item-actions .download-image {
  gap: 5px;
  line-height: 1;
  white-space: nowrap;
}

.image-workbench .download-image-icon {
  display: block;
  flex: 0 0 14px;
}

.image-workbench .download-image-label {
  display: block;
  font-family: inherit;
  letter-spacing: 0;
}

.image-workbench .generated-image-gallery.is-multiple .generated-image-item-actions {
  opacity: .72;
}

.image-workbench .generated-image-gallery.is-multiple .generated-image-result:hover .generated-image-item-actions,
.image-workbench .generated-image-gallery.is-multiple .generated-image-result:focus-within .generated-image-item-actions {
  opacity: 1;
}

@keyframes generated-result-enter {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: scale(1); }
}

/* 只移除图片生成输出的卡片外观，普通 AI 聊天气泡保持不变。 */
.image-workbench .message.image-message.assistant:not(.is-failed) {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.image-workbench .message.image-message.assistant.is-pending .generation-frame {
  border: 0 !important;
  box-shadow: none !important;
}

.image-workbench .image-error-card {
  display: grid;
  width: 300px;
  height: 300px;
  max-width: 100%;
  box-sizing: border-box;
  place-items: center;
  align-content: center;
  gap: 24px;
  border: 1px solid #fecdca;
  border-radius: 16px;
  padding: 28px;
  color: #b42318;
  background:
    radial-gradient(circle at 50% 28%, rgb(217 45 32 / 9%), transparent 32%),
    #fff8f7;
  box-shadow: 0 10px 26px rgb(217 45 32 / 7%);
  text-align: center;
}

.image-workbench .image-error-card-content {
  display: grid;
  gap: 12px;
}

.image-workbench .image-error-card strong {
  font-size: 16px;
}

.image-workbench .image-error-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #7a271a;
  font-size: 13px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.image-workbench .image-error-card .retry-message {
  margin: 0;
}

@media (min-width: 1600px) {
  .image-workbench .message-row.assistant .message.image-message {
    width: min(632px, calc(100% - 48px));
    max-width: min(632px, calc(100% - 48px));
  }

}

@media (max-width: 680px) {
  .image-workbench .message-row.assistant .message.image-message {
    width: calc(100% - 38px);
    max-width: calc(100% - 38px);
  }

  .message.image-message.assistant .generated-image-gallery.is-single,
  .message.image-message.assistant .generated-image-gallery.is-multiple {
    grid-template-columns: minmax(0, 1fr);
  }

  .image-workbench .generated-image-item-actions {
    width: auto;
    opacity: 1 !important;
  }

  .image-preview-toolbar {
    gap: 4px;
  }

  .image-preview-toolbar button {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
  }
}

/* 图片详情始终按当前舞台尺寸缩放，避免响应式上下布局时按整屏高度计算而被裁切。 */
.media-viewer-stage {
  min-width: 0;
  min-height: 0;
  place-items: center;
}

.media-viewer-viewport {
  position: relative;
  width: calc(100% - 170px);
  height: calc(100% - 80px);
  max-width: none;
  max-height: calc(100% - 96px);
  place-items: center;
  overflow: hidden;
}

.media-viewer-viewport img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: center !important;
  cursor: zoom-in;
}

.media-viewer-magnifier {
  position: absolute;
  z-index: 4;
  width: 180px;
  height: 180px;
  overflow: hidden;
  border: 3px solid rgb(255 255 255 / 92%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 12px 38px rgb(15 23 42 / 24%);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.media-viewer-magnifier[hidden] {
  display: none;
}

.media-viewer-magnifier img {
  position: absolute;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  object-fit: fill;
  box-shadow: none;
  transform: none !important;
}

/* 移动端舞台只有部分视口高度，详情图片必须跟随舞台计算，避免被父级裁切。 */
@media (max-width: 980px) {
  .media-viewer-viewport {
    width: calc(100% - 72px);
    height: calc(100% - 58px);
    max-width: calc(100% - 72px);
    max-height: calc(100% - 58px);
  }

  .media-viewer-magnifier {
    display: none;
  }
}

.chat-quote-panel article {
  padding-top: 9px;
}

/* 媒体分页由脚本维护可见锚点，关闭浏览器的重复滚动补偿。 */
.assets-grid,
.inspiration-grid {
  overflow-anchor: none;
}

.workspace > .view {
  position: relative;
  z-index: 1;
}

@media (max-width: 1180px) {
  :root { --shell-nav-width: 224px; }
  .main-nav { padding-inline: 11px; }
}

@media (max-width: 1360px) and (min-width: 901px) {
  .video-workbench { grid-template-columns: 240px minmax(360px, 1fr) minmax(320px, 38vw); }
}

@media (max-width: 760px) {
  :root { --shell-mobile-nav-height: 68px; }
  html, body { width: 100%; min-width: 0; height: 100%; overflow: hidden; }
  .app-shell, .app-shell.nav-collapsed { display: block; width: 100%; height: 100dvh; }
  .main-nav {
    position: fixed; inset: auto 0 0; z-index: 1400; width: 100%; height: var(--shell-mobile-nav-height);
    min-height: 0; padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--shell-border); border-right: 0;
    background: color-mix(in srgb, var(--shell-panel-solid) 92%, transparent);
    box-shadow: 0 -12px 36px rgb(15 23 42 / 10%); backdrop-filter: blur(20px) saturate(140%);
  }
  .nav-brand, .global-create, .nav-section-label, .membership-card, .nav-utilities, .nav-collapse { display: none; }
  .module-navigation { display: grid; height: 100%; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; overflow: visible; }
  .module-tab, .nav-collapsed .module-tab { width: 100%; min-width: 0; height: 56px; justify-content: center; gap: 2px; border-radius: 12px; padding: 4px 2px; }
  .module-tab .nav-icon { width: 28px; height: 28px; }
  .module-tab .nav-icon svg { width: 23px; height: 23px; }
  .module-tab .nav-label, .nav-collapsed .module-tab .nav-label { display: block; min-width: 0; }
  .module-tab .nav-label strong { display: block; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .module-tab .nav-label small { display: none; }
  .nav-footer { position: fixed; top: 8px; right: 8px; z-index: 1500; display: block; padding: 0; border: 0; }
  .account-menu { position: static; }
  .account-trigger { width: 42px; max-width: 42px; height: 42px; padding: 4px; }
  .account-copy, .account-chevron { display: none; }
  .account-popover { position: fixed; top: 58px; right: 8px; }
  .workspace { width: 100%; height: calc(100dvh - var(--shell-mobile-nav-height)); overflow: hidden; }
  .workspace > .view, .workspace > .view.active { width: 100%; height: 100%; min-height: 0; }
  .image-workbench { display: block; width: 100%; height: 100%; }
  .chat-sidebar { display: none; }
  .image-main { width: 100%; height: 100%; grid-template-rows: 58px minmax(0, 1fr); }
  .image-topbar { min-width: 0; padding: 0 58px 0 16px; }
  .image-topbar h1 { font-size: 18px; }
  .image-topbar p { overflow: hidden; max-width: 74vw; text-overflow: ellipsis; white-space: nowrap; }
  .conversation { padding: 8px; }
  .message-list { padding: 12px 6px 20px; }
  .prompt-composer { max-height: min(52dvh, 430px); margin: 0; padding: 10px; overflow-y: auto; border-radius: 16px; }
  .prompt-composer textarea { min-height: 70px; }
  .toolbar-left, .toolbar-right { width: 100%; gap: 8px; }
  .detail-layout { height: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: 148px minmax(0, 1fr); padding: 8px; }
  .detail-mode-sidebar { display: grid; grid-template-columns: 72px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 6px; padding: 8px; }
  .detail-mode-tab { grid-row: 1 / 3; height: 100%; flex-direction: column; justify-content: center; }
  .detail-history-heading { grid-column: 2; margin: 0; }
  .detail-history-list { display: flex; grid-column: 2; max-height: none; gap: 7px; overflow-x: auto; overflow-y: hidden; }
  .detail-history-item { min-width: 180px; }
  .detail-canvas { display: none; }
  .detail-panel { min-width: 0; }
  .assets-workbench, .inspiration-workbench { height: 100%; padding: 18px 12px 40px; }
  .inspiration-header, .inspiration-search-tools { align-items: stretch; flex-direction: column; }
  .inspiration-search-tools label, .inspiration-search-tools select { width: 100%; }
  .inspiration-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .asset-day-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .main-nav,
  .module-tab,
  .global-create,
  .view.active {
    animation: none;
    transition: none;
  }
}
