:root {
  --bg: #0a0a0c;
  --surface: #141417;
  --surface-elevated: #1c1c21;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --text-muted: #8e8e93;
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.14);
  --amber: #ff9f0a;
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.14);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  min-height: 100vh;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 4px 2px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  color: var(--text);
}

.tier-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.tier-btn.is-pro {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-elevated);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

h2 {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 0.98rem;
  font-weight: 600;
}

.muted-sm {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.section-block {
  margin-top: 16px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* Identity Verification Row */
.verify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.verify-row.is-verified {
  border-color: rgba(48, 209, 88, 0.35);
  background: rgba(48, 209, 88, 0.07);
}

.verify-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.verify-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--text-muted);
}

.verify-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.verify-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.verify-btn {
  padding: 7px 13px;
  border-radius: 999px;
  border: none;
  background: var(--text);
  color: #0a0a0c;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  flex-shrink: 0;
}

.verify-btn.is-subtle {
  background: transparent;
  color: var(--green);
  border: 1px solid rgba(48, 209, 88, 0.35);
}

/* Photo Grid */
.photo-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-slot {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
}

.photo-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-add-btn {
  width: 100%;
  height: 100%;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
}

.photo-add-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
}

.photo-add-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.slot-tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 0.64rem;
  font-weight: 650;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(10, 10, 12, 0.8);
  color: var(--green);
}

.slot-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 10, 12, 0.85);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
}

.quick-capture-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.quick-capture-link:hover {
  color: var(--text);
}

/* Segmented Timer Control */
.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
}

.seg-btn {
  padding: 8px 4px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.is-selected {
  background: var(--surface-elevated);
  color: var(--text);
}

.seg-btn.is-locked {
  opacity: 0.45;
}

/* Toggle Row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #2c2c31;
  cursor: pointer;
  transition: 0.18s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s;
}

.switch input:checked + .slider {
  background: var(--green);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 0.12s ease, transform 0.08s ease;
}

.btn:active {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text);
  color: #0a0a0c;
}

.btn-secondary {
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.btn-danger {
  background: var(--red-soft);
  border: 1px solid rgba(255, 69, 58, 0.35);
  color: #ff6961;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

/* Link box */
.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  margin: 14px 0;
}

.link-box code {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: var(--text);
  color: #0a0a0c;
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
}

/* Viewer */
.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.countdown-pill {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.countdown-pill.is-urgent {
  background: var(--red-soft);
  border-color: rgba(255, 69, 58, 0.5);
  color: var(--red);
}

.viewer-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 460px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
}

.viewer-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hold-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 20px;
  background: rgba(10, 10, 12, 0.22);
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.hold-overlay.is-hidden {
  opacity: 0;
}

.hold-pill {
  background: rgba(10, 10, 12, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 10, 12, 0.65);
  color: var(--text);
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 4;
}

.carousel-arrow-prev {
  left: 10px;
}

.carousel-arrow-next {
  right: 10px;
}

/* iOS-style PageControl indicator */
.page-control-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.page-dots {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.page-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.page-dot.is-active {
  background: var(--text);
  transform: scale(1.25);
}

.page-count-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.78);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
}

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  margin-bottom: 12px;
}

.camera-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-oval {
  position: absolute;
  inset: 14% 20%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  pointer-events: none;
  transition: border-color 0.2s ease;
}

.camera-oval.is-ready {
  border-color: var(--green);
}

.camera-status-pill {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: rgba(10, 10, 12, 0.84);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.liveness-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-elevated);
  overflow: hidden;
  margin-bottom: 14px;
}

.liveness-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 0.2s ease;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.plan-box {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
}

.plan-box-pro {
  border-color: var(--border-strong);
  background: var(--surface-elevated);
}

.plan-title {
  font-weight: 650;
  font-size: 0.88rem;
}

.plan-price {
  font-size: 1.25rem;
  font-weight: 750;
  margin: 4px 0 8px;
}

.plan-price span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.plan-list {
  list-style: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
