*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(circle at 12% 8%, var(--blob-a), transparent 42%),
    radial-gradient(circle at 88% 78%, var(--blob-c), transparent 46%);
  transition: background-color .45s ease, color .45s ease;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- 环境氛围层 ---------- */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient-blob { position: absolute; border-radius: 50%; filter: blur(48px); opacity: .9; }
.blob-a { width: 46vw; height: 46vw; left: -12vw; top: -14vw; background: var(--blob-a); animation: drift-a 34s ease-in-out infinite alternate; }
.blob-b { width: 38vw; height: 38vw; right: -10vw; top: 22vh; background: var(--blob-b); animation: drift-b 42s ease-in-out infinite alternate; }
.blob-c { width: 34vw; height: 34vw; left: 28vw; bottom: -18vw; background: var(--blob-c); animation: drift-c 38s ease-in-out infinite alternate; }
.ambient-grain {
  position: absolute; inset: 0; opacity: var(--grain-opacity); mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.14'/%3E%3C/svg%3E");
}
:root[data-theme="night"] .ambient-grain { mix-blend-mode: screen; opacity: .08; }

.theme-ripple {
  position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), var(--ripple-color, var(--accent)) 0%, transparent 0%);
}
.theme-ripple.is-active { animation: ink-ripple .74s cubic-bezier(.22, .9, .25, 1) forwards; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 60; height: var(--topbar-h);
  display: flex; align-items: center; gap: 30px; padding: 0 clamp(20px, 4vw, 58px);
  background: var(--surface); backdrop-filter: blur(18px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  transition: background-color .4s ease, transform .35s ease, opacity .35s ease;
}
.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-seal {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px;
  background: var(--accent); color: var(--surface-solid); font-size: 22px; line-height: 1;
  box-shadow: 0 6px 18px var(--accent-soft); transform: rotate(-4deg);
  transition: transform .4s cubic-bezier(.2, 1.4, .4, 1);
}
.brand:hover .brand-seal { transform: rotate(0deg) scale(1.08); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy b { font-size: 20px; letter-spacing: .16em; }
.brand-copy small { font-family: var(--sans); font-size: 9px; letter-spacing: .22em; color: var(--ink-faint); margin-top: 3px; }
.main-nav { display: flex; gap: 6px; }
.main-nav a {
  position: relative; padding: 9px 16px; border-radius: 999px; font-size: 14.5px; color: var(--ink-soft);
  transition: color .25s ease, background .25s ease;
}
.main-nav a:hover { color: var(--ink); background: var(--surface-2); }
.main-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-box {
  display: flex; align-items: center; gap: 9px; padding: 0 12px; height: 38px; min-width: 220px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  transition: border-color .25s ease, box-shadow .25s ease, min-width .3s ease;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); min-width: 260px; }
.search-box svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-faint); stroke-width: 1.8; stroke-linecap: round; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 13.5px; font-family: var(--sans); }
.search-box input::placeholder { color: var(--ink-faint); }
.search-box kbd { font-family: var(--sans); font-size: 10px; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
  transition: transform .22s ease, color .22s ease, background .22s ease, border-color .22s ease;
}
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { transform: translateY(-2px) rotate(-4deg); color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-family: var(--sans);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease, border-color .22s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: var(--accent); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--accent); color: var(--surface-solid); border-color: var(--accent); font-weight: 700; }
.btn-primary:hover { box-shadow: 0 10px 24px var(--accent-soft); }
.btn-small { padding: 8px 14px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 12px; }
.btn-text { border: 0; background: none; color: var(--ink-faint); font-size: 12.5px; margin-top: 14px; width: 100%; }
.btn-text:hover { color: var(--accent); transform: none; box-shadow: none; }

.top-progress { position: fixed; top: var(--topbar-h); left: 0; right: 0; height: 2px; z-index: 61; background: transparent; }
.top-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .18s ease; box-shadow: 0 0 10px var(--accent); }

main { position: relative; z-index: 1; padding-top: var(--topbar-h); }
.view { min-height: calc(100vh - var(--topbar-h)); transition: opacity .35s ease; }
.view-enter { animation: view-in .5s cubic-bezier(.2, .8, .25, 1) both; }

/* ---------- 表单控件 ---------- */
.field { display: flex; flex-direction: column; gap: 7px; font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft); }
.field > span { display: flex; justify-content: space-between; align-items: center; }
.field output { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.field input[type="text"], .field input[type="password"], .field input:not([type]), .field select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); outline: 0; font-size: 13px; font-family: var(--sans);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 99px; background: var(--line); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface-solid); box-shadow: 0 2px 8px var(--accent-soft); transition: transform .18s ease; }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface-solid); }
.check-field { display: flex; align-items: center; gap: 9px; font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft); }
.check-field input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- 提示 / 加载 / 弹窗 ---------- */
.toast-stack { position: fixed; right: 22px; bottom: 24px; z-index: 120; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 210px; max-width: 340px; padding: 13px 17px; border-radius: 14px;
  background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-family: var(--sans); font-size: 13px; display: flex; align-items: center; gap: 10px;
  animation: toast-in .35s cubic-bezier(.2, 1.3, .4, 1) both;
}
.toast::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.toast.error::before { background: #d35046; }
.toast.success::before { background: #4d9a71; }
.toast.leaving { animation: toast-out .3s ease forwards; }

.loading-overlay {
  position: fixed; inset: 0; z-index: 110; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg); opacity: .96;
}
.loading-overlay p { font-size: 14px; letter-spacing: .18em; color: var(--ink-soft); margin: 0; }
.loader-ring { width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.loader-bar { width: 200px; height: 3px; border-radius: 9px; background: var(--line); overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.modal-scrim { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(20, 18, 15, .42); backdrop-filter: blur(6px); padding: 20px; animation: fade-in .25s ease both; }
.modal { position: relative; width: min(420px, 100%); padding: 34px 34px 26px; border-radius: var(--radius-lg); background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow); animation: modal-in .38s cubic-bezier(.2, 1.2, .35, 1) both; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal-seal { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--accent); color: var(--surface-solid); font-size: 25px; transform: rotate(-5deg); margin-bottom: 16px; }
.modal h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: .08em; }
.modal-sub { margin: 0 0 22px; font-family: var(--sans); font-size: 12.5px; color: var(--ink-faint); }
.modal form { display: flex; flex-direction: column; gap: 15px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { flex: 1; padding: 8px; border-radius: 999px; font-family: var(--sans); font-size: 13px; color: var(--ink-soft); transition: all .22s ease; }
.tabs button.active { background: var(--accent); color: var(--surface-solid); font-weight: 700; }
.form-error { min-height: 0; margin: 0; font-family: var(--sans); font-size: 12px; color: #cf4b40; }
.form-error:empty { display: none; }

.offline-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 115; text-align: center; padding: 8px; font-family: var(--sans); font-size: 12px; background: #b4493e; color: #fff; }
html.is-offline .offline-banner { display: block !important; }

@media (max-width: 880px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .brand-copy small, .search-box kbd { display: none; }
  .search-box { min-width: 120px; }
  .main-nav a { padding: 8px 10px; font-size: 13px; }
  .btn-ghost { padding: 8px 12px; font-size: 12px; }
}
@media (max-width: 620px) {
  .main-nav { display: none; }
  .search-box { min-width: 44px; width: 44px; padding: 0 11px; }
  .search-box:focus-within { position: absolute; left: 12px; right: 12px; width: auto; min-width: 0; z-index: 2; background: var(--surface-solid); }
  .search-box input { opacity: 0; }
  .search-box:focus-within input { opacity: 1; }
}
