:root {
  --bg: #0b1020;
  --bg-grad-1: #141b34;
  --bg-grad-2: #0b1020;
  --surface: rgba(30, 41, 70, 0.55);
  --card: rgba(26, 33, 58, 0.7);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.32);
  --text: #eef2ff;
  --text-muted: #9aa6c4;
  --primary: #6d6cf0;
  --primary-2: #8b7cf6;
  --primary-hover: #5b5ae6;
  --danger: #f0556b;
  --success: #34d399;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 6px 18px -6px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(109, 108, 240, 0.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 124, 246, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(56, 189, 248, 0.12), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 0.4rem;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff; box-shadow: 0 8px 20px -8px rgba(109, 108, 240, 0.8);
}
.btn-primary:hover { box-shadow: 0 10px 26px -8px rgba(109, 108, 240, 0.95); transform: translateY(-1px); }
.btn-ghost { background: rgba(148, 163, 184, 0.07); color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: rgba(148, 163, 184, 0.14); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: rgba(240, 85, 107, 0.12); border-color: var(--danger); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; border-radius: 8px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.02em; }
.brand-mark {
  display: grid; place-items: center;
  width: 2.4rem; height: 2.4rem;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff; border-radius: 12px; font-weight: 800; font-size: 0.9rem;
  box-shadow: 0 8px 18px -6px rgba(109, 108, 240, 0.7);
}
.brand.small .brand-mark { width: 2rem; height: 2rem; border-radius: 10px; }

/* ---------- auth ---------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  width: 100%; max-width: 27rem;
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 2.25rem;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.auth-sub { color: var(--text-muted); font-size: 0.92rem; margin: 0.85rem 0 1.6rem; }
.tabs { display: flex; gap: 0.3rem; margin-bottom: 1.4rem; background: rgba(11, 16, 32, 0.6); padding: 0.3rem; border-radius: 12px; border: 1px solid var(--border); }
.tab { flex: 1; padding: 0.55rem; border: none; background: transparent; color: var(--text-muted); border-radius: 9px; font-weight: 600; transition: 0.15s; }
.tab.active { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; box-shadow: var(--shadow-sm); }

form label, .editor-form label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 1rem; font-weight: 500; }
form input, form textarea, form select,
.editor-form input, .editor-form textarea, .editor-form select {
  width: 100%; margin-top: 0.35rem;
  padding: 0.7rem 0.85rem;
  background: rgba(11, 16, 32, 0.55); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 0.95rem; transition: border-color 0.15s, box-shadow 0.15s;
}
form input::placeholder, form textarea::placeholder,
.editor-form input::placeholder, .editor-form textarea::placeholder { color: #64708f; }
form input:focus, form textarea:focus, form select:focus,
.editor-form input:focus, .editor-form textarea:focus, .editor-form select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[type="color"] { padding: 0.25rem; height: 2.7rem; cursor: pointer; }
input[type="range"] { padding: 0; accent-color: var(--primary); }
.hint { font-size: 0.78rem; color: var(--text-muted); margin: -0.6rem 0 1rem; }
.form-error { color: #ff9aa8; font-size: 0.85rem; min-height: 1.2rem; margin: 0 0 0.6rem; }
.reg-disabled-note { color: var(--text-muted); font-size: 0.8rem; text-align: center; margin-top: 1rem; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.6rem;
  background: rgba(11, 16, 32, 0.65);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-email { color: var(--text-muted); font-size: 0.85rem; }

.container { max-width: 1140px; margin: 0 auto; padding: 2rem 1.6rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.8rem; flex-wrap: wrap; gap: 1rem; }
.page-head h2 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }

/* ---------- code cards ---------- */
.codes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.code-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s, box-shadow 0.16s;
  animation: rise 0.3s ease both;
}
.code-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.code-thumb {
  background: #fff; border-radius: 12px; padding: 0.9rem;
  display: grid; place-items: center; aspect-ratio: 1 / 1;
}
.code-thumb img { width: 100%; max-width: 180px; image-rendering: pixelated; }
.code-meta { display: flex; flex-direction: column; gap: 0.35rem; }
.code-title { font-weight: 700; font-size: 1.02rem; word-break: break-word; letter-spacing: -0.01em; }
.badge {
  display: inline-flex; align-items: center; font-size: 0.68rem; font-weight: 700;
  padding: 0.18rem 0.55rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge.dynamic { background: rgba(109, 108, 240, 0.2); color: #b7b6fb; border: 1px solid rgba(109, 108, 240, 0.35); }
.badge.static { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border: 1px solid var(--border); }
.code-url { color: var(--text-muted); font-size: 0.8rem; word-break: break-all; }
.code-url a { color: #b7b6fb; text-decoration: none; }
.code-url a:hover { text-decoration: underline; }
.code-stats { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; }
.code-stats::before { content: "📈"; font-size: 0.85rem; }
.code-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.3rem; }

.empty-state {
  text-align: center; padding: 5rem 1rem; color: var(--text-muted);
  background: var(--card); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty-state p { margin-bottom: 1rem; font-size: 1.05rem; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 18, 0.7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: linear-gradient(180deg, rgba(34, 43, 74, 0.92), rgba(20, 27, 52, 0.95));
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: 20px; width: 100%; max-width: 760px;
  max-height: 92vh; overflow: auto; box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--border); }
.modal-foot { border-bottom: none; border-top: 1px solid var(--border); gap: 0.75rem; justify-content: flex-end; }
.modal-head h3 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }
.modal-body { padding: 1.6rem; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.7rem; line-height: 1; padding: 0 0.25rem; transition: color 0.15s; }
.icon-btn:hover { color: var(--text); }

.editor-body { display: grid; grid-template-columns: 1fr 250px; gap: 1.75rem; padding: 1.6rem; }
@media (max-width: 660px) { .editor-body { grid-template-columns: 1fr; } }

.type-toggle { display: flex; gap: 0.6rem; margin-bottom: 1.4rem; }
.type-opt {
  flex: 1; text-align: left; padding: 0.85rem;
  background: rgba(11, 16, 32, 0.5); border: 1px solid var(--border); border-radius: 12px; color: var(--text-muted);
  display: flex; flex-direction: column; gap: 0.15rem; transition: 0.15s;
}
.type-opt strong { color: var(--text); font-size: 0.95rem; }
.type-opt span { font-size: 0.74rem; }
.type-opt:hover { border-color: var(--border-strong); }
.type-opt.active { border-color: var(--primary); background: rgba(109, 108, 240, 0.14); box-shadow: var(--ring); }

.style-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }

