/* ═══════════════════════════════════════════
   BASE — Reset, Typography, Scrollbar
═══════════════════════════════════════════ */

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

html {
  height: 100%;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* ── Scrollbar ── */
::-webkit-scrollbar        { width: 4px; height: 4px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border-strong); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Typography Resets ── */
h1, h2, h3, h4, h5, h6 { font-weight: 500; line-height: 1.3; }
p { line-height: 1.65; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: var(--text-primary); }

/* ── Focus Ring ── */
:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── Selection ── */
::selection {
  background: var(--accent-purple-dim);
  color: var(--text-primary);
}

/* ── Noise Overlay ── */
#noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ── Utility Classes ── */
.hide-mobile { /* controlled in mobile.css */ }
.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;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  user-select: none;
}
.badge-version { color: var(--accent-purple); border-color: var(--accent-purple-dim); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
}
.btn-primary:hover { background: #7c7ff7; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Icon Buttons ── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s var(--spring) both;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.toast.success { border-color: var(--accent-emerald); color: var(--text-positive); }
.toast.error { border-color: var(--accent-rose); color: var(--text-danger); }
.toast.fadeout { animation: toastOut 0.3s var(--ease) both; }
@keyframes toastIn  { from { opacity:0; transform:translateY(8px) scale(0.97); } to { opacity:1; transform:none; } }
@keyframes toastOut { to   { opacity:0; transform:translateY(-4px) scale(0.97); } }

/* ── Forms ── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 11px; font-weight: 500; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.form-input  { width: 100%; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border-default); border-radius: var(--r-md); color: var(--text-primary); font-size: 13px; transition: border-color var(--t-fast); }
.form-input:focus { outline: none; border-color: var(--accent-purple); }
.form-textarea { width: 100%; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border-default); border-radius: var(--r-md); color: var(--text-primary); font-size: 13px; resize: vertical; transition: border-color var(--t-fast); }
.form-textarea:focus { outline: none; border-color: var(--accent-purple); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Checkbox ── */
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; margin-top: 8px; }
.checkbox-label input[type="checkbox"] { accent-color: var(--accent-purple); width: 14px; height: 14px; }

/* ── KBD ── */
kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}
