/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --canvas:    #fafaf8;
  --white:     #ffffff;
  --border:    #e8e4de;
  --muted:     #a09890;
  --text:      #2c2622;
  --text-soft: #6b5f58;
  --pink:      #c49a94;
  --pink-dark: #b48880;
  --pink-bg:   #f9f0ee;
  --green:     #4caf50;
  --red:       #e53935;
  --shadow:    0 2px 20px rgba(0,0,0,.06);
  --radius:    8px;
  --font-h:    'Cormorant Garamond', Georgia, serif;
  --font-b:    'Jost', system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-b);
  background: var(--canvas);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--pink-dark); text-decoration: none; }
a:hover { color: var(--pink); }
img { max-width: 100%; height: auto; display: block; }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.container { max-width: 640px; margin: 0 auto; }

/* ── Navigation ──────────────────────────────────────────────────────────────── */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.nav-brand {
  font-family: var(--font-h);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-brand:hover { color: var(--pink); }
.nav-admin-badge {
  font-family: var(--font-b);
  font-size: .65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--pink);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}
.nav-links a {
  font-size: .875rem;
  font-weight: 400;
  color: var(--text-soft);
  transition: color .15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links .nav-logout { color: var(--muted); }
.nav-credits span {
  font-size: .8rem;
  font-weight: 500;
  background: var(--pink-bg);
  color: var(--pink-dark);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--pink);
}

/* ── Flash messages ──────────────────────────────────────────────────────────── */
.flash {
  max-width: 960px;
  margin: 0 auto 0;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .9rem;
}
.flash-info    { background: #e3f2fd; color: #0d47a1; }
.flash-success { background: #e8f5e9; color: #1b5e20; }
.flash-error   { background: #ffebee; color: #b71c1c; }
.flash-warning { background: #fff8e1; color: #e65100; }
.flash-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: .5;
  color: inherit;
  padding: 0 4px;
}
.flash-close:hover { opacity: 1; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 28px; }
.card-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2, .card-header h3 {
  font-family: var(--font-h);
  font-weight: 400;
  font-size: 1.25rem;
}

/* ── Typography ──────────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-h); font-weight: 400; line-height: 1.25; }
h1 { font-size: 2.2rem; font-style: italic; margin-bottom: 8px; }
h2 { font-size: 1.6rem; margin-bottom: 12px; }
h3 { font-size: 1.25rem; margin-bottom: 8px; }
.page-title { margin-bottom: 28px; }
.page-title p { color: var(--text-soft); font-size: .9rem; margin-top: 4px; }
.text-muted { color: var(--muted); font-size: .875rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-b);
  font-size: .875rem;
  font-weight: 400;
  padding: 10px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-cta {
  background: var(--pink);
  color: #fff;
  border-color: var(--pink);
}
.btn-cta:hover { background: var(--pink-dark); border-color: var(--pink-dark); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--pink); color: var(--pink); }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--canvas); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-b);
  font-size: .9rem;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
}
.form-control:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(196,154,148,.15);
}
textarea.form-control { resize: vertical; min-height: 140px; }
.form-hint { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.form-error { font-size: .8rem; color: var(--red); margin-top: 5px; }

/* ── Conversation list ───────────────────────────────────────────────────────── */
.conv-list { list-style: none; }
.conv-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  text-decoration: none;
  color: inherit;
}
.conv-item:last-child { border-bottom: none; }
.conv-item:hover { background: var(--canvas); }
.conv-item.unread .conv-subject { font-weight: 500; color: var(--text); }
.conv-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--pink-bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-size: 1.2rem;
  color: var(--pink-dark);
}
.conv-content { flex: 1; min-width: 0; }
.conv-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-subject { font-size: .9rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: .75rem; color: var(--muted); flex-shrink: 0; }
.conv-preview { font-size: .825rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-unread-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink);
  flex-shrink: 0;
}

