/**
 * base.css —— 重置、基础排版与跨端通用组件（不含布局）
 * 明亮主题：浅紫白背景 + 纯白卡片 + 深墨紫文字
 */

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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(109, 74, 255, 0.14), transparent 62%),
    radial-gradient(760px 460px at 96% 4%, rgba(143, 116, 255, 0.12), transparent 58%),
    radial-gradient(700px 520px at 60% 108%, rgba(56, 189, 248, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
  color: var(--text-0);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

h1 { font-size: var(--fs-display); font-weight: 700; letter-spacing: 0.4px; }
h2 { font-size: var(--fs-h2); font-weight: 650; letter-spacing: 0.2px; }

a {
  color: var(--brand);
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

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

::selection {
  background: var(--brand-soft);
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card--flat {
  box-shadow: none;
}

.card h2 {
  margin-bottom: 10px;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-btn);
  padding: 13px 22px;
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.btn--primary {
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand) 52%, var(--brand-deep) 100%);
  color: var(--on-brand);
  box-shadow: var(--shadow-brand);
}

.btn--primary:hover:not([disabled]) {
  box-shadow: var(--shadow-brand-lg);
  transform: translateY(-1px);
}

.btn--ghost {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: var(--shadow-xs);
}

.btn--ghost:hover:not([disabled]) {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-softer);
}

.btn--quiet {
  background: var(--bg-soft);
  color: var(--text-1);
}

.btn--quiet:hover:not([disabled]) {
  background: var(--brand-soft);
  color: var(--brand);
}

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 8px 14px;
  font-size: var(--fs-note);
  border-radius: var(--r-sm);
}

.btn:active:not([disabled]) {
  transform: translateY(1px);
  box-shadow: var(--shadow-xs);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* 顶部 / 卡片里的小药丸按钮 */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--text-1);
  font-size: var(--fs-note);
  font-weight: 500;
  line-height: 1.2;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.pill:hover:not([disabled]) {
  border-color: var(--line);
  background: var(--bg-card-hover);
  color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pill:active:not([disabled]) {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.pill--accent {
  background: linear-gradient(135deg, var(--brand-light), var(--brand-deep));
  border-color: transparent;
  color: var(--on-brand);
  font-weight: 600;
  box-shadow: var(--shadow-brand);
}

.pill--accent:hover:not([disabled]) {
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand-light), var(--brand-deep));
  box-shadow: var(--shadow-brand-lg);
}

.pill--ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}

.pill--ghost:hover:not([disabled]) {
  background: var(--bg-soft);
  color: var(--text-1);
  box-shadow: none;
  transform: none;
}

.pill--user {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-0);
  font-weight: 600;
}

/* 只有图标的窄版药丸（手机端顶栏省空间） */
.pill--icon {
  padding: 7px 10px;
  font-size: 15px;
  line-height: 1;
  flex: 0 0 auto;
}

/* 顶栏品牌文字：过长时省略号，避免挤掉右侧按钮 */
.topbar__brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: var(--fs-tiny);
  font-weight: 600;
  line-height: 1.5;
}

.muted {
  color: var(--text-2);
  font-size: var(--fs-note);
}

/* #app 只是逻辑容器：透明化后，顶栏 / 侧边栏 / 主内容才直接参与 body 的网格 */
.app {
  display: contents;
}

/* 启动动画与错误页在电脑端跨越整个网格 */
html[data-shell='desktop'] .boot {
  grid-area: 1 / 1 / -1 / -1;
}

.center {
  text-align: center;
}

/* ---------- 启动期占位 ---------- */

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
}

.boot__disc {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--brand), var(--brand-light), var(--brand-deep), var(--brand));
  box-shadow: var(--shadow-brand-lg);
  animation: spin 3.2s linear infinite;
}

.boot__text {
  color: var(--text-2);
  font-size: var(--fs-note);
  letter-spacing: 1px;
}

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

/* ---------- 四步进度条 ---------- */

.steps {
  display: flex;
  gap: 8px;
}

.step {
  flex: 1;
  text-align: center;
  font-size: var(--fs-tiny);
  color: var(--text-2);
}

.step__bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(28, 23, 52, 0.08);
  margin-bottom: 8px;
  transition: background var(--dur) var(--ease);
}

.step--done .step__bar { background: var(--ok); }
.step--done { color: var(--ok); }
.step--current .step__bar { background: var(--brand); box-shadow: 0 2px 8px rgba(109, 74, 255, 0.4); }
.step--current { color: var(--brand-deep); font-weight: 600; }

