/* ==========================================================================
   照片直播系统 · 基础样式
   设计取色、间距、组件统一在此定义，观众端与后台共用。
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow: 0 6px 24px rgba(0, 0, 0, .12);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .2);

  --ease: cubic-bezier(.22, .61, .36, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ---------- 深色（观众端默认：更突出照片） ---------- */
[data-theme="dark"] {
  --bg: #0a0b0e;
  --bg-elevated: #101216;
  --surface: #16181d;
  --surface-2: #1e2127;
  --surface-3: #262a31;
  --text: #f3f4f6;
  --text-2: #a8adb8;
  --text-3: #6b7280;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);
  --accent: #ff5a7a;
  --accent-soft: rgba(255, 90, 122, .14);
  --accent-text: #fff;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --danger: #f2545b;
  --overlay: rgba(0, 0, 0, .82);
  --skeleton: linear-gradient(90deg, #16181d 25%, #1e2127 37%, #16181d 63%);
}

/* ---------- 浅色（后台默认） ---------- */
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --text: #14161a;
  --text-2: #626977;
  --text-3: #9aa1ad;
  --border: rgba(16, 20, 28, .1);
  --border-strong: rgba(16, 20, 28, .18);
  --accent: #e0345c;
  --accent-soft: rgba(224, 52, 92, .1);
  --accent-text: #fff;
  --ok: #12a150;
  --warn: #c47f0a;
  --danger: #d93a41;
  --overlay: rgba(12, 14, 18, .72);
  --skeleton: linear-gradient(90deg, #eef0f3 25%, #f7f8fa 37%, #eef0f3 63%);
}

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

/* hidden 属性必须永远生效：很多组件自带 display，会覆盖 UA 的 [hidden]{display:none}，
   导致「已经隐藏的元素仍然占位/遮挡页面」。这条兜底规则不可删除。 */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

/* iOS 上 font-size < 16px 的输入框会触发聚焦自动放大 */
input, select, textarea { font-size: 16px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .1s var(--ease), opacity .16s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  box-shadow: 0 4px 14px rgba(224, 52, 92, .26);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: transparent; border-color: var(--border-strong); color: var(--danger); }
.btn-danger:hover { background: rgba(217, 58, 65, .1); }

.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { min-width: 40px; padding: 0 10px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.field-hint { margin-top: 6px; font-size: 12px; color: var(--text-3); line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 44px; height: 26px; flex: none;
  background: var(--surface-3); border-radius: var(--radius-full);
  transition: background .2s var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch-text { font-size: 14px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-pad { padding: 18px; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px; font-weight: 500; line-height: 1;
}
.badge-ok { background: rgba(18, 161, 80, .12); color: var(--ok); }
.badge-warn { background: rgba(196, 127, 10, .14); color: var(--warn); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--overlay);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease);
}
.modal-mask.is-open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  transform: translateY(14px);
  transition: transform .26s var(--ease);
  -webkit-overflow-scrolling: touch;
}
.modal-mask.is-open .modal { transform: none; }

@media (min-width: 720px) {
  .modal-mask { align-items: center; }
  .modal { border-radius: var(--radius-lg); padding: 24px; max-height: 84vh; }
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }

/* ---------- 提示条 ---------- */
.toast-wrap {
  position: fixed; left: 50%; top: calc(16px + var(--safe-top));
  transform: translateX(-50%); z-index: 1200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius-full);
  background: rgba(20, 22, 26, .94);
  color: #fff;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn .26s var(--ease);
}
[data-theme="light"] .toast { background: rgba(28, 30, 36, .94); }
.toast.is-out { animation: toastOut .22s var(--ease) forwards; }
.toast-err { background: rgba(200, 42, 50, .95); }
.toast-ok { background: rgba(16, 140, 72, .95); }

@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- 空状态 / 加载 ---------- */
.empty { padding: 56px 20px; text-align: center; color: var(--text-3); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .55; }
.empty-title { font-size: 15px; color: var(--text-2); margin-bottom: 4px; }
.empty-desc { font-size: 13px; }

.spinner {
  width: 20px; height: 20px; flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: var(--skeleton);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- 工具类 ---------- */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.bold { font-weight: 600; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

/* 图标按钮命中区不小于 44px，符合移动端可点击性标准 */
.tap-target { position: relative; }
.tap-target::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: max(100%, 44px); height: max(100%, 44px);
  transform: translate(-50%, -50%);
}
