:root {
  --bg-0: #08090A;
  --bg-1: #0F1012;
  --bg-2: #16171A;
  --bg-3: #1C1D21;
  --bg-4: #24262B;
  --border-1: #26272C;
  --border-2: #33353B;
  --text-1: #F5F5F7;
  --text-2: #A8A8AE;
  --text-3: #6B6B72;
  --text-4: #48484E;
  --accent: #A78BFA;
  --accent-2: #C4B5FD;
  --accent-glow: rgba(167, 139, 250, 0.12);
  --gold: #D4B896;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --info: #60A5FA;
  --font-ui: 'Onest', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Instrument Serif', 'Songti SC', serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg-0);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  background-image:
    radial-gradient(ellipse 60% 50% at 20% 0%, rgba(167, 139, 250, 0.08), transparent 60%),
    radial-gradient(ellipse 80% 60% at 80% 100%, rgba(212, 184, 150, 0.04), transparent 60%);
}

.h-serif { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; }
.num { font-family: var(--font-mono); font-feature-settings: "tnum"; letter-spacing: -0.02em; }

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--text-1); color: var(--bg-0); }
.btn-primary:hover { background: #fff; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: var(--bg-3); color: var(--text-1); border: 0.5px solid var(--border-2); }
.btn-ghost:hover { background: var(--bg-4); }
.btn-accent {
  background: linear-gradient(135deg, var(--accent), #7C3AED); color: #fff;
  box-shadow: 0 4px 20px -4px rgba(167, 139, 250, 0.4);
}
.btn-block { width: 100%; padding: 14px; font-size: 16px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 8px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500; }
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 0.5px solid var(--border-1);
  border-radius: 12px;
  color: var(--text-1);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus { border-color: var(--accent); background: var(--bg-3); }
.input::placeholder { color: var(--text-4); }

.alert {
  padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert-error { background: rgba(248, 113, 113, 0.1); border: 0.5px solid rgba(248, 113, 113, 0.3); color: #FCA5A5; }
.alert-success { background: rgba(52, 211, 153, 0.1); border: 0.5px solid rgba(52, 211, 153, 0.3); color: #6EE7B7; }
.alert-info { background: rgba(96, 165, 250, 0.1); border: 0.5px solid rgba(96, 165, 250, 0.3); color: #93C5FD; }

.toast {
  position: fixed; top: 24px; left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg-3); border: 0.5px solid var(--border-2);
  padding: 10px 16px; border-radius: 100px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; transition: all 0.3s;
  z-index: 2000; pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.error svg { color: var(--danger); }
.toast.success svg { color: var(--success); }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.switch {
  position: relative;
  width: 46px; height: 28px;
  background: var(--bg-4);
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.25s;
  flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px;
  background: #fff; border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }
.switch.saving { opacity: 0.5; pointer-events: none; }

.trash-list { display: flex; flex-direction: column; }
.trash-cell {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--border-1);
}
.trash-cell:last-child { border-bottom: none; }
.tc-thumb {
  width: 44px; height: 44px; border-radius: 8px;
  overflow: hidden; background: var(--bg-3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.tc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tc-thumb svg { width: 20px; height: 20px; color: var(--text-3); }
.tc-info { flex: 1; min-width: 0; }
.tc-name {
  font-size: 13px; font-weight: 500;
  color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-meta {
  font-size: 11px; color: var(--text-3);
  margin-top: 2px;
}
.tc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.tc-btn {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px; font-weight: 500;
  border: 0.5px solid var(--border-2);
  background: var(--bg-3); color: var(--text-1);
  cursor: pointer; font-family: inherit;
}
.tc-btn:active { transform: scale(0.96); }
.tc-restore { color: var(--success); border-color: rgba(52, 211, 153, 0.3); }
.tc-purge { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
