@import url("./home.css");
@import url("./workbench.css");
@import url("./resources.css");
@import url("./library-logos.css");

:root {
  color-scheme: light;
  --header-h: 100px;
  font-family:
    "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI",
    "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:
    ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas,
    monospace;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f6f5f1;
  --surface-3: #eeede8;
  --ink: #161618;
  --ink-2: #3b3b40;
  --muted: #86868b;
  --faint: #b8b7b2;
  --line: rgba(22, 22, 24, 0.08);
  --line-strong: rgba(22, 22, 24, 0.14);
  --ok: #1d8a4e;
  --ok-bg: #e7f4ec;
  --warn: #a4660a;
  --warn-bg: #fbf1de;
  --bad: #b8392d;
  --bad-bg: #fcebe8;
  --radius: 24px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-sm: 0 1px 2px rgba(22, 22, 24, 0.04),
    0 2px 8px rgba(22, 22, 24, 0.04);
  --shadow: 0 1px 2px rgba(22, 22, 24, 0.04),
    0 12px 32px -8px rgba(22, 22, 24, 0.1);
  --shadow-lg: 0 2px 6px rgba(22, 22, 24, 0.05),
    0 32px 64px -16px rgba(22, 22, 24, 0.18);
  /* 资源库主题色：页面中所有 [data-site] 节点共用 */
  --site: var(--ink);
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
[data-site="1"] {
  --site: #ec4f72;
  --site-soft: #fde8ee;
}
[data-site="2"] {
  --site: #d8323b;
  --site-soft: #fce6e7;
}
[data-site="5"] {
  --site: #26a843;
  --site-soft: #e3f6e7;
}
[data-site="6"] {
  --site: #f27405;
  --site-soft: #fdeedd;
}
* {
  box-sizing: border-box;
}
html {
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100dvh;
  font-size: 14px;
  line-height: 1.6;
  background: transparent;
}
[hidden] {
  display: none !important;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
svg {
  display: block;
  flex-shrink: 0;
}
::selection {
  background: rgba(22, 22, 24, 0.14);
}

/* ---------- 背景柔光 ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
}
.orb-a {
  width: 560px;
  height: 560px;
  top: -220px;
  left: -140px;
  background: #ffd9c2;
}
.orb-b {
  width: 620px;
  height: 620px;
  right: -220px;
  top: 18%;
  background: #dcd8ff;
  opacity: 0.45;
}
.orb-c {
  width: 520px;
  height: 520px;
  left: 30%;
  bottom: -320px;
  background: #d4eedd;
  opacity: 0.45;
}

/* ---------- 按钮 ---------- */
button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 560;
  line-height: 1.4;
  white-space: nowrap;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    box-shadow 0.25s var(--ease),
    transform 0.25s var(--ease),
    opacity 0.2s;
}
button:hover {
  background: var(--surface-2);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
button svg {
  width: 16px;
  height: 16px;
}
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
.primary {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 6px 16px -6px rgba(22, 22, 24, 0.5);
}
.primary:hover:not(:disabled) {
  background: #2a2a2e;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 10px 24px -8px rgba(22, 22, 24, 0.55);
  transform: translateY(-1px);
}
.primary:disabled {
  opacity: 1;
  color: #a9a9ad;
  background: var(--surface-3);
  border-color: transparent;
  box-shadow: none;
}
.primary svg {
  transition: transform 0.3s var(--ease);
}
.primary:hover:not(:disabled) svg {
  transform: translateX(3px);
}
a.primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
}
.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.quiet:hover {
  background: rgba(22, 22, 24, 0.05);
}
.icon-text svg {
  width: 15px;
  height: 15px;
}
.wide {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
  padding: 14px 20px;
  font-size: 15px;
}
.small {
  font-size: 12.5px;
  padding: 7px 14px;
}
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  color: var(--ink-2);
}
.icon-button:hover {
  background: var(--surface-3);
}
.icon-button svg {
  width: 18px;
  height: 18px;
}
button[aria-busy="true"]::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
button[aria-busy="true"] svg {
  display: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 表单 ---------- */
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 16px;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.25s var(--ease);
}
input:hover,
textarea:hover {
  border-color: var(--line-strong);
}
input:focus,
textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: rgba(22, 22, 24, 0.35);
  box-shadow: 0 0 0 4px rgba(22, 22, 24, 0.06);
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
textarea {
  resize: vertical;
  line-height: 1.9;
  min-height: 150px;
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
fieldset:disabled textarea {
  opacity: 0.6;
}
label {
  display: block;
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 560;
  color: var(--ink-2);
}
label input {
  margin-top: 8px;
  font-weight: 400;
}

/* ---------- 文字 ---------- */
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
h1:focus {
  outline: none;
}
h2 {
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
p {
  margin-top: 6px;
}
strong {
  font-weight: 620;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 560;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.eyebrow:empty {
  display: none;
}
.caption,
.muted {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.75;
}
.caption {
  margin-top: 10px;
}
.caption:empty {
  display: none;
}
.url {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- 顶栏 ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  /* 与 main 同宽同边距，导航与账号按钮和下方内容左右对齐 */
  max-width: 1120px;
  /* 顶部留白：导航不贴着浏览器边缘；刘海屏额外让出安全区 */
  height: calc(var(--header-h) + env(safe-area-inset-top));
  margin: auto;
  padding: env(safe-area-inset-top) 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: transform 0.35s var(--ease);
}
/* 手机端向下滑动时收起顶栏，向上滑动再出现（app.js 切换） */
.header.is-hidden {
  transform: translateY(-100%);
}
.header nav {
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow-sm);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.header nav a {
  padding: 7px 18px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 560;
  transition:
    color 0.2s,
    background 0.3s var(--ease),
    box-shadow 0.3s var(--ease);
}
.header nav a:hover {
  color: var(--ink);
}
.header nav a.active {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 4px 12px -4px rgba(22, 22, 24, 0.45);
}
.account-button {
  max-width: 34%;
  padding: 8px 16px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow-sm);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  font-size: 13px;
}
.account-button::before {
  content: "";
  display: inline-block;
  vertical-align: -7px;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='9' r='3.5'/%3E%3Cpath d='M5.5 19c1.2-3 3.6-4.5 6.5-4.5s5.3 1.5 6.5 4.5'/%3E%3C/svg%3E")
      center / 16px no-repeat,
    var(--ink);
}
.account-button:hover {
  background: rgba(255, 255, 255, 0.85);
}

/* ---------- 主体与转场 ---------- */
main {
  max-width: 1120px;
  margin: 12px auto 80px;
  padding: 0 32px;
}
main > section {
  /* 整节只做淡入：transform/filter 会让内部 fixed 元素（底部操作条、dock）
     在动画期间以本节为定位基准，出现"先在上方再跳到底部"。位移与虚化放在子元素上。 */
  animation: fade-in 0.45s ease-out backwards;
}
.page-heading,
.checkout-panel {
  animation: stage-in 0.6s var(--ease) backwards;
}
@keyframes stage-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 36px 0 28px;
}
.panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
}
.pill.accent {
  color: #fff;
  background: var(--ink);
}
.pill:empty {
  display: none;
}
.inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.stack {
  display: grid;
  gap: 24px;
}
.stack:empty {
  display: none;
}
.text-link,
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 560;
  color: var(--muted);
  transition: color 0.2s;
}
.text-link svg,
.back-link svg {
  width: 15px;
  height: 15px;
  transition: transform 0.3s var(--ease);
}
.text-link {
  margin-top: 18px;
}
.text-link:hover,
.back-link:hover {
  color: var(--ink);
}
.text-link:hover svg {
  transform: translateX(3px);
}
.back-link:hover svg {
  transform: translateX(-3px);
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty-art {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--faint);
}
.empty-art svg {
  width: 26px;
  height: 26px;
}
.empty .text-link {
  color: var(--ink);
  margin-top: 14px;
}
.inline-error {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bad-bg);
  color: var(--bad);
  font-size: 12.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-line;
  animation: rise-in 0.35s var(--ease);
}
.inline-error:empty {
  display: none;
}
.banner {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12.5px;
}

