/* B's Gua Sha app — mobile-first styles, gold/champagne brand (light/dark via [data-theme]) */
:root {
  --brand: #9a7b3c;
  --brand-deep: #7c612c;
  --brand-soft: #f3e8d2;
  --gold: #c9a55a;
  --blush: #e8c5b0;
  --bg: #faf6ec;
  --surface: #fffdf8;
  --surface2: #f3ecdc;
  --ink: #322a1a;
  --muted: #7c7260;
  --line: #e7dcc4;
  --danger: #c0564f;
  --ok: #3e8e60;
  --shadow: 0 8px 24px rgba(60, 48, 22, 0.09);
  --radius: 18px;
  --tabbar-h: 64px;
}
[data-theme="dark"] {
  --brand: #d6b372;
  --brand-deep: #e7cf9d;
  --brand-soft: #32291a;
  --gold: #d8b878;
  --blush: #c79a82;
  --bg: #171310;
  --surface: #211b13;
  --surface2: #2b2418;
  --ink: #f0e8d6;
  --muted: #ada18a;
  --line: #3a3122;
  --danger: #e07a72;
  --ok: #62b888;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
  transition: background 0.25s, color 0.25s;
}
h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; line-height: 1.25; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; }

.app-root {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  padding: 16px 16px calc(var(--tabbar-h) + 28px);
}
@media (min-width: 560px) {
  body { background: linear-gradient(160deg, var(--brand-soft), var(--bg) 55%); }
  .app-root { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--bg); min-height: 100vh; }
}

/* top bar inside views */
.appbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.appbar .logo { display: flex; align-items: center; gap: 8px; font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1.12rem; }
.appbar .logo img { width: 32px; height: 32px; border-radius: 8px; }
.appbar .spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 0.9rem; font-weight: 600;
  position: relative;
}
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 0.66rem;
  display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 700;
}
.back-btn { border: none; background: none; color: var(--brand); font-weight: 600; cursor: pointer; font-size: 1rem; padding: 4px 8px 4px 0; }

.view-title { font-size: 1.45rem; margin-bottom: 4px; }
.view-sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 16px; }

/* cards & buttons */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-weight: 600; font-size: 1rem;
  padding: 13px 22px; border-radius: 999px; transition: transform 0.12s, opacity 0.12s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--brand)); color: #fff; }
