/* ══════════════════════════════════════════
   THEME TOKENS
══════════════════════════════════════════ */
:root {
  --bg: #0e1015;
  --bg-accent: #13151b;
  --bg-elevated: #191c24;
  --bg-hover: #1f2330;
  --bg-muted: #1f2330;
  --card: #161920;
  --card-foreground: #f0f0f2;
  --card-highlight: rgba(255, 255, 255, 0.04);
  --popover: #191c24;
  --popover-foreground: #f0f0f2;
  --panel: #0e1015;
  --panel-strong: #191c24;
  --panel-hover: #1f2330;
  --chrome: rgba(14, 16, 21, 0.96);
  --chrome-strong: rgba(14, 16, 21, 0.98);
  --text: #d4d4d8;
  --text-strong: #f4f4f5;
  --chat-text: #d4d4d8;
  --muted: #838387;
  --muted-strong: #75757d;
  --muted-foreground: #838387;
  --border: #1e2028;
  --border-strong: #2e3040;
  --border-hover: #3e4050;
  --input: #1e2028;
  --ring: #ff5c5c;
  --accent: #ff5c5c;
  --accent-hover: #ff7070;
  --accent-muted: #ff5c5c;
  --accent-subtle: rgba(255, 92, 92, 0.1);
  --accent-foreground: #fafafa;
  --accent-glow: rgba(255, 92, 92, 0.2);
  --primary: #ff5c5c;
  --primary-foreground: #ffffff;
  --secondary: #161920;
  --secondary-foreground: #f0f0f2;
  --accent-2: #14b8a6;
  --accent-2-muted: rgba(20, 184, 166, 0.7);
  --accent-2-subtle: rgba(20, 184, 166, 0.1);
  --ok: #22c55e;
  --ok-muted: rgba(34, 197, 94, 0.75);
  --ok-subtle: rgba(34, 197, 94, 0.08);
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --warn: #f59e0b;
  --warn-muted: rgba(245, 158, 11, 0.75);
  --warn-subtle: rgba(245, 158, 11, 0.08);
  --danger: #ef4444;
  --danger-muted: rgba(239, 68, 68, 0.75);
  --danger-subtle: rgba(239, 68, 68, 0.08);
  --info: #3b82f6;
  --focus: rgba(255, 92, 92, 0.2);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 3px color-mix(in srgb, var(--ring) 80%, transparent);
  --focus-glow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ring), 0 0 16px var(--accent-glow);
  --grid-line: rgba(255, 255, 255, 0.03);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: var(--font-body);
  --font-weight-bold: 750;
  --font-weight-semibold: 650;
  --font-weight-medium: 550;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 32px 64px rgba(0, 0, 0, 0.6);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.25), inset 0 -1px 2px 0 rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 24px var(--accent-glow), 0 0 48px rgba(255, 92, 92, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --radius: 12px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 100ms;
  --duration-normal: 180ms;
  --duration-slow: 300ms;
  color-scheme: dark;
}

:root[data-theme-mode="light"] {
  --bg: #f8f9fa;
  --bg-accent: #f1f3f5;
  --bg-elevated: #ffffff;
  --bg-hover: #eceef0;
  --bg-muted: #eceef0;
  --card: #ffffff;
  --card-foreground: #1a1a1e;
  --card-highlight: rgba(0, 0, 0, 0.02);
  --popover: #ffffff;
  --popover-foreground: #1a1a1e;
  --panel: #f8f9fa;
  --panel-strong: #f1f3f5;
  --panel-hover: #e6e8eb;
  --chrome: rgba(248, 249, 250, 0.96);
  --chrome-strong: rgba(248, 249, 250, 0.98);
  --text: #3c3c43;
  --text-strong: #1a1a1e;
  --chat-text: #3c3c43;
  --muted: #6e6e73;
  --muted-strong: #545458;
  --muted-foreground: #6e6e73;
  --border: #e5e5ea;
  --border-strong: #d1d1d6;
  --border-hover: #aeaeb2;
  --input: #e5e5ea;
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-muted: #dc2626;
  --accent-subtle: rgba(220, 38, 38, 0.08);
  --accent-foreground: #ffffff;
  --accent-glow: rgba(220, 38, 38, 0.1);
  --primary: #dc2626;
  --primary-foreground: #ffffff;
  --secondary: #f1f3f5;
  --secondary-foreground: #3c3c43;
  --accent-2: #0d9488;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --focus: rgba(220, 38, 38, 0.15);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 3px color-mix(in srgb, var(--ring) 70%, transparent);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.1);
  color-scheme: light;
}