/* ── Message thread ──────────────────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 20px; padding: 24px; }
.msg-bubble { display: flex; gap: 12px; }
.msg-bubble.from-admin { flex-direction: row; }
.msg-bubble.from-member { flex-direction: row-reverse; }

.bubble-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--canvas);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-size: 1rem;
  color: var(--muted);
}
.bubble-content { max-width: 70%; }
.bubble-body {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.from-admin .bubble-body {
  background: var(--white);
  border: 1px solid var(--border);
  border-top-left-radius: 2px;
}
.from-member .bubble-body {
  background: var(--pink-bg);
  border: 1px solid rgba(196,154,148,.25);
  border-top-right-radius: 2px;
}
.bubble-meta {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 5px;
  padding: 0 4px;
}
.from-member .bubble-meta { text-align: right; }

.bubble-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.att-thumb {
  width: 90px;
  height: 90px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--canvas);
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Reply form ──────────────────────────────────────────────────────────────── */
.reply-box {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  background: var(--canvas);
}
.reply-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 12px; }
.credit-cost {
  font-size: .8rem;
  color: var(--text-soft);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
}
.credit-cost strong { color: var(--pink-dark); }

/* ── Wallet / credits ────────────────────────────────────────────────────────── */
.balance-card {
  text-align: center;
  padding: 40px 28px;
}
.balance-number {
  font-family: var(--font-h);
  font-size: 3.5rem;
  font-style: italic;
  color: var(--pink-dark);
  display: block;
  line-height: 1;
  margin: 12px 0 6px;
}
.balance-label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.tx-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tx-table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 500;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.tx-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tx-table tr:last-child td { border-bottom: none; }
.tx-credit { color: var(--green); font-weight: 500; }
.tx-debit  { color: var(--red); }

/* ── Credit packages ─────────────────────────────────────────────────────────── */
.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.pkg-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.pkg-card:hover, .pkg-card.selected {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(196,154,148,.15);
}
.pkg-card.popular::before {
  content: 'Most popular';
  position: absolute;
  top: -1px; left: 50%; transform: translateX(-50%);
  background: var(--pink);
  color: #fff;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .04em;
  padding: 3px 12px;
  border-radius: 0 0 6px 6px;
}
.pkg-name { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pkg-credits { font-family: var(--font-h); font-size: 3rem; font-weight: bold; color: var(--text); margin: 8px 0 2px; }
.pkg-msg-count { font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.pkg-price { font-size: 1.4rem; font-weight: 300; color: var(--text); }

/* ── Auth pages ──────────────────────────────────────────────────────────────── */
.auth-wrap {
  max-width: 420px;
  margin: 40px auto;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo a {
  font-family: var(--font-h);
  font-size: 2rem;
  font-style: italic;
  color: var(--text);
}
.auth-footer { text-align: center; margin-top: 20px; font-size: .875rem; color: var(--text-soft); }

/* ── Inbox / page headers ────────────────────────────────────────────────────── */
.page-actions { display: flex; align-items: center; gap: 12px; }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-soft);
}
.empty-state p { margin-bottom: 20px; }

/* ── Tables (admin) ──────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 500;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}
.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--canvas); }
.table a { color: var(--text); }
.table a:hover { color: var(--pink); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .04em;
}
.badge-active  { background: #e8f5e9; color: #2e7d32; }
.badge-banned  { background: #ffebee; color: #c62828; }
.badge-unread  { background: var(--pink-bg); color: var(--pink-dark); }

/* ── Custom file picker ──────────────────────────────────────────────────────── */
.file-pick-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-pick-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: .8rem;
  font-family: var(--font-b);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--white);
  transition: border-color .15s, color .15s;
  white-space: nowrap;
  user-select: none;
}
.file-pick-label:hover { border-color: var(--pink); color: var(--pink-dark); }
.file-pick-name { font-size: .8rem; color: var(--muted); font-style: italic; }
.file-pick-input {
  position: absolute;
  z-index: -1;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
}

/* ── Profile photo ───────────────────────────────────────────────────────────── */
.profile-photo-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}
.profile-avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--pink-bg);
  border: 2px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-size: 2rem;
  color: var(--pink-dark);
}
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.avatar-photo { width: 100%; height: 100%; object-fit: cover; }

/* ── File upload ─────────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  font-size: .875rem;
  color: var(--muted);
}
.upload-area:hover { border-color: var(--pink); }
.upload-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.upload-preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
  animation: lb-fade .15s ease;
}
.lightbox.open { display: flex; }
@keyframes lb-fade { from { opacity: 0 } to { opacity: 1 } }
.lightbox img {
  max-width: min(95vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
  cursor: default;
  display: block;
  animation: lb-zoom .15s ease;
}
@keyframes lb-zoom { from { transform: scale(.95); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-links { gap: 14px; }
  .nav-credits { display: none; }
  .pkg-grid { grid-template-columns: 1fr 1fr; }
  .bubble-content { max-width: 88%; }
  h1 { font-size: 1.7rem; }
}