[data-theme="dark"] .btn-primary { color: #1c1610; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.88rem; }

.field { margin-bottom: 12px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.field label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; }

/* ===== auth ===== */
.auth-wrap { padding-top: 6vh; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo img { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); }
.auth-logo h1 { font-size: 1.8rem; margin-top: 14px; }
.auth-logo p { color: var(--brand); font-size: 0.88rem; margin-top: 4px; }
.auth-tabs { display: flex; background: var(--surface2); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; border: none; background: none; padding: 10px; border-radius: 999px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.auth-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.demo-hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin-top: 16px; }

/* ===== home ===== */
.balance-card {
  background: linear-gradient(135deg, #c9a55a, #8a6a2f);
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 14px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.balance-card::after {
  content: "B"; position: absolute; right: 10px; bottom: -22px;
  font-family: 'Playfair Display', serif; font-size: 6rem; font-weight: 700; opacity: 0.12;
}
.balance-card small { opacity: 0.9; font-size: 0.82rem; }
.balance-amount { font-size: 2rem; font-weight: 700; font-family: 'Playfair Display', serif; margin: 2px 0 12px; }
.balance-card .btn { background: rgba(255, 255, 255, 0.25); color: #fff; backdrop-filter: blur(4px); }
.demo-banner {
  background: var(--gold); color: #2c2412; font-size: 0.78rem; font-weight: 700;
  text-align: center; border-radius: 10px; padding: 6px 10px; margin-bottom: 12px; letter-spacing: 0.04em;
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 10px; }
.section-head h3 { font-size: 1.1rem; }
.section-head a, .section-head button { color: var(--brand); font-size: 0.88rem; font-weight: 600; background: none; border: none; cursor: pointer; }

.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 4px; }
.qa {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 4px; text-align: center; cursor: pointer; color: var(--ink); position: relative;
}
.qa .ico { font-size: 1.35rem; display: block; margin-bottom: 4px; }
.qa span { font-size: 0.68rem; font-weight: 600; color: var(--muted); }
.qa .badge { top: 4px; right: 8px; }

.rate-banner {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--brand-soft); border: 1px solid var(--gold); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 12px;
}
.rate-banner p { font-size: 0.88rem; font-weight: 600; }

.svc-row {
  display: flex; gap: 12px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; margin-bottom: 9px; cursor: pointer;
}
.svc-row:active { background: var(--surface2); }
.svc-row .emoji { font-size: 1.45rem; }
.svc-row .name { font-weight: 600; font-size: 0.95rem; }
.svc-row .meta { color: var(--muted); font-size: 0.82rem; }
.svc-row .price { margin-left: auto; font-weight: 700; color: var(--brand); white-space: nowrap; }

.appt-card { display: flex; gap: 12px; align-items: center; }
.appt-date {
  background: var(--brand-soft); color: var(--brand-deep); border-radius: 12px; padding: 8px 12px;
  text-align: center; font-weight: 700; min-width: 64px;
}
.appt-date .d { font-size: 1.3rem; line-height: 1.1; }
.appt-date .m { font-size: 0.72rem; }

/* ===== booking ===== */
.date-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.date-strip::-webkit-scrollbar { display: none; }
.date-chip {
  flex: 0 0 auto; width: 62px; padding: 9px 0; text-align: center; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink);
}
.date-chip .wd { font-size: 0.7rem; color: var(--muted); display: block; }
.date-chip .dn { font-weight: 700; font-size: 1.05rem; }
.date-chip.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.date-chip.active .wd { color: rgba(255, 255, 255, 0.8); }
[data-theme="dark"] .date-chip.active { color: #1c1610; }
[data-theme="dark"] .date-chip.active .wd { color: rgba(28, 22, 16, 0.7); }

.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.slot {
  padding: 11px 0; text-align: center; border-radius: 12px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink);
}
.slot.taken { opacity: 0.35; text-decoration: line-through; cursor: not-allowed; }
.slot.active { border-color: var(--brand); background: var(--brand); color: #fff; }
[data-theme="dark"] .slot.active { color: #1c1610; }

.staff-card {
  display: flex; gap: 12px; align-items: center; border: 1.5px solid var(--line);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; cursor: pointer; background: var(--surface);
}
.staff-card.active { border-color: var(--brand); background: var(--brand-soft); }
.staff-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.05rem; font-family: 'Playfair Display', serif;
}
.staff-card .nm { font-weight: 600; font-size: 0.95rem; }
.staff-card .sp { color: var(--muted); font-size: 0.8rem; }
.staff-card .rt { margin-left: auto; text-align: right; font-size: 0.8rem; color: var(--gold); font-weight: 700; white-space: nowrap; }
.staff-card .rt .cnt { display: block; color: var(--muted); font-weight: 500; font-size: 0.72rem; }
.pill {
  display: inline-block; font-size: 0.68rem; font-weight: 700; border-radius: 999px;
  padding: 2px 8px; background: var(--brand-soft); color: var(--brand-deep); margin-left: 6px;
}

.pay-opt {
  display: flex; gap: 12px; align-items: center; border: 1.5px solid var(--line);
  border-radius: 14px; padding: 14px; margin-bottom: 10px; cursor: pointer; background: var(--surface);
}
.pay-opt.active { border-color: var(--brand); background: var(--brand-soft); }
.pay-opt.disabled { opacity: 0.5; cursor: not-allowed; }
.pay-opt .ttl { font-weight: 600; }
.pay-opt .sub { font-size: 0.82rem; color: var(--muted); }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; }
.pay-opt.active .radio { border-color: var(--brand); background: radial-gradient(var(--brand) 0 45%, transparent 50%); }

.summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.95rem; }
.summary-row.total { font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }

/* ===== wallet / codes / bundles ===== */
.amount-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 10px; }
.amount-btn {
  padding: 14px 0; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 1.02rem; cursor: pointer; color: var(--ink);
}
.amount-btn.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); }
.tx-row { display: flex; gap: 12px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.tx-row:last-child { border-bottom: none; }
.tx-icon {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface2); font-size: 1.05rem; flex: 0 0 auto;
}
.tx-amount { margin-left: auto; font-weight: 700; white-space: nowrap; }
.tx-amount.pos { color: var(--ok); }
.tx-amount.neg { color: var(--danger); }
.tx-name { font-weight: 600; font-size: 0.92rem; }
.tx-date { color: var(--muted); font-size: 0.78rem; }

.qr-box { background: #fff; border-radius: 16px; padding: 16px; display: flex; justify-content: center; margin: 14px auto; max-width: 250px; border: 1px solid var(--line); }
.qr-box svg { width: 100%; height: auto; }
.qr-text { word-break: break-all; background: var(--surface2); border-radius: 10px; padding: 10px; font-size: 0.78rem; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 2px dashed var(--gold); background: var(--brand-soft); border-radius: 14px;
  padding: 14px 16px; margin: 12px 0; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.06em;
  color: var(--brand-deep);
}
.gc-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.gc-row:last-child { border-bottom: none; }
.gc-code { font-weight: 700; letter-spacing: 0.04em; }

.bundle-card {
  border: 1.5px solid var(--gold); border-radius: var(--radius); background: var(--surface);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.bundle-card .bnm { font-weight: 700; font-size: 1.02rem; }
.bundle-card .bds { color: var(--muted); font-size: 0.85rem; margin: 4px 0 10px; }
.pkg-bar { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.pkg-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--brand)); border-radius: 999px; }

