:root {
  --teal: #006b6b;
  --teal-dark: #004f4f;
  --teal-deep: #003c3c;
  --teal-light: #e0f2f2;
  --gold: #f5a623;
  --gold-light: #fef3dc;
  --gold-ink: #6b4a00;
  --green: #2a7a3b;
  --green-light: #d6f0db;
  --red: #c0392b;
  --red-light: #fdf0ef;
  --ink: #1a1a16;
  --grey: #6b6860;
  --grey-light: #f0efea;
  --border: #e0ddd6;
  --page: #f7f6f2;
  --surface: #fff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: 'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .top-title, .hero-name, .big {
  font-family: 'Cabinet Grotesk', 'General Sans', -apple-system, sans-serif;
  letter-spacing: -0.01em;
}

a { color: var(--teal); }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* top bar */
.top {
  background: var(--teal-deep);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}

.top-in {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
}

.top-title { font-size: 20px; font-weight: 800; line-height: 1.1; }
.top-sub { font-size: 12px; opacity: 0.75; letter-spacing: 0.08em; text-transform: uppercase; }

/* page */
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px calc(40px + env(safe-area-inset-bottom));
}

.loading { text-align: center; padding: 80px 0; color: var(--grey); }

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .bar-fill { transition: none; }
}

/* hero */
.hero {
  margin: 16px 0 0;
  padding: 20px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(245, 166, 35, 0.16);
}

.hero-top { display: flex; gap: 16px; align-items: center; position: relative; z-index: 1; }

.avatar {
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: rgba(255, 255, 255, 0.15);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-size: 34px;
  font-weight: 800;
  padding: 0;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
}

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

.hero-id { min-width: 0; }
.hero-hello { font-size: 13px; opacity: 0.8; }
.hero-name { font-size: 26px; font-weight: 800; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
.hero-sub { font-size: 14px; opacity: 0.85; margin-top: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
}

.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.pill.ok .pill-dot { background: #6fe08a; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
  position: relative;
  z-index: 1;
}

.stat {
  background: rgba(255, 255, 255, 0.11);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0;
}

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; opacity: 0.75; }
.big { font-size: 22px; font-weight: 800; line-height: 1.2; }
.stat-note { font-size: 12px; opacity: 0.75; }
.star { color: var(--gold); }

/* layout */
.cols { display: grid; gap: 0 24px; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
  .hero { padding: 28px; }
  .hero-name { font-size: 32px; }
  .avatar { flex-basis: 104px; width: 104px; height: 104px; }
}

.section-title {
  margin: 26px 2px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-pad { padding: 16px; }

/* attention */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid transparent;
}

.alert-icon {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
}

.alert-title { font-weight: 700; }
.alert-text { font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }

