:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e7eaf3;
  --border: #e2e5ef;
  --border-strong: #c9cedd;
  --text: #171a26;
  --text-2: #4b5168;
  --text-3: #8389a0;
  --accent: #6d4aff;
  --accent-2: #00c2ff;
  --accent-soft: #efeaff;
  --accent-text: #ffffff;
  --danger: #e5484d;
  --success: #12a594;
  --warning: #f5a524;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, .06), 0 1px 3px rgba(20, 22, 40, .06);
  --shadow: 0 6px 24px rgba(20, 22, 40, .08), 0 2px 6px rgba(20, 22, 40, .05);
  --shadow-lg: 0 24px 60px rgba(20, 22, 40, .18), 0 6px 16px rgba(20, 22, 40, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gradient: linear-gradient(135deg, #6d4aff 0%, #3b82f6 55%, #00c2ff 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1018; --surface: #161925; --surface-2: #1d2130; --surface-3: #262b3d;
    --border: #262b3c; --border-strong: #3a4057; --text: #eef0f7; --text-2: #b4b9cc; --text-3: #7c829a;
    --accent-soft: #2a2350; --shadow: 0 6px 24px rgba(0,0,0,.4); --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1018; --surface: #161925; --surface-2: #1d2130; --surface-3: #262b3d;
  --border: #262b3c; --border-strong: #3a4057; --text: #eef0f7; --text-2: #b4b9cc; --text-3: #7c829a;
  --accent-soft: #2a2350; --shadow: 0 6px 24px rgba(0,0,0,.4); --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gradient { background: var(--gradient); border: 0; color: #fff; box-shadow: 0 6px 18px rgba(109,74,255,.35); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.icon-btn { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; flex: none; }

.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
label.field { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.muted { color: var(--text-3); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--gradient); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(109,74,255,.4); }
.brand-mark svg { width: 18px; height: 18px; color: #fff; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 9999; pointer-events: none; }
.toast { background: #1b1e2c; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; animation: toastIn .25s ease; pointer-events: auto; max-width: min(520px, 90vw); }
.toast.error { background: var(--danger); }
.toast.success { background: #0f8a7c; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 14, 24, .45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 1000; padding: 16px; animation: fadeIn .15s ease; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px; animation: popIn .2s cubic-bezier(.2,.9,.3,1.2); }
.modal.wide { width: min(880px, 100%); }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(6px); } }

.menu { position: fixed; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 1100; animation: fadeIn .1s ease; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; color: var(--text); }
.menu button:hover { background: var(--surface-2); }
.menu button .kbd { margin-left: auto; color: var(--text-3); font-size: 12px; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.menu .menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 6px 10px 2px; }

.kbd-chip { display: inline-block; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; color: var(--text-2); background: var(--surface-2); font-family: ui-monospace, monospace; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
