@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600&family=Karla:wght@400;500;600;700&display=swap');

:root {
  --bg:         #160b0a;
  --bg-surface: #1f1311;
  --bg-raised:  #2a1b18;
  --bg-hover:   #34211d;
  --border:     #3d2722;
  --border-soft: #ffffff0d;

  --accent:       #d3293c;
  --accent-bright:#ff5a44;
  --accent-deep:  #841c28;
  --accent-dim:   #d3293c22;
  --accent-soft:  #d3293c44;
  --ember:        #f0a13c;

  --text:       #f2e8e3;
  --text-muted: #b4948c;
  --text-dim:   #6e5550;

  --online:  #6ebf80;
  --danger:  #ff5a44;
  --warning: #f0a13c;

  --font-display: 'Newsreader', Georgia, serif;
  --font-ui:      'Karla', system-ui, sans-serif;

  --radius:    5px;
  --radius-lg: 8px;

  --shadow-flat: 3px 3px 0 rgba(0,0,0,0.45);
  --shadow-sm:   0 2px 6px rgba(0,0,0,0.3);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

/* Several elements below set their own `display` (e.g. .error-text uses flex for
   icon+text layout). An author rule with the same specificity as the UA [hidden]
   rule wins by source order, so without this override, hidden elements with a
   display override would render anyway. This makes [hidden] always win. */
[hidden] { display: none !important; }

html {
  height: 100%;
  background: var(--bg);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { position: relative; isolation: isolate; }

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

::selection { background: var(--accent-soft); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-raised); border-radius: 3px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }

a { color: var(--accent-bright); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-soft); }

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

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 2px; }

code { font-family: 'SFMono-Regular', Consolas, monospace; background: var(--bg-raised); padding: 2px 6px; border-radius: 3px; font-size: 0.85em; }

.container { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ---------- Top nav ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.navbar .logo {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.navbar .logo .logo-accent { color: var(--accent-bright); font-style: normal; }
.navbar .logo svg { color: var(--accent-bright); }

.navbar nav { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.navbar nav a, .navbar nav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 11px;
  border-radius: var(--radius);
  border-bottom: 2px solid transparent;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.navbar nav a:hover { color: var(--text); text-decoration: none; }
.navbar nav a.active { color: var(--text); border-bottom-color: var(--accent-bright); }
.navbar nav a.nav-cta { color: #fff; background: var(--accent); border-bottom-color: transparent; }
.navbar nav a.nav-cta:hover { background: var(--accent-bright); }
.navbar nav a.nav-avatar-link { padding: 0; margin-left: 6px; border-bottom: none; }
.navbar .nav-label { display: inline; }

.navbar nav a, .navbar nav button { position: relative; }
.nav-badge {
  position: absolute; top: 2px; right: 0;
  background: var(--accent); color: #fff;
  font-size: 0.62rem; font-weight: 700; line-height: 1;
  min-width: 15px; height: 15px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 1px solid var(--bg-surface);
}

.nav-bell-wrap { position: relative; }
.nav-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; max-height: 420px; overflow-y: auto;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-flat); z-index: 60;
}
.nav-dropdown-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; font-size: 0.84rem; color: var(--text);
  border-bottom: 1px solid var(--border-soft);
}
.nav-dropdown-item:last-child { border-bottom: none; }
.nav-dropdown-item:hover { background: var(--bg-hover); text-decoration: none; }
.nav-dropdown-item.unread { background: var(--accent-dim); }
.nav-dropdown-empty { padding: 24px 14px; text-align: center; color: var(--text-dim); font-size: 0.84rem; }

@media (max-width: 640px) {
  .navbar { padding: 12px 14px; }
  .navbar .nav-label { display: none; }
  .navbar nav a, .navbar nav button { padding: 8px; }
  .nav-dropdown { width: 280px; right: -40px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn:hover { background: var(--bg-hover); border-color: #4a322c; }
.btn:active { transform: translate(1px, 1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff;
  box-shadow: 2px 2px 0 var(--accent-deep);
}
.btn-primary:hover { background: var(--accent-bright); }
.btn-primary:active { box-shadow: none; transform: translate(2px, 2px); }

.btn-danger { color: var(--danger); border-color: #8f2c22; background: #ff5a4414; }
.btn-danger:hover { background: #ff5a441f; }

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

.btn-icon { padding: 9px; }

.btn-sm { padding: 7px 13px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; font-size: 0.84rem; font-weight: 600; color: var(--text-muted); }
input, textarea, select {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-bright); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 5px; }
.error-text {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: #ffb3a8;
  margin-top: 12px; padding: 10px 12px;
  background: #ff5a4414; border: 1px solid #ff5a4440;
  border-radius: var(--radius);
}
.error-text svg { flex-shrink: 0; color: var(--accent-bright); }

/* ---------- Trait sliders (AI personality sliders) ----------
   Titles/values/descriptions are deliberately plain text, no badges or boxes -
   the slider itself is the only thing that should look "designed". */
.trait-field { margin-bottom: 26px; }
.trait-head { margin-bottom: 10px; }
.trait-head .trait-name { font-size: 0.92rem; color: var(--text); }
.trait-head .trait-value { font-size: 0.92rem; color: var(--text-dim); }

.trait-track-wrap { position: relative; padding: 8px 0 0; }
.trait-slider-row input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  outline: none;
  padding: 0;
  border: none;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--bg-raised) var(--fill, 50%));
}
.trait-slider-row input[type="range"]::-moz-range-track { background: var(--bg-raised); height: 6px; border-radius: 3px; border: none; }
.trait-slider-row input[type="range"]::-moz-range-progress { background: var(--accent); height: 6px; border-radius: 3px; }
.trait-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  cursor: pointer;
}
.trait-slider-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  cursor: pointer;
}
.trait-ticks { display: flex; justify-content: space-between; margin-top: 6px; padding: 0 1px; }
.trait-ticks span { width: 2px; height: 5px; background: var(--border); border-radius: 1px; }
.trait-endlabels { display: flex; justify-content: space-between; margin-top: 6px; }
.trait-endlabels span { font-size: 0.74rem; color: var(--text-dim); }
.trait-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 10px; min-height: 1.2em; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.card-hover { transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease); }
.card-hover:hover { border-color: var(--accent-soft); box-shadow: var(--shadow-flat); transform: translate(-2px, -2px); }

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { max-width: 400px; width: 100%; }
.auth-card .auth-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-card .auth-logo .logo { font-size: 1.5rem; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 26px; }

