:root {
  --bg: #121325;
  --bg-2: #1a1c36;
  --surface: #1e2545;
  --surface-glass: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --ink: #ede8da;
  --ink-soft: #c9c2ab;
  --ink-faint: #8f886f;

  --accent: #e3a544;
  --accent-2: #39a67f;
  --accent-grad: linear-gradient(135deg, #e3a544 0%, #39a67f 100%);
  --on-accent: #241a08;

  --success: #39a67f;
  --warning: #fbbf5a;
  --danger: #d65a4a;
  --danger-soft: rgba(214, 90, 74, 0.14);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  /* iOS PWA safe-area padding */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}
p {
  margin: 0;
}
a {
  color: var(--accent);
}
[hidden] {
  display: none !important;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.topbar h1 {
  font-size: 1.05rem;
  flex: 1;
}
.topbar .icon-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  padding: 6px;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}
.topbar .back-btn {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1.4rem;
  padding: 4px 8px 4px 0;
  cursor: pointer;
}

.mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mark svg {
  width: 14px;
  height: 14px;
}

.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}
.content.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ---------- welcome ---------- */
.welcome-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.welcome-mark svg {
  width: 32px;
  height: 32px;
}
.tagline {
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 34ch;
  margin: 10px 0 30px;
  line-height: 1.5;
}

/* ---------- forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input,
.field select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}
.otp-input {
  font-size: 1.6rem;
  letter-spacing: 0.5em;
  text-align: center;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn-primary {
  background: var(--accent-grad);
  color: var(--on-accent);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink);
}
.btn-outline.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px;
}
.btn-text:disabled {
  color: var(--ink-faint);
  cursor: default;
}
.btn-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.error-text {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 10px 0;
}
.hint-text {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 18px;
}

/* ---------- cards / lists ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.card + .card {
  margin-top: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.row:last-child {
  border-bottom: none;
}
.row-main {
  flex: 1;
  min-width: 0;
}
.row-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.row-sub {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 2px;
}
.row-chevron {
  color: var(--ink-faint);
  font-size: 1.2rem;
}
.row.tappable {
  cursor: pointer;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 14px 16px 6px;
}

/* switch */
.switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: none;
  flex: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.switch.on {
  background: var(--accent-grad);
}
.switch.on::after {
  transform: translateX(18px);
}
.switch:disabled {
  opacity: 0.5;
  cursor: default;
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 60px 20px;
  font-size: 0.92rem;
}

/* ---------- home ---------- */
.stats-row {
  display: flex;
  align-items: center;
  padding: 4px 2px 18px;
}
.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stat-value {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
}
.stat-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 1px;
}
.stat-divider {
  width: 1px;
  height: 30px;
  margin: 0 14px;
  background: var(--border);
  flex: none;
}
.stat.align-end {
  align-items: flex-end;
  margin-left: auto;
  text-align: right;
}
.footer-hint {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.76rem;
  padding: 14px 12px 6px;
}
.empty-state-detail {
  color: var(--ink-faint);
  font-size: 0.82rem;
  margin-top: 8px;
  max-width: 34ch;
  margin-left: auto;
  margin-right: auto;
}

.contact-line {
  color: var(--ink-faint);
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.review-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 12px;
  cursor: pointer;
}
.review-link svg {
  width: 15px;
  height: 15px;
}

.purpose-item {
  border-bottom: 1px solid var(--border);
}
.purpose-item:last-child {
  border-bottom: none;
}
.purpose-item .row {
  border-bottom: none;
}
.notice-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px 12px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.76rem;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.notice-text {
  padding: 0 16px 14px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.5;
}

.fab {
  position: fixed;
  bottom: 24px;
  right: calc(50% - 240px + 24px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--on-accent);
  border: none;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab svg {
  width: 26px;
  height: 26px;
}
@media (max-width: 480px) {
  .fab {
    right: 24px;
  }
}

/* ---------- QR scanner ---------- */
.scanner-wrap {
  position: relative;
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.scanner-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-frame {
  position: absolute;
  width: 62%;
  aspect-ratio: 1;
  border: 3px solid var(--accent);
  border-radius: 20px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.45);
}
.scanner-footer {
  padding: 18px 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.scanner-status {
  color: var(--ink-soft);
  font-size: 0.85rem;
  min-height: 1.2em;
  text-align: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(36, 26, 8, 0.3);
  border-top-color: var(--on-accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
