/* Shared design tokens + base components for the React app and the preview page.
   Dark by default, follows the OS light/dark setting (NF-4). */

:root {
  color-scheme: dark;
  --bg: #0e1014;
  --bg-raised: #161920;
  --bg-sunken: #0a0c0f;
  --surface: #1c2029;
  --surface-hover: #242936;
  --border: #2a303c;
  --text: #e8eaf0;
  --text-muted: #9aa3b5;
  --text-faint: #6b7385;
  --accent: #7c6cff;
  --accent-hover: #9284ff;
  --accent-text: #ffffff;
  --accent-soft: rgba(124, 108, 255, 0.16);
  --ok: #3ccf8e;
  --warn: #f5b84a;
  --danger: #ff5c6c;
  --danger-soft: rgba(255, 92, 108, 0.14);
  --thumb-bg: #050608;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f6f9;
    --bg-raised: #ffffff;
    --bg-sunken: #eceef3;
    --surface: #ffffff;
    --surface-hover: #f0f1f6;
    --border: #dde1ea;
    --text: #161922;
    --text-muted: #5a6275;
    --text-faint: #8890a2;
    --accent: #5b4bea;
    --accent-hover: #4a3bd6;
    --accent-soft: rgba(91, 75, 234, 0.1);
    --danger-soft: rgba(220, 40, 60, 0.08);
    --shadow: 0 6px 24px rgba(20, 24, 40, 0.1);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; font-size: 14px;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.copied { border-color: var(--ok); color: var(--ok); }
.btn svg { width: 16px; height: 16px; flex: none; }

input[type=text], input[type=password], input[type=search], input[type=number], input[type=date],
select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-sunken); color: var(--text);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }

.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.error-text { color: var(--danger); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--danger); }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.copy-pair { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-pair .btn { flex: 1 1 0; min-width: 0; }

.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover; background: var(--surface); color: #fff; font-weight: 700; line-height: 1; overflow: hidden; }
.avatar-initials { letter-spacing: 0.02em; user-select: none; }

.url-fallback { margin-top: 8px; font-family: var(--mono); font-size: 13px; }