.alert.urgent { background: var(--red-light); border-color: #f2c9c4; }
.alert.urgent .alert-icon { background: var(--red); }
.alert.urgent .alert-title { color: var(--red); }

.alert.soon { background: var(--gold-light); border-color: #f6dfae; }
.alert.soon .alert-icon { background: var(--gold); }
.alert.soon .alert-title { color: var(--gold-ink); }

.alert.good { background: var(--green-light); border-color: #b9e2c1; }
.alert.good .alert-icon { background: var(--green); }
.alert.good .alert-title { color: var(--green); }

.alert.info { background: var(--teal-light); border-color: #bfe1e1; }
.alert.info .alert-icon { background: var(--teal); }
.alert.info .alert-title { color: var(--teal-dark); }

.alert-when { font-size: 12px; color: var(--grey); margin-top: 2px; }

/* steps */
.bar-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.bar { height: 8px; border-radius: 4px; background: var(--grey-light); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 4px; background: var(--green); transition: width 0.5s; }

.step {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.tick {
  flex: 0 0 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.step.done .tick { background: var(--green); border-color: var(--green); }
.step-label { font-weight: 600; }
.step.done .step-label { color: var(--grey); }
.step-hint { font-size: 13px; color: var(--grey); }

/* documents */
.doc {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  align-items: flex-start;
}

.doc:first-child, .step:first-child { border-top: 0; }

.doc-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--grey-light);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--grey);
  cursor: pointer;
}

.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb[disabled] { cursor: default; }

.doc-main { flex: 1; min-width: 0; }
.doc-name { font-weight: 700; }
.doc-sub { font-size: 13px; color: var(--grey); }
.doc-sub.warn { color: var(--gold-ink); font-weight: 600; }
.doc-sub.bad { color: var(--red); font-weight: 600; }

.doc-note {
  margin-top: 6px;
  padding: 8px 10px;
  border-left: 3px solid var(--red);
  background: var(--red-light);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chip {
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--grey-light);
  color: var(--grey);
}

.chip.accepted, .chip.on_file { background: var(--green-light); color: var(--green); }
.chip.review { background: var(--gold-light); color: var(--gold-ink); }
.chip.rejected, .chip.expired, .chip.missing { background: var(--red-light); color: var(--red); }

.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--grey); background: #fbfaf7; }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 380px) { .tiles { grid-template-columns: 1fr; } }

.tile {
  display: block;
  padding: 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: #fff;
  background: var(--teal);
  box-shadow: var(--shadow);
}

.tile.gold { background: var(--gold); color: #3b2800; }
.tile-title { font-family: 'Cabinet Grotesk', sans-serif; font-size: 18px; font-weight: 800; line-height: 1.2; }
.tile-sub { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.tile-go { font-size: 13px; font-weight: 700; margin-top: 10px; }

/* rules */
.rule { display: flex; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 15px; }
.rule:first-child { border-top: 0; }
.rule-mark { flex: 0 0 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.rule.do .rule-mark { background: var(--green); }
.rule.dont .rule-mark { background: var(--red); }

details > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: '+'; font-size: 22px; line-height: 1; color: var(--teal); }
details[open] > summary::after { content: '–'; }
details[open] > summary { border-bottom: 1px solid var(--border); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn.wa { background: #1faa59; }
.btn.block { display: flex; width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal); text-decoration: underline; cursor: pointer; }

.foot { margin-top: 28px; text-align: center; font-size: 13px; color: var(--grey); }

/* no-session screen */
.gate { max-width: 440px; margin: 48px auto 0; text-align: center; }
.gate img { width: 160px; height: 160px; object-fit: contain; }
.gate h1 { font-size: 26px; margin: 8px 0; }
.gate p { color: var(--grey); margin: 0 0 20px; }

/* viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  color: #fff;
}

.viewer-title { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-close { background: none; border: 0; color: #fff; font-size: 34px; line-height: 1; width: 48px; height: 48px; cursor: pointer; }
.viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; color: #fff; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* achievements */
.next { border-bottom: 1px solid var(--border); }
.next .bar-fill { background: linear-gradient(90deg, var(--gold), #ffcf70); }

.badges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 8px;
  padding: 18px 12px;
}

@media (min-width: 560px) { .badges { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 900px) { .badges { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.badge { text-align: center; min-width: 0; }

/* A medal: scalloped outer ring, bright rim, face with the number. */
.medal {
  --m1: #e9a46b;
  --m2: #a85f2a;
  --ink-m: #4a2508;
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(from 0deg, var(--m2), var(--m1), var(--m2), var(--m1), var(--m2), var(--m1), var(--m2), var(--m1), var(--m2));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.medal::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #fff 0%, var(--m1) 38%, var(--m2) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), inset 0 -6px 10px rgba(0, 0, 0, 0.14);
}

.medal-face {
  position: relative;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-m);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.badge.silver .medal { --m1: #e8ecef; --m2: #8e9aa3; --ink-m: #2c3840; }
.badge.gold .medal { --m1: #ffd874; --m2: #d98e00; --ink-m: #573500; }
.badge.diamond .medal { --m1: #8fe3e3; --m2: #006b6b; --ink-m: #003c3c; }

.badge-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.badge-how { font-size: 12px; color: var(--grey); line-height: 1.3; margin-top: 2px; }
.badge.earned .badge-how { color: var(--green); font-weight: 600; }

.badge.locked .medal {
  background: var(--grey-light);
  box-shadow: inset 0 0 0 2px var(--border);
}

.badge.locked .medal::before {
  background: #faf9f6;
  box-shadow: inset 0 0 0 2px var(--border);
}

.badge.locked .medal-face { color: #b9b5ab; text-shadow: none; }
.badge.locked .badge-title { color: var(--grey); }

/* uploads */
.chip.todo { background: var(--grey-light); color: var(--grey); }

.photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
  padding: 16px;
}

@media (min-width: 560px) { .photos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.photo { position: relative; min-width: 0; }

.photo-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--grey-light);
  overflow: hidden;
  cursor: pointer;
}

.photo-frame.empty { border: 2px dashed #c9c5ba; background: #fbfaf7; color: var(--teal); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-plus { font-size: 30px; line-height: 1; font-weight: 300; }
.photo-add { font-size: 13px; font-weight: 700; }

.photo-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
.photo-name { font-weight: 700; min-width: 0; }
.photo-hint { font-size: 12px; color: var(--grey); line-height: 1.35; margin-top: 2px; }
.photo-replace { font-size: 13px; margin-top: 4px; min-height: 32px; }

.photo-busy {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.88);
  font-weight: 700;
  color: var(--teal);
}

.photo.busy .photo-busy { display: flex; }

.up-action { border-top: 1px solid var(--border); }
.btn[disabled] { opacity: 0.6; cursor: default; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--teal-deep);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.toast.bad { background: var(--red); }

.photo-name { font-size: 15px; line-height: 1.25; }
.photo-row .chip { font-size: 11px; padding: 2px 8px; }
