:root {
  --brand: #6c5ce7;
  --brand-2: #a29bfe;
  --brand-dark: #4b3cc4;
  --bg: #0d0d14;
  --bg-soft: #14141f;
  --card: #1a1a28;
  --card-2: #20202f;
  --border: #2a2a3d;
  --text: #f2f2f7;
  --text-dim: #9b9bb4;
  --success: #2ed573;
  --danger: #ff6b6b;
  --warn: #ffa502;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; }
input[type="file"] { font-size: 13px; color: var(--text-dim); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

.text-dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.text-danger { color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 6px 20px rgba(108,92,231,.35);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(108,92,231,.5); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--card-2); }
.btn-danger { background: rgba(255,107,107,.12); color: var(--danger); }
.btn-danger:hover { background: rgba(255,107,107,.2); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-mark { font-size: 20px; }
.brand b { color: var(--brand-2); }

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13,13,20,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-nav { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; }
.app-nav-right { display: flex; gap: 10px; align-items: center; }

.app-main { padding: 30px 20px 80px; }

/* Dashboard */
.dash-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.dash-head h1 { font-size: 28px; font-weight: 800; }
.dash-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.page-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.page-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease;
  display: flex;
  flex-direction: column;
}
.page-card:hover { transform: translateY(-3px); border-color: var(--brand); }
.page-card-thumb {
  height: 120px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.page-card-thumb .thumb-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.page-card-body { padding: 16px; flex: 1; }
.page-card-body h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.page-card-body p { color: var(--text-dim); font-size: 13px; }
.page-card-meta { display: flex; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.page-card-actions { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--border); }
.page-card-actions .btn { flex: 1; }

.empty-state {
  text-align: center;
  padding: 70px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 20px; margin-bottom: 6px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* Editor */
.editor-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.editor-head h1 { font-size: 24px; font-weight: 800; margin-right: auto; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.editor-side { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.card-danger { border-color: rgba(255,107,107,.35); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field input[type="text"], .field input[type="url"], .field input[type="email"], .field textarea, .field select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.field textarea { resize: vertical; }

.slug-box { display: flex; align-items: center; gap: 8px; }
.slug-prefix { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.slug-box input { flex: 1; }

.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-item {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 18px;
  transition: transform .1s ease;
}
.emoji-item:hover { transform: scale(1.1); }
.emoji-item.active { border-color: var(--brand); background: rgba(108,92,231,.15); }

#avatar-preview, #bg-preview { margin-top: 8px; }
.thumb-img {
  width: 64px; height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.bg-thumb {
  width: 100%; height: 80px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Button editor rows */
.link-row {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}
.link-row-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.link-row-top input[type="text"] { flex: 1; }
.link-emoji {
  width: 38px; text-align: center;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 0;
  font-size: 16px;
}
.link-row-url { display: flex; gap: 8px; align-items: center; }
.link-row-url input { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; color: var(--text); font-size: 13px; outline: none; }
.link-row-url input:focus { border-color: var(--brand); }
.row-actions { display: flex; gap: 6px; }
.row-actions button {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}
.row-actions button:hover { border-color: var(--brand); }
.row-actions .row-del:hover { border-color: var(--danger); color: var(--danger); }

/* Products */
.product-row {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.product-row-top { display: flex; gap: 8px; margin-bottom: 8px; }
.product-row-top input { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; color: var(--text); font-size: 13px; outline: none; }
.product-row-top input:focus { border-color: var(--brand); }
.product-row-top .price { max-width: 100px; }
.product-row-desc { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; color: var(--text); font-size: 13px; outline: none; margin-bottom: 8px; }
.product-row-desc:focus { border-color: var(--brand); }
.product-row-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Theme grid */
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-opt {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.mode-opt.active {
  border-color: var(--brand);
  color: var(--text);
  background: rgba(108,92,231,.15);
}
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-item {
  height: 52px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform .1s ease;
}
.theme-item:hover { transform: scale(1.05); }
.theme-item.active { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.theme-item .check {
  position: absolute; top: 4px; right: 6px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-top: 2px; }
input[type="range"] { width: 100%; accent-color: var(--brand); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .stat-value { font-size: 30px; font-weight: 800; }
.stat-card .stat-label { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar {
  width: 100%;
  max-width: 46px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height .3s ease;
}
.chart-date { font-size: 11px; color: var(--text-dim); }

.click-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.click-label { width: 40%; font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.click-bar-wrap { flex: 1; background: var(--bg-soft); border-radius: 8px; height: 22px; overflow: hidden; }
.click-bar { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 8px; min-width: 4px; }
.click-count { width: 40px; text-align: right; font-size: 13px; font-weight: 700; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal-box {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-small { max-width: 420px; }
.modal-box h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.modal-box textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  margin: 16px 0;
  outline: none;
  resize: vertical;
}
.modal-box textarea:focus { border-color: var(--brand); }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
#ai-result { margin-top: 14px; }
#ai-result .demo-btn { cursor: default; margin-bottom: 6px; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: toast-in .25s ease;
}
.toast.success { border-color: rgba(46,213,115,.5); }
.toast.error { border-color: rgba(255,107,107,.5); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
