:root {
  --bg:           #0b0d12;
  --surface-0:    #0f1218;
  --surface-1:    #161a23;
  --surface-2:    #1d222e;
  --border:       rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text:         #e8eaf0;
  --text-muted:   #a8b0c4;
  --text-subtle:  #7e8a9e;
  --accent:       #5b8bff;
  --accent-hover: #739dff;
  --gold:         #FFD700;
  --r-md: 10px;
  --r-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button, input { font: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-status {
  color: var(--text-muted);
  font-size: 13px;
}
.auth-status.signed-in { color: #6fd29d; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 13px;
}
.ghost-btn:hover { background: var(--surface-1); }
.primary-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 8px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 600;
}
.primary-btn:hover { background: var(--accent-hover); }

/* ── Launcher ─────────────────────────────────────────────────────────────── */
.launcher {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.launcher-inner {
  width: 100%;
  max-width: 960px;
}
.hero-title {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero-sub {
  margin: 0 0 32px 0;
  color: var(--text-muted);
  font-size: 15px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}
.tile {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}
.tile:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-1px);
}
.tile-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  /* Reset any letter-spacing / weight so emoji renders cleanly */
  letter-spacing: 0;
  font-weight: 400;
}
.tile-mark--blue { background: linear-gradient(135deg, #015BBB, #2E8EFF); }
.tile-mark--gold { background: linear-gradient(135deg, #C49500, #FFD700); }

.tile-body { min-width: 0; }
.tile-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.tile-desc {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.tile-cta {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

/* ── Settings drawer ──────────────────────────────────────────────────────── */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 380px;
  max-width: 90vw;
  background: var(--surface-0);
  border-left: 1px solid var(--border);
  z-index: 60;
  padding: 24px;
  overflow-y: auto;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
}
.panel-intro {
  margin: 0 0 18px 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.api-key-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.api-key-wrap input {
  flex: 1;
  padding-right: 88px; /* room for badge */
}
.api-key-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(78, 183, 132, 0.15);
  color: #6fd29d;
  border: 1px solid rgba(78, 183, 132, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.field {
  display: block;
  margin-bottom: 18px;
}
.field > span:first-of-type {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 8px;
}
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Auth gate ────────────────────────────────────────────── */

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-gate.hidden { display: none !important; }

.gate-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 28px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.3);
  text-align: center;
}

.gate-title {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.gate-state.hidden { display: none; }

.gate-sub {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.gate-error { color: #ff8b8b; }

.gate-email {
  display: inline-block;
  margin-top: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text-subtle);
  word-break: break-all;
}

.gate-help {
  margin: 16px 0 20px;
  font-size: 13px;
  color: var(--text-subtle);
}

.gate-btn {
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
}