/* ---------- Avatar ---------- */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-raised);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 0.95rem;
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: 0.72rem; }
.avatar-lg { width: 76px; height: 76px; font-size: 1.5rem; border-radius: 10px; }
.avatar-xl { width: 104px; height: 104px; font-size: 2rem; border-radius: 12px; }
.avatar-ai { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent-bright); }

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.center { text-align: center; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fade-up 0.35s var(--ease) backwards; }

/* ---------- Rising embers (hero only, used once, sparingly) ---------- */
.embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.embers .ember {
  position: absolute;
  bottom: -10px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 6px 1px var(--ember);
  opacity: 0;
  animation: rise 7s ease-in infinite;
}
.embers .ember:nth-child(1) { left: 8%;  animation-delay: 0s;   background: var(--accent-bright); box-shadow: 0 0 6px 1px var(--accent-bright); }
.embers .ember:nth-child(2) { left: 22%; animation-delay: 1.6s; width: 3px; height: 3px; }
.embers .ember:nth-child(3) { left: 47%; animation-delay: 3.1s; }
.embers .ember:nth-child(4) { left: 68%; animation-delay: 0.9s; width: 3px; height: 3px; background: var(--accent-bright); box-shadow: 0 0 6px 1px var(--accent-bright); }
.embers .ember:nth-child(5) { left: 84%; animation-delay: 2.4s; }
.embers .ember:nth-child(6) { left: 35%; animation-delay: 4.4s; width: 3px; height: 3px; }
@keyframes rise {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.8); }
  8%   { opacity: 0.9; }
  55%  { opacity: 0.5; }
  100% { opacity: 0; transform: translate(6px, -220px) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .embers .ember { animation: none; opacity: 0; }
}

/* ---------- Toasts ---------- */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--border); border-left: 3px solid var(--online);
  color: var(--text); padding: 11px 18px; border-radius: var(--radius);
  font-size: 0.88rem; box-shadow: var(--shadow-flat);
  opacity: 0; transform: translateY(10px); transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--danger); color: #ffd0c8; }
.toast svg { color: var(--online); flex-shrink: 0; }
.toast.error svg { color: var(--danger); }

/* ---------- Loading ---------- */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent-bright); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-line, .skeleton-circle, .skeleton-card {
  background: linear-gradient(100deg, var(--bg-surface) 30%, var(--bg-raised) 50%, var(--bg-surface) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}
.skeleton-line { height: 14px; margin-bottom: 10px; width: 100%; }
.skeleton-line:nth-child(odd) { width: 85%; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skeleton-card { height: 90px; margin-bottom: 12px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty-state { text-align: center; color: var(--text-dim); padding: 56px 20px; font-size: 0.92rem; }
.empty-state .icon { color: var(--text-dim); margin-bottom: 10px; opacity: 0.7; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: var(--radius); background: var(--accent-dim); color: var(--accent-bright); text-transform: uppercase; letter-spacing: 0.03em; }
.badge-muted { background: var(--bg-raised); color: var(--text-muted); }

hr { border: none; border-top: 1px solid var(--border-soft); margin: 24px 0; }

.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider { position: absolute; inset: 0; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 999px; transition: background 0.2s var(--ease); }
.toggle-switch .slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--text-muted); border-radius: 50%; transition: transform 0.2s var(--ease), background 0.2s var(--ease); }
.toggle-switch input:checked + .slider { background: var(--accent); border-color: var(--accent-deep); }
.toggle-switch input:checked + .slider::before { transform: translateX(16px); background: #fff; }

.row-actions { display: flex; gap: 6px; align-items: center; }

/* ---------- Prose (blog posts, terms, privacy) ---------- */
.prose { font-size: 1rem; line-height: 1.7; }
.prose p { margin: 0 0 16px; }
.prose h2 { margin-top: 32px; font-size: 1.3rem; }
.prose a { text-decoration: underline; }
