/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e17;
  --surface: #161d2f;
  --surface-strong: #20283a;
  --border: #2a3346;
  --text: #e4e6eb;
  --text-muted: #a8afbe;
  --accent: #5eb3ff;
  --accent-hover: #7ecbff;
  --danger: #ff8e8e;
  --success: #8fe0ae;
  --info: #8fc7ff;
  --radius: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --font-heading: "Libre Baskerville", Georgia, serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top, rgba(94, 179, 255, 0.14), transparent 34%),
    linear-gradient(135deg, #0a0e17 0%, #0d1621 100%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.page-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-strong) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 440px;
}

.card--wide { max-width: 760px; }

/* ── Topbar / nav ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 2rem;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.topbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 { font-family: var(--font-heading); font-size: 1.9rem; margin-bottom: .5rem; }
h2 { font-family: var(--font-heading); font-size: 1.4rem; margin-bottom: 1rem; }
h3 { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
p  { color: var(--text-muted); font-size: .95rem; }

h1, h2, h3 { color: var(--text); }

.subtitle { color: var(--text-muted); margin-bottom: 2rem; font-size: .95rem; }
.loading  { color: var(--text-muted); font-style: italic; text-align: center; padding: 3rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s, border-color .15s, transform .15s;
  text-decoration: none;
}

.btn--primary   { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%); color: #0a0e17; }
.btn--primary:hover   { filter: brightness(1.03); text-decoration: none; transform: translateY(-1px); }
.btn--secondary { background: rgba(255,255,255,0.02); color: var(--text); border: 1px solid var(--border); }
.btn--secondary:hover { background: rgba(126, 203, 255, 0.08); border-color: var(--accent); text-decoration: none; }
.btn--ghost     { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn--ghost:hover     { color: var(--text); border-color: var(--border); text-decoration: none; }
.btn--danger    { background: linear-gradient(135deg, #ff8e8e 0%, #ffb0b0 100%); color: #180c10; }
.btn--full      { width: 100%; }
.btn:disabled   { opacity: .5; cursor: not-allowed; }

/* OAuth provider buttons */
.btn--oauth {
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  margin-bottom: .75rem;
  font-size: 1rem;
}
.btn--oauth:hover { background: rgba(126, 203, 255, 0.08); border-color: var(--accent); text-decoration: none; }
.btn--oauth svg { flex-shrink: 0; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .92rem; }
.form-hint  { font-size: .82rem; color: var(--text-muted); margin-top: .3rem; }

.file-input--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-pick-btn {
  display: inline-flex;
}

textarea,
input[type="text"],
input[type="url"],
input[type="file"] {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .95rem;
  background: rgba(13, 20, 31, 0.9);
  color: var(--text);
  transition: border-color .15s, background .15s;
  resize: vertical;
}
textarea:focus,
input:focus { outline: none; border-color: var(--accent); background: #111a27; }

textarea.code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .82rem;
  min-height: unset;
  background: #1e1e1e;
  color: #d4d4d4;
  border-color: #444;
  width: 100%;
  box-sizing: border-box;
}

