/**
 * 词元工作室 · 子页统一顶栏
 */

:root {
  --platform-shell-height: 52px;
}

.platform-shell {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10070;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--platform-shell-height);
  padding: calc(6px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 6px calc(12px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--w12);
  background: var(--w05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 24px var(--shadow-card);
}

[data-theme="light"] .platform-shell {
  background: rgba(255, 255, 255, 0.82);
  border-bottom-color: rgba(99, 102, 241, 0.12);
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.08);
}

.platform-shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 0;
}

.platform-shell-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow: none;
}

.platform-shell-brand-text {
  font-family: "LXGW WenKai", "霞鹜文楷", KaiTi, "楷体", serif;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 1px;
  white-space: nowrap;
}

.platform-shell-context {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: center;
  padding: 0 4px;
}

.platform-shell-avatar {
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
}

.platform-shell-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  text-align: center;
}

.platform-shell-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.platform-shell-subtitle {
  font-size: 11px;
  color: var(--w55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(42vw, 320px);
}

.platform-shell-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.platform-shell-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--w15);
  background: var(--w06);
  color: var(--w78);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.platform-shell-back:hover {
  color: var(--text-primary);
  border-color: rgba(102, 126, 234, 0.4);
  background: var(--w08);
}

.platform-shell-back:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.45);
  outline-offset: 2px;
}

.platform-shell-theme {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--w15);
  background: var(--w06);
  color: var(--w80);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.platform-shell-theme:hover {
  transform: scale(1.05);
  border-color: rgba(102, 126, 234, 0.45);
  box-shadow: 0 4px 16px var(--shadow-card);
}

.platform-shell-theme:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.45);
  outline-offset: 2px;
}

body.platform-shell-mounted {
  padding-top: calc(var(--platform-shell-height) + env(safe-area-inset-top));
}

body.platform-shell-mounted.inv-body,
body.platform-shell-mounted.chat-body {
  padding-top: calc(var(--platform-shell-height) + env(safe-area-inset-top));
}

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

  .platform-shell-subtitle {
    display: none;
  }

  .platform-shell-back span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .platform-shell-back {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }
}

@media (min-width: 1024px) {
  .platform-shell {
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
  }
}

/* minimal：Logo 回首页即可，不再在右侧再放一个返回 */
.platform-shell--minimal {
  min-height: 44px;
  gap: 10px;
  box-shadow: none;
}

.platform-shell--minimal .platform-shell-context {
  justify-content: flex-start;
}

.platform-shell--logo-only {
  justify-content: flex-start;
}

.platform-shell--logo-only .platform-shell-brand-text,
.platform-shell--logo-only .platform-shell-context {
  display: none;
}

/* 仅左上角 Logo：不占文档流、不推内容 */
.platform-shell--corner {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  right: auto;
  bottom: auto;
  z-index: 10080;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(20, 24, 30, 0.1);
  text-decoration: none;
}

.platform-shell--corner .platform-shell-logo {
  width: 32px;
  height: 32px;
}

body.platform-shell-mounted--minimal {
  padding-top: calc(44px + env(safe-area-inset-top));
}

body.platform-shell-mounted--corner {
  /* corner logo 不占用顶栏高度 */
}

/* 暗色工具页（钢琴 / Bye PPT）：不引入 theme.css，颜色自给 */
.platform-shell--dark {
  background: rgba(16, 13, 11, 0.78);
  border-bottom-color: rgba(243, 239, 230, 0.1);
  box-shadow: none;
  color: #f3efe6;
}

.platform-shell--dark .platform-shell-brand,
.platform-shell--dark .platform-shell-brand-text,
.platform-shell--dark .platform-shell-title {
  color: #f3efe6;
}

.platform-shell--dark .platform-shell-logo {
  box-shadow: none;
}

.platform-shell--dark.platform-shell--corner {
  background: rgba(16, 13, 11, 0.72);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.platform-shell--dark .platform-shell-back {
  border-color: rgba(243, 239, 230, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(243, 239, 230, 0.88);
}

.platform-shell--dark .platform-shell-back:hover {
  color: #f3efe6;
  border-color: rgba(201, 136, 42, 0.45);
  background: rgba(201, 136, 42, 0.16);
}