/* ===== chat ===== */
.chat-wrap { display: flex; flex-direction: column; min-height: calc(100vh - 170px); }
.chat-list { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; }
.bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 0.93rem;
  line-height: 1.45; word-break: break-word; white-space: pre-wrap;
}
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
[data-theme="dark"] .bubble.me { color: #1c1610; }
.bubble.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble .bmeta { display: block; font-size: 0.66rem; opacity: 0.7; margin-top: 3px; }
.chat-input { display: flex; gap: 8px; position: sticky; bottom: calc(var(--tabbar-h) + 10px); background: var(--bg); padding-top: 6px; }
.chat-input input { flex: 1; padding: 12px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); outline: none; }
.chat-input button { border: none; background: var(--brand); color: #fff; border-radius: 50%; width: 46px; height: 46px; font-size: 1.1rem; cursor: pointer; flex: 0 0 auto; }
[data-theme="dark"] .chat-input button { color: #1c1610; }

/* ===== stars ===== */
.stars { display: flex; gap: 6px; justify-content: center; margin: 10px 0 14px; }
.stars button { background: none; border: none; font-size: 2rem; cursor: pointer; color: var(--line); transition: transform 0.1s; }
.stars button.on { color: var(--gold); }
.stars button:active { transform: scale(1.2); }
.star-inline { color: var(--gold); font-weight: 700; }

/* ===== edu ===== */
.edu-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.edu-item:last-child { border-bottom: none; }
.edu-item .ico { font-size: 1.5rem; flex: 0 0 34px; text-align: center; }
.edu-item .nm { font-weight: 600; font-size: 0.95rem; }
.edu-item .ds { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.edu-cat { font-family: 'Playfair Display', serif; color: var(--brand); font-size: 1.05rem; margin: 16px 0 4px; }

/* ===== progress ===== */
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery .ph {
  position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 3/4;
  border: 1px solid var(--line); cursor: pointer; background: var(--surface2);
}
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph .dt {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 0.66rem; padding: 3px 6px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
}
.editor-canvas-wrap { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; touch-action: none; }
.editor-canvas-wrap canvas { width: 100%; display: block; touch-action: none; }
.editor-controls { margin-top: 12px; }
.editor-controls .ctl { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.85rem; }
.editor-controls .ctl label { width: 70px; color: var(--muted); }
.editor-controls input[type="range"] { flex: 1; accent-color: var(--brand); }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare-grid figure { margin: 0; }
.compare-grid img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.compare-grid figcaption { text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 5px; }

/* ===== profile ===== */
.booking-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.booking-item:last-child { border-bottom: none; }
.chip { display: inline-block; font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.chip.confirmed { background: var(--brand-soft); color: var(--brand-deep); }
.chip.done { background: rgba(62, 142, 96, 0.14); color: var(--ok); }
.chip.cancelled { background: rgba(192, 86, 79, 0.12); color: var(--danger); }
.chip.noshow { background: var(--surface2); color: var(--muted); }
.seg { display: flex; background: var(--surface2); border-radius: 12px; padding: 4px; }
.seg button {
  flex: 1; border: none; background: none; padding: 9px; border-radius: 9px;
  font-weight: 600; color: var(--muted); cursor: pointer; font-size: 0.9rem;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.list-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.list-row:last-child { border-bottom: none; }
.list-row .lbl { color: var(--muted); width: 110px; flex: 0 0 auto; font-size: 0.85rem; }
.link-row {
  display: flex; align-items: center; gap: 10px; padding: 13px 2px; border-bottom: 1px solid var(--line);
  cursor: pointer; font-weight: 600; font-size: 0.93rem; color: var(--ink); background: none; border-left: none; border-right: none; border-top: none; width: 100%; text-align: left;
}
.link-row:last-child { border-bottom: none; }
.link-row .arr { margin-left: auto; color: var(--muted); }

/* ===== tab bar ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: var(--tabbar-h);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 40;
}
.tabbar .tab {
  flex: 1; border: none; background: none; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 0.68rem; font-weight: 600;
}
.tabbar .tab svg { width: 23px; height: 23px; }
.tabbar .tab.active { color: var(--brand); }

/* ===== modal & toast ===== */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 14, 6, 0.55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 560px) { .modal-back { align-items: center; } }
.modal {
  background: var(--bg); border-radius: 22px 22px 0 0; width: 100%; max-width: 480px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@media (min-width: 560px) { .modal { border-radius: 22px; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 1.2rem; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

#toastHost { position: fixed; top: 14px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 11px 18px;
  font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow); max-width: 90%;
  animation: toastIn 0.25s ease;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

.skeleton { background: var(--surface2); border-radius: 12px; animation: pulse 1.3s infinite; height: 56px; margin-bottom: 9px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 0.92rem; }
.empty .big { font-size: 2rem; display: block; margin-bottom: 8px; }
