:root {
  --bg: #0d1117;
  --bg-panel: #131a24;
  --bg-panel-2: #17202b;
  --border: #232d3a;
  --text: #e6edf3;
  --text-dim: #8b98a5;
  --accent: #22d3b6;
  --accent-2: #7c6cf0;
  --danger: #f0654c;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

#app {
  display: grid;
  grid-template-columns: 240px 360px 1fr;
  height: 100vh;
}

.panel { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.panel:last-child { border-right: none; }

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-header h1 { font-size: 15px; margin: 0; font-weight: 600; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.brand span { font-weight: 700; letter-spacing: 0.2px; }

.panel-body { flex: 1; overflow-y: auto; padding: 10px; }

.list-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.list-item:hover { background: var(--bg-panel-2); color: var(--text); }
.list-item.active { background: rgba(34, 211, 182, 0.12); color: var(--accent); font-weight: 600; }
.list-item .meta { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 13px;
}
.icon-btn:hover { color: var(--danger); background: rgba(240,101,76,0.1); }

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06120f;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
button.primary:hover { filter: brightness(1.08); }
button.secondary {
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12.5px;
}
button.secondary:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.tab-content.active { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 13px; }
.card .sub { color: var(--text-dim); font-size: 11.5px; margin-bottom: 8px; }
.card .body { font-size: 12.8px; white-space: pre-wrap; line-height: 1.5; }
.card .row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.empty { color: var(--text-dim); text-align: center; padding: 30px 10px; font-size: 13px; }

.memory-box {
  flex: 1;
  min-height: 200px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  resize: vertical;
}

/* chat column */
.chat-column { display: flex; flex-direction: column; height: 100vh; }
.thread-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.thread-chip {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-panel-2);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12.5px;
  border: 1px solid transparent;
}
.thread-chip.active { color: var(--accent); border-color: var(--accent); background: rgba(34,211,182,0.08); }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 78%; padding: 12px 14px; border-radius: 12px; line-height: 1.55; font-size: 13.5px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(124,108,240,0.25), rgba(34,211,182,0.18)); border: 1px solid var(--border); }
.msg.assistant { align-self: flex-start; background: var(--bg-panel); border: 1px solid var(--border); }
.msg .role { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 6px; }

.composer {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-top { display: flex; gap: 8px; align-items: center; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 160px; resize: vertical; flex: 1; }
.file-chip-toggle {
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
}
.file-chip-toggle.on { color: var(--accent); border-color: var(--accent); }

.model-select { max-width: 260px; }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--text-dim); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.scroll-thin::-webkit-scrollbar { width: 8px; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- auth / paywall ---------- */

#auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  justify-content: center;
  padding: 40px 16px 60px;
}
.auth-box { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 18px; }
.auth-box .brand { justify-content: center; font-size: 20px; margin-bottom: 4px; }
.auth-box .brand .dot { width: 14px; height: 14px; }
.auth-sub { text-align: center; color: var(--text-dim); margin: 0 0 8px; font-size: 13.5px; }
.auth-login .row { display: flex; gap: 8px; }
.auth-login input { text-transform: uppercase; letter-spacing: 0.05em; }
.auth-error { color: var(--danger); font-size: 12.5px; min-height: 16px; text-align: center; }

.plans-title { text-align: center; margin: 4px 0 0; font-size: 14px; color: var(--text-dim); font-weight: 600; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.plan-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-card .plan-label { font-weight: 700; font-size: 14px; }
.plan-card .plan-price { font-size: 22px; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plan-card .plan-price small { font-size: 12px; font-weight: 600; -webkit-text-fill-color: var(--text-dim); }
.plan-card button { margin-top: 6px; width: 100%; }

.code-reveal { text-align: center; border-color: var(--accent); }
.code-reveal .code-value {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--bg-panel-2);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  user-select: all;
}

/* ---------- landing page sections ---------- */

.hero { text-align: center; padding: 20px 0 8px; }
.hero-title { font-size: 30px; font-weight: 800; margin: 14px 0 10px; line-height: 1.25; }
.hero-sub { color: var(--text-dim); font-size: 14.5px; max-width: 560px; margin: 0 auto 18px; line-height: 1.6; }
.hero-cta { display: inline-block; text-decoration: none; padding: 10px 22px; font-size: 14px; }
.hero-trust { margin-top: 12px; color: var(--text-dim); font-size: 11.5px; }

.pl-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
}

.section-title { text-align: center; font-size: 18px; font-weight: 700; margin: 8px 0 6px; }
.section-sub { text-align: center; color: var(--text-dim); font-size: 12.8px; max-width: 520px; margin: 0 auto 18px; line-height: 1.6; }

.audience-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 18px 0 8px; }
.audience-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
}
.audience-card h3 { margin: 0 0 6px; font-size: 13.5px; }
.audience-card p { margin: 0; color: var(--text-dim); font-size: 12.3px; line-height: 1.5; }

.models-section { margin: 20px 0 8px; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.model-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.model-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.model-badge {
  position: absolute; top: -9px; right: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06120f;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 8px;
}
.model-card h3 { margin: 0 0 6px; font-size: 13px; }
.model-card p { margin: 0; color: var(--text-dim); font-size: 11.8px; line-height: 1.5; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 12px 0 8px; }
.feature-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
}
.feature-icon { font-size: 22px; margin-bottom: 8px; }
.feature-card h3 { margin: 0 0 6px; font-size: 13.5px; }
.feature-card p { margin: 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.55; }

.how-it-works { margin: 20px 0 8px; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.step { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; font-size: 12.5px; line-height: 1.5; }
.step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06120f;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}

.faq { margin: 24px 0 8px; }
.faq-item { margin-bottom: 14px; font-size: 12.8px; }
.faq-item b { display: block; margin-bottom: 4px; font-size: 13.3px; }
.faq-item p { margin: 0; color: var(--text-dim); line-height: 1.55; }

.landing-footer { text-align: center; color: var(--text-dim); font-size: 11.5px; padding: 24px 0 4px; }

/* ---------- admin ---------- */

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; color: var(--accent); }
.stat-card .stat-label { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.admin-table th, table.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.admin-table th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
table.admin-table tr:last-child td { border-bottom: none; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; }
.badge-active { background: rgba(34,211,182,0.15); color: var(--accent); }
.badge-unused { background: rgba(124,108,240,0.15); color: var(--accent-2); }
.badge-expired, .badge-revoked { background: rgba(240,101,76,0.15); color: var(--danger); }

#topbar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-bottom-left-radius: 10px;
  border: 1px solid var(--border);
  border-top: none;
  border-right: none;
}