/* ---------- 表单 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: var(--gap);
}

.field__label {
  font-size: var(--fs-note);
  color: var(--text-1);
  font-weight: 600;
}

.field__hint {
  font-size: var(--fs-tiny);
  color: var(--text-2);
  line-height: 1.6;
}

.field__hint--ok { color: var(--ok); }
.field__hint--warn { color: var(--warn); }

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line-soft);
  background: var(--bg-input);
  color: var(--text-0);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.input::placeholder { color: var(--text-2); }

.input:hover { border-color: var(--line); }

.input:focus {
  outline: none;
  background: var(--bg-card);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.input--code {
  text-align: center;
  font-size: 26px;
  letter-spacing: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 14px 10px 14px 22px;
}

select.input { appearance: none; background-image: none; }

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: var(--fs-note);
  color: var(--text-1);
}

.switch input {
  appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(28, 23, 52, 0.14);
  border: 0;
  position: relative;
  transition: background var(--dur) var(--ease);
  flex: 0 0 auto;
}

.switch input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur) var(--ease);
}

.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(20px); }

/* ---------- 登录 / 注册 ---------- */

.auth__disc {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--brand), var(--brand-light), var(--brand-deep), var(--brand));
  box-shadow: var(--shadow-brand-lg);
  animation: spin 12s linear infinite;
}

.auth__title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: 0.4px;
}

.auth__sub {
  color: var(--text-1);
  font-size: var(--fs-note);
  margin-top: 8px;
  line-height: 1.7;
}

.auth__desc {
  color: var(--text-2);
  font-size: var(--fs-tiny);
  margin-top: 12px;
  line-height: 1.8;
}

.auth__stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--gap);
  font-size: var(--fs-tiny);
  color: var(--text-2);
}

.auth__step { white-space: nowrap; }
.auth__step--active { color: var(--brand-deep); font-weight: 600; }
.auth__step--done { color: var(--ok); }

.auth__step-line {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--line-soft);
}

.auth__msg {
  margin-bottom: var(--gap);
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-note);
  line-height: 1.6;
  border: 1px solid transparent;
}

.auth__msg--error { background: var(--danger-soft); border-color: rgba(224, 74, 79, 0.3); color: #a52328; }
.auth__msg--info { background: var(--brand-soft); border-color: var(--line); color: var(--brand-deep); }
.auth__msg--ok { background: var(--ok-soft); border-color: rgba(15, 157, 112, 0.3); color: #0a6b4c; }

.auth__row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.auth__row .btn { flex: 1; }

.auth__link {
  display: block;
  margin: var(--gap) auto 0;
  color: var(--text-2);
  font-size: var(--fs-note);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth__link:hover { color: var(--brand); }

.auth__legal {
  margin-top: var(--gap-sm);
  line-height: 1.7;
}

/* 未登录时隐藏导航（登录页整屏展示） */
html[data-authed='false'] .tabbar {
  display: none !important;
}

html[data-authed='false'] body {
  padding-bottom: 0;
}

/* ---------- 后台入口（未登录）：整屏专注登录，外壳导航全部让位 ---------- */
/* #/admin 是后台自己的入口，未登录时不再借用前台登录页，也不需要顶栏与底栏 */

html[data-route='admin'][data-authed='false'] .topbar,
html[data-route='admin'][data-authed='false'] .tabbar {
  display: none !important;
}

html[data-route='admin'][data-authed='false'] body {
  padding-bottom: 0;
}

/* 高度只交给 .main 一处置 100vh 并居中：若 .auth 也设 100vh，会和 .main 的内边距叠加出滚动条 */
html[data-route='admin'][data-authed='false'] .main {
  min-height: 100vh;
  justify-content: center;
  align-content: center;
}

html[data-route='admin'][data-authed='false'] .auth {
  min-height: auto;
}

/* ---------- 管理后台 ---------- */

.admin {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.admin__title h1 { font-size: var(--fs-title); }

.admin__card { display: flex; flex-direction: column; }

.admin__head { margin-bottom: var(--gap); }
.admin__head h2 { font-size: var(--fs-h2); }
.admin__head .muted { margin-top: 6px; line-height: 1.7; }

.admin__grid {
  display: grid;
  gap: var(--gap-sm) var(--gap);
  grid-template-columns: 1fr;
}

.admin__grid--two { grid-template-columns: 1fr; }

.admin__grid .field { margin-bottom: 0; }

.admin__stat {
  padding: 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-soft);
}

.admin__stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-deep);
  line-height: 1.3;
}

.admin__stat-label {
  font-size: var(--fs-tiny);
  color: var(--text-2);
  margin-top: 2px;
}

.admin__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  align-items: center;
  margin-top: var(--gap);
}

.admin__list {
  display: flex;
  flex-direction: column;
  margin-top: var(--gap);
}

.admin__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.admin__row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.admin__row-title {
  font-size: var(--fs-note);
  color: var(--text-0);
  word-break: break-all;
}

.tag--approved { background: var(--ok-soft); color: var(--ok); }
.tag--pending { background: var(--warn-soft); color: var(--warn); }
.tag--blocked { background: var(--danger-soft); color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