/* ── Steps ────────────────────────────────────────────────────────────────── */
.steps {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

.step {
  flex: 1;
  padding: .6rem .75rem;
  background: rgba(255,255,255,0.02);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
  transition: background .15s, color .15s;
}
.step:hover { background: rgba(126, 203, 255, 0.08); color: var(--text); }
.step.active { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%); color: #0a0e17; }

/* ── Dashboard content ────────────────────────────────────────────────────── */
.dashboard {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem 4rem;
}

.flow-shell {
  background: linear-gradient(145deg, #0f1724 0%, #141f30 55%, #1a2638 100%);
  border: 1px solid #2a3346;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.flow-shell h2,
.flow-shell h3 {
  color: #e4e6eb;
}

.flow-shell .subtitle,
.flow-shell .form-hint,
.flow-shell p {
  color: #a8afbe;
}

.flow-shell .form-label {
  color: #d4d9e3;
}

.flow-shell input[type="text"],
.flow-shell textarea {
  background: #0d141f;
  border-color: #2c3548;
  color: #e4e6eb;
}

.flow-shell input[type="text"]:focus,
.flow-shell textarea:focus {
  border-color: #5eb3ff;
}

.flow-shell .slug-preview {
  background: #0d141f;
  border-color: #2c3548;
  color: #a8afbe;
}

.flow-shell .slug-preview strong,
.flow-shell .slug-preview a {
  color: #7ecbff;
}

.flow-shell details summary {
  color: #9aa6bd;
}

.slug-suggestions {
  margin-top: .4rem;
}

.slug-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.btn--suggestion {
  padding: .4rem .7rem;
  font-size: .86rem;
}

/* ── Dashboard home cards (jaani-builds inspired) ───────────────────────── */
.dashboard-home {
  max-width: 980px;
}

.home-shell {
  background: linear-gradient(135deg, #0a0e17 0%, #0d1621 100%);
  border: 1px solid #2a3346;
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.home-kicker {
  font-size: .8rem;
  color: #a8afbe;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .35rem;
}

.home-title {
  color: #e4e6eb;
  margin-bottom: .4rem;
}

.home-subtitle {
  color: #a8afbe;
  margin-bottom: 1.5rem;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.home-cards--single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 640px;
}

.home-card {
  border: 1px solid #2a3346;
  border-radius: 8px;
  background: linear-gradient(135deg, #161d2f 0%, #20283a 100%);
  padding: 1.25rem;
  box-shadow: 0 8px 20px rgba(94, 179, 255, 0.08);
  transition: all .25s ease;
}

.home-card:hover {
  transform: translateY(-2px);
  border-color: #5eb3ff;
  box-shadow: 0 16px 40px rgba(94, 179, 255, 0.15);
}

.home-card h3 {
  color: #e4e6eb;
  margin-bottom: .4rem;
}

.home-card p {
  color: #a8afbe;
  margin-bottom: 1rem;
  min-height: 48px;
}

.home-card__action {
  border: none;
  border-radius: 8px;
  padding: .62rem 1rem;
  background: linear-gradient(135deg, #5eb3ff 0%, #7ecbff 100%);
  color: #0a0e17;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
}

.home-card__action:hover {
  filter: brightness(1.04);
}

.home-live-url {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #2a3346;
  color: #a8afbe;
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
}

.home-live-url a {
  color: #7ecbff;
}

/* ── Slug preview ─────────────────────────────────────────────────────────── */
.slug-preview {
  background: rgba(13, 20, 31, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: .75rem;
  word-break: break-all;
}
.slug-preview strong { color: var(--accent); }

/* ── Published banner ─────────────────────────────────────────────────────── */
.banner {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: .95rem;
  margin-bottom: 1.5rem;
}
.banner--success {
  background: rgba(143, 224, 174, 0.1);
  border: 1px solid rgba(143, 224, 174, 0.32);
  color: var(--success);
}
.banner--error {
  background: rgba(255, 142, 142, 0.1);
  border: 1px solid rgba(255, 142, 142, 0.28);
  color: var(--danger);
}
.banner--info {
  background: rgba(143, 199, 255, 0.1);
  border: 1px solid rgba(143, 199, 255, 0.28);
  color: var(--info);
}

/* ── JSON viewer ──────────────────────────────────────────────────────────── */
.json-summary {
  background: rgba(13, 20, 31, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.json-summary dl { display: grid; grid-template-columns: 140px 1fr; gap: .35rem .75rem; }
.json-summary dt { font-weight: 700; font-size: .88rem; color: var(--text-muted); }
.json-summary dd { font-size: .88rem; word-break: break-word; color: var(--text); }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-brand {
  text-align: center;
  margin-bottom: 1.25rem;
}

.login-brand__logo {
  max-height: 56px;
  width: auto;
}

.login-logo {
  font-family: var(--font-heading);
  font-size: 2rem;
  text-align: center;
  margin-bottom: .5rem;
  color: var(--text);
}
.login-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: .95rem;
  margin-bottom: 2rem;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: .85rem;
}
.login-divider::before,
.login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.login-stack {
  width: 100%;
  max-width: 440px;
}

#parse-result pre {
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

details summary:hover {
  color: var(--text);
}

/* ── Coffee Button & Modal ─────────────────────────────────────────────────── */
.btn--support-topbar {
  background: rgba(94, 179, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(94, 179, 255, 0.3);
  padding: .48rem .75rem;
  font-size: .85rem;
  white-space: nowrap;
}
.btn--support-topbar:hover {
  background: rgba(94, 179, 255, 0.25);
  border-color: var(--accent);
  text-decoration: none;
}

.support-cta {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  flex-wrap: wrap;
}

.support-cta p {
  margin: 0;
  color: var(--text-muted);
}

.support-inline {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .88rem;
}

.support-panel {
  margin-top: 1rem;
  border: 1px solid rgba(94, 179, 255, 0.35);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  background: linear-gradient(135deg, rgba(94, 179, 255, 0.08) 0%, rgba(126, 203, 255, 0.03) 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.support-panel__kicker {
  margin: 0 0 .35rem;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
}

.support-panel h3 {
  margin: 0 0 .35rem;
}

.support-panel p {
  margin: 0 0 .75rem;
  color: var(--text-muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity .2s;
}

.modal--hidden {
  opacity: 0;
  pointer-events: none;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.modal__content {
  position: relative;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-strong) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  animation: slideUp .25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal__header h3 {
  margin: 0;
}

.modal__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.modal__body p {
  text-align: center;
  margin: 0;
}

.modal__hint {
  font-size: .85rem;
  color: var(--text-muted);
}

.modal__sgd-note {
  font-size: .82rem;
  color: #f5d77a;
  background: rgba(245, 215, 122, 0.12);
  border: 1px solid rgba(245, 215, 122, 0.35);
  border-radius: var(--radius);
  padding: .45rem .6rem;
}

.payee-verify {
  width: 100%;
  font-size: .84rem;
  color: #c7def8;
  border: 1px dashed rgba(94, 179, 255, 0.45);
  background: rgba(94, 179, 255, 0.1);
  border-radius: var(--radius);
  padding: .55rem .65rem;
  text-align: center;
}

.support-log {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.support-log input {
  width: 100%;
  padding: .55rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0d141f;
  color: var(--text);
}

.support-log input:focus {
  outline: none;
  border-color: var(--accent);
}

.category-editor {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin: 1rem 0 1.2rem;
}

.parse-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .25rem;
  flex-wrap: wrap;
}

.publish-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Accordion sections ─────────────────────────────────────────────────── */
.acc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255,255,255,0.01);
}

.acc__hd {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
  background: rgba(255,255,255,0.025);
  transition: background .15s;
  min-height: 48px; /* comfortable touch target */
}
.acc__hd::-webkit-details-marker { display: none; }
.acc__hd:hover { background: rgba(94, 179, 255, 0.07); }
.acc__hd::after {
  content: "▸";
  font-size: .7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: auto;
  transition: transform .2s;
}
details[open] > .acc__hd::after { transform: rotate(90deg); }

.acc__title { flex: 1; }

.acc__badge {
  font-size: .74rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(94, 179, 255, 0.12);
  border: 1px solid rgba(94, 179, 255, 0.25);
  border-radius: 99px;
  padding: .18rem .6rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.acc__badge--empty {
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}

.acc__body {
  padding: .75rem;
  border-top: 1px solid var(--border);
}
.acc__body .form-hint {
  font-size: .82rem;
  margin-bottom: .5rem;
}
.acc__body textarea {
  font-size: 14px; /* explicit so mobile doesn't zoom */
}

@media (max-width: 640px) {
  .acc__body textarea {
    font-size: 16px; /* prevent iOS auto-zoom on focus */
    rows: auto;
  }
  .acc__hd {
    padding: 1rem;
    font-size: .88rem;
  }
}

.category-editor__section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  padding: .8rem;
}

.modal__error {
  color: var(--danger);
  font-size: .9rem;
}

.qr-code {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 320px;
}

.qr-image {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .card { padding: 1.75rem 1.25rem; }
  h1    { font-size: 1.5rem; }
  .topbar { padding: .75rem 1rem; }
  .topbar__user { gap: .45rem; }
  .topbar__user > span { display: none; }
  .btn--support-topbar { padding: .45rem .55rem; font-size: .78rem; }
  .json-summary dl { grid-template-columns: 1fr; }
  .home-shell { padding: 1.25rem; }
  .home-cards { grid-template-columns: 1fr; }
  .home-card p { min-height: auto; }
  .support-panel { padding: .95rem 1rem; }
  .support-inline { justify-content: flex-start; }
  .flow-shell { padding: 1.1rem; }

  .parse-actions {
    flex-direction: column;
    align-items: stretch;
    gap: .6rem;
  }

  .parse-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .publish-actions {
    flex-direction: column;
    align-items: stretch;
    gap: .6rem;
  }

  .publish-actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .modal {
    align-items: flex-start;
    padding-top: 1.25rem;
    padding-left: .6rem;
    padding-right: .6rem;
  }

  .modal__content {
    width: 100%;
    max-width: 360px;
    padding: 1.1rem .95rem;
    max-height: calc(100vh - 2.2rem);
    overflow-y: auto;
  }

  .modal__header {
    margin-bottom: .85rem;
  }

  .modal__body {
    gap: .65rem;
  }

  .qr-code {
    min-height: 200px;
    padding: .65rem;
  }

  .qr-image {
    max-height: 180px;
    width: auto;
  }
}