/* ---------- 全局提示 ---------- */
.notice {
  position: fixed;
  z-index: 60;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(90vw, 560px);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  padding: 11px 22px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 520;
  white-space: pre-line;
  animation: toast-in 0.45s var(--ease);
}
.notice.error {
  border-radius: 16px;
  color: var(--bad);
  background: #fff;
  border: 1px solid #f3d3cd;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
.boot-state {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.boot-state::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid var(--faint);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
#boot-retry {
  display: flex;
  margin: 30vh auto 0;
}
.sandbox-badge {
  position: fixed;
  z-index: 45;
  right: 16px;
  bottom: 16px;
  padding: 6px 14px;
  background: var(--warn-bg);
  border: 1px solid #efdcb4;
  border-radius: 999px;
  color: var(--warn);
  font-size: 11.5px;
  font-weight: 560;
  pointer-events: none;
}

/* ---------- 弹窗 ---------- */
dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  color: var(--ink);
  background: var(--surface);
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-lg);
}
dialog[open] {
  animation: dialog-in 0.45s var(--ease);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
dialog::backdrop {
  background: rgba(22, 22, 24, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
dialog[open]::backdrop {
  animation: fade-in 0.3s ease-out;
}
/* 关闭：复用打开动画反向播放 */
dialog.closing {
  animation: dialog-in 0.3s var(--ease) reverse forwards;
}
dialog.closing::backdrop {
  animation: fade-in 0.3s ease-in reverse forwards;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.dialog-heading h2 {
  overflow-wrap: anywhere;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  :root {
    --header-h: 84px;
  }
  .header {
    padding: env(safe-area-inset-top) 16px 0;
    gap: 8px;
  }
  .header nav a {
    padding: 6px 12px;
    font-size: 13px;
  }
  .account-button {
    max-width: 30%;
    padding: 5px;
    font-size: 12px;
  }
  .account-button::before {
    margin-right: 6px;
  }
  main {
    margin: 4px auto 40px;
    padding: 0 16px;
  }
  .page-heading {
    margin: 22px 0 20px;
  }
  .panel {
    padding: 22px;
  }
  input,
  textarea {
    font-size: 16px;
  }
  .notice {
    top: 72px;
  }
  .sandbox-badge {
    top: 70px;
    bottom: auto;
    right: 12px;
    font-size: 10.5px;
  }
  .orb {
    filter: blur(70px);
  }
  /* 手机端弹窗居中，上下留出可点击关闭的空白 */
  dialog {
    width: calc(100vw - 32px);
    max-width: none;
    max-height: calc(
      100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
    padding: 22px 18px;
    border-radius: 26px;
  }
  /* 弹窗打开时锁住页面，内部滑到尽头不会带动后面 */
  html:has(dialog[open]) {
    overflow: hidden;
  }
}
@media (max-width: 380px) {
  .header nav a {
    padding: 6px 9px;
    font-size: 12.5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