/* ---------- logo section ---------- */
.logo-section { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.logo-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; color: var(--text-muted); font-weight: 600; margin-bottom: 0.75rem; }
.logo-head small { font-weight: 400; }
.logo-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 0.55rem; }
.logo-tile {
  position: relative; aspect-ratio: 1 / 1; border-radius: 12px;
  border: 1px solid var(--border); background: #fff;
  display: grid; place-items: center; overflow: hidden; cursor: pointer; transition: 0.15s; padding: 0.3rem;
}
.logo-tile img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-tile:hover { border-color: var(--border-strong); }
.logo-tile.active { border-color: var(--primary); box-shadow: var(--ring); }
.logo-tile.logo-none { background: rgba(11, 16, 32, 0.5); color: var(--text-muted); font-size: 0.7rem; text-align: center; padding: 0.3rem; }
.logo-tile.logo-none.active { color: var(--text); }
.logo-del {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(15, 23, 42, 0.85); color: #fff; font-size: 0.85rem; line-height: 1;
  display: grid; place-items: center; opacity: 0; transition: 0.15s;
}
.logo-tile:hover .logo-del { opacity: 1; }
.logo-del:hover { background: var(--danger); }
.logo-size { margin-top: 0.9rem; }
.logo-size span { font-size: 0.8rem; color: var(--text-muted); }
.logo-tip { font-size: 0.75rem; color: var(--text-muted); margin: 0.7rem 0 0; background: rgba(109, 108, 240, 0.1); border: 1px solid rgba(109, 108, 240, 0.25); padding: 0.5rem 0.7rem; border-radius: 9px; }

.editor-preview { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; }
.preview-box {
  background: #fff; border-radius: var(--radius); width: 220px; height: 220px;
  display: grid; place-items: center; overflow: hidden; box-shadow: var(--shadow-sm);
}
.preview-box img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.preview-placeholder { color: #94a3b8; font-size: 0.85rem; }
.preview-note { color: var(--text-muted); font-size: 0.75rem; text-align: center; word-break: break-all; }

/* ---------- stats ---------- */
.stat-big { font-size: 2.8rem; font-weight: 800; background: linear-gradient(135deg, var(--primary-2), var(--primary)); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.bars { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 1.2rem; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 0.6rem; font-size: 0.8rem; color: var(--text-muted); }
.bar { height: 9px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; min-width: 3px; }
.scan-list { margin-top: 1.6rem; max-height: 240px; overflow: auto; font-size: 0.8rem; border: 1px solid var(--border); border-radius: 12px; }
.scan-list table { width: 100%; border-collapse: collapse; }
.scan-list td { padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.scan-list tr:last-child td { border-bottom: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: rgba(26, 33, 58, 0.95); backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  padding: 0.75rem 1.3rem; border-radius: 12px; box-shadow: var(--shadow);
  z-index: 100; font-size: 0.9rem; animation: rise 0.2s ease;
}
.toast.error { border-color: var(--danger); color: #ff9aa8; }
.toast.success { border-color: var(--success); color: #86efac; }