:root[data-theme="openknot"] {
  --ring: #e5243b;
  --accent: #e5243b;
  --accent-hover: #f03e52;
  --primary: #e5243b;
  --bg: #080808;
  --bg-accent: #0d0d0f;
  --bg-elevated: #141416;
  --bg-hover: #1a1a1e;
  --card: #111113;
  --border: #1a1a1e;
  --text: #e0e0e2;
  --text-strong: #f5f5f7;
  --accent-subtle: rgba(229, 36, 59, 0.1);
  --accent-glow: rgba(229, 36, 59, 0.2);
}

:root[data-theme="dash"] {
  --ring: #b47840;
  --accent: #b47840;
  --accent-hover: #c8885a;
  --primary: #b47840;
  --bg: #1a1210;
  --bg-accent: #201816;
  --bg-elevated: #28201c;
  --card: #221a16;
  --text: #d8c8b8;
  --text-strong: #f0e4da;
  --border: #302418;
  --accent-subtle: rgba(180, 120, 64, 0.1);
  --accent-glow: rgba(180, 120, 64, 0.2);
}

/* ══════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font: var(--font-weight-medium) 14px/1.55 var(--font-body);
  letter-spacing: -0.01em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--duration-normal), color var(--duration-normal);
}

::selection {
  background: var(--accent-subtle);
  color: var(--text-strong);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ══════════════════════════════════════════
   VIEWS SYSTEM
══════════════════════════════════════════ */
.view {
  display: none;
}

.view.active {
  display: flex;
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0.78rem 1.6rem;
  border-radius: var(--radius-md);
  font: var(--font-weight-semibold) 0.93rem/1 var(--font-body);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  background: var(--secondary);
  color: var(--secondary-foreground);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

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

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.84rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-danger {
  background: var(--danger-subtle);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

.btn-social {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 500;
}

.btn-social:hover {
  background: var(--bg-hover);
}

/* ══════════════════════════════════════════
   DIVIDER
══════════════════════════════════════════ */
.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.4rem 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ══════════════════════════════════════════
   TOAST / ALERT
══════════════════════════════════════════ */
.form-alert {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
}

.form-alert.show {
  display: flex;
}

.form-alert.ok {
  background: var(--ok-subtle);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 20%, transparent);
}

.form-alert.err {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
}

#toast {
  position: fixed;
  top: 20px;
  right: 20px;
  transform: translateX(20px);
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text-strong);
  border-radius: var(--radius-full);
  padding: 10px 20px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.25s var(--ease-spring);
  z-index: 400;
  pointer-events: none;
  white-space: nowrap;
  max-width: 300px;
  word-wrap: break-word;
}

/* ══════════════════════════════════════════
   THEME SWITCHER
══════════════════════════════════════════ */
.theme-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--chrome);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px;
  display: flex;
  flex-direction: row;
  gap: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.theme-btn {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.theme-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.theme-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ══════════════════════════════════════════
   STATUS BADGE
══════════════════════════════════════════ */
.status-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  color: white;
}

.status-badge.success { background: #10b981; }
.status-badge.pending { background: #f59e0b; }
.status-badge.warning { background: #f59e0b; }
.status-badge.error   { background: #ef4444; }

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: rise 0.25s var(--ease-spring);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.5rem;
}

.modal-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ══════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════ */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.stagger-1 {
  animation: rise 0.35s 0.05s var(--ease-spring) both;
}

.stagger-2 {
  animation: rise 0.35s 0.1s var(--ease-spring) both;
}

.stagger-3 {
  animation: rise 0.35s 0.15s var(--ease-spring) both;
}

.stagger-4 {
  animation: rise 0.35s 0.2s var(--ease-spring) both;
}