/* Metal America Design System — RTO Flow v2 */
:root {
  --ma-red: #FF2400;
  --ma-red-hover: #D42F4D;
  --ma-red-pressed: #B01C2E;
  --ma-red-light: #FFF5F6;
  --ma-red-border: #FFBDC9;
  --ma-black: #0A0A0A;
  --ma-white: #FFFFFF;
  --ma-gray-100: #F7F7F7;
  --ma-gray-200: #EBF0F4;
  --ma-gray-300: #E4E9EC;
  --ma-gray-400: #D8DCE0;
  --ma-gray-500: #BABEC1;
  --ma-gray-600: #989B9D;
  --ma-gray-700: #717375;
  --ma-gray-800: #5D5F61;
  --ma-gray-900: #3D3F40;
  --ma-shadow-1: 0px 1px 2px rgba(0,0,0,0.12);
  --ma-shadow-2: 0px 4px 8px rgba(0,0,0,0.10);
  --ma-shadow-3: 0px 8px 28px rgba(0,0,0,0.15);
  --ma-shadow-glow: 0 6px 18px rgba(255,36,0,0.25);
  --ma-radius-sm: 8px;
  --ma-radius-md: 12px;
  --ma-radius-lg: 16px;
  --ma-radius-pill: 9999px;
  --ma-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --topbar-h: 56px;
  --footer-h: 40px;
}

* { box-sizing: border-box; }
*[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--ma-font);
  font-size: 16px;
  line-height: 22px;
  color: var(--ma-black);
  background: var(--ma-gray-100);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--ma-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ TOPBAR ============ */
.topbar {
  background: var(--ma-white);
  border-bottom: 1px solid var(--ma-gray-200);
  flex-shrink: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: inline-flex; align-items: center; }
.brand img { height: 26px; width: auto; display: block; }
.brand-tag {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ma-gray-700);
  padding-left: 14px;
  border-left: 1px solid var(--ma-gray-300);
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  background: var(--ma-red-light);
  color: var(--ma-red);
  border: 1px solid var(--ma-red-border);
  border-radius: var(--ma-radius-pill);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 200ms ease;
}
.ref-pill:hover {
  background: var(--ma-red);
  color: var(--ma-white);
  border-color: var(--ma-red);
  text-decoration: none;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--ma-gray-300);
  background: var(--ma-white);
  color: var(--ma-gray-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 200ms ease;
}
.icon-btn:hover { background: var(--ma-gray-100); color: var(--ma-black); }
.help-menu {
  position: absolute;
  top: 42px;
  right: 0;
  background: var(--ma-white);
  border: 1px solid var(--ma-gray-300);
  border-radius: var(--ma-radius-md);
  box-shadow: var(--ma-shadow-2);
  min-width: 220px;
  padding: 6px;
  z-index: 20;
}
.help-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--ma-radius-sm);
  color: var(--ma-black);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.help-menu a:hover { background: var(--ma-gray-100); text-decoration: none; }
.help-menu a svg { color: var(--ma-gray-600); }

/* ============ STAGE — fills remaining viewport ============ */
.stage {
  flex: 1 0 auto;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.progress {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 6px;
  flex-shrink: 0;
}
.progress-seg {
  flex: 1;
  height: 6px;
  border-radius: var(--ma-radius-pill);
  background: var(--ma-gray-300);
  transition: background 250ms ease;
}
.progress-seg.is-done { background: var(--ma-red); }
.progress-seg.is-active { background: var(--ma-red); }
.progress-meta {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ma-gray-700);
  margin-left: 6px;
  white-space: nowrap;
}

/* ============ STEP CARD ============ */
.step-card {
  background: var(--ma-white);
  border: 1px solid var(--ma-gray-300);
  border-radius: var(--ma-radius-lg);
  padding: 24px 28px;
  box-shadow: var(--ma-shadow-1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ma-red);
}
.step-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 30px;
  color: var(--ma-black);
  margin: 0;
}
.step-body {
  font-size: 14px;
  line-height: 20px;
  color: var(--ma-gray-800);
  margin: 0;
}
.step-body strong { color: var(--ma-black); font-weight: 600; }

/* Mascot — only used on Done */
.mascot-wrap { display: flex; justify-content: center; align-items: center; }
.mascot-wrap img { width: 160px; max-width: 50%; height: auto; display: block; }

/* ============ NUMBERED CHECKLIST ============ */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--ma-gray-100);
  border-radius: var(--ma-radius-md);
  padding: 14px 16px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
}
.check-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ma-red);
  color: var(--ma-white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--ma-font);
}
.check-text {
  font-size: 14px;
  line-height: 22px;
  color: var(--ma-black);
  min-width: 0;
  overflow-wrap: anywhere;
}
.check-text strong { font-weight: 600; }

/* ============ HELPERS ============ */
.helpers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.helper {
  border: 1px solid var(--ma-gray-300);
  border-radius: var(--ma-radius-md);
  background: var(--ma-white);
  overflow: hidden;
}
.helper-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ma-black);
  user-select: none;
  min-width: 0;
}
.helper-summary::-webkit-details-marker { display: none; }
.helper-summary > span { min-width: 0; overflow-wrap: anywhere; }
.helper-summary .chev {
  margin-left: auto;
  color: var(--ma-gray-600);
  transition: transform 200ms ease;
  flex-shrink: 0;
}
.helper[open] .helper-summary .chev { transform: rotate(180deg); }
.helper-summary .ic {
  width: 26px;
  height: 26px;
  border-radius: var(--ma-radius-sm);
  background: var(--ma-red-light);
  color: var(--ma-red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.helper-body { padding: 12px 14px 14px; border-top: 1px solid var(--ma-gray-200); }

.creds-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
.cred-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--ma-gray-100);
  border-radius: var(--ma-radius-sm);
}
.cred-key {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ma-gray-700);
  width: 72px;
  flex-shrink: 0;
}
.cred-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ma-black);
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.copy-btn {
  background: var(--ma-white);
  border: 1px solid var(--ma-gray-300);
  border-radius: var(--ma-radius-sm);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ma-gray-800);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 150ms ease;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--ma-gray-100); border-color: var(--ma-gray-400); }

.helper-img {
  width: 100%;
  border-radius: var(--ma-radius-sm);
  border: 1px solid var(--ma-gray-200);
  cursor: zoom-in;
  display: block;
  max-height: 180px;
  object-fit: contain;
  object-position: top left;
  background: var(--ma-white);
}
.helper-caption { font-size: 12px; color: var(--ma-gray-700); line-height: 18px; margin: 8px 0 0; }
.legend-intro { font-size: 12px; color: var(--ma-gray-800); margin: 0 0 8px; line-height: 18px; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--ma-gray-100);
  border-radius: var(--ma-radius-sm);
  font-size: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.legend-region { font-weight: 600; color: var(--ma-black); }
.legend-maker { color: var(--ma-gray-700); margin-left: 4px; }

/* ============ ACTION ROW ============ */
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  flex-shrink: 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--ma-radius-pill);
  padding: 12px 24px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 200ms ease;
  text-decoration: none;
  line-height: 20px;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--ma-red); outline-offset: 2px; }
.btn-primary {
  background: var(--ma-red);
  color: var(--ma-white);
  flex: 1;
  box-shadow: var(--ma-shadow-glow);
}
.btn-primary:hover { background: var(--ma-red-hover); text-decoration: none; }
.btn-primary:active { background: var(--ma-red-pressed); }
.btn-ghost {
  background: transparent;
  color: var(--ma-gray-800);
  padding: 12px 16px;
}
.btn-ghost:hover { background: var(--ma-gray-100); color: var(--ma-black); }
.btn .arrow { transition: transform 200ms ease; }
.btn-primary:hover .arrow { transform: translateX(3px); }

/* ============ FOOTER ============ */
.footer {
  flex-shrink: 0;
  padding: 12px 16px 18px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ma-gray-600);
  background: transparent;
  border: none;
}

/* ============ LIGHTBOX ============ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--ma-radius-md); box-shadow: var(--ma-shadow-3); }
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ma-white);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ma-black);
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ma-black);
  color: var(--ma-white);
  padding: 10px 18px;
  border-radius: var(--ma-radius-pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--ma-shadow-2);
  z-index: 200;
  animation: toastIn 200ms ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.step-card { animation: cardIn 220ms cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ DONE SCREEN ============ */
.done-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
  min-height: 0;
}
.done-wrap .step-title { text-align: center; }
.done-wrap .step-body { text-align: center; max-width: 460px; }

/* ============ RESPONSIVE — MOBILE ============ */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }
  .stage { padding: 14px 14px 24px; gap: 12px; }
  .step-card { padding: 20px 18px; gap: 14px; }
  .step-title { font-size: 20px; line-height: 26px; }
  .step-body { font-size: 14px; line-height: 20px; }
  .legend-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 14px; gap: 10px; }
  .brand-tag { display: none; }
  .ref-pill span { display: none; }
  .ref-pill { padding: 0 11px; height: 32px; }
  .icon-btn { width: 32px; height: 32px; }
  .action-row { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .btn-primary, .btn-ghost { width: 100%; min-height: 48px; }
  .cred-row { flex-wrap: wrap; gap: 6px; }
  .cred-key { width: 100%; }
  .cred-value { flex: 1 1 auto; font-size: 12px; word-break: break-all; }
  .copy-btn { flex-shrink: 0; }
  .helper-img { max-height: 220px; }
  .progress-meta { font-size: 10px; }
  .mascot-wrap img { width: 120px; }
  .help-menu { right: -2px; min-width: 200px; }
}

/* ============ AUTH GATE ============ */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #F7F8FA 0%, #EEF1F5 100%);
  overflow-y: auto;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--ma-white);
  border: 1px solid var(--ma-gray-200);
  border-radius: var(--ma-radius-lg);
  box-shadow: var(--ma-shadow-3);
  padding: 36px 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: gateIn 280ms cubic-bezier(.2,.7,.2,1) both;
}
@keyframes gateIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-logo { height: 30px; width: auto; margin-bottom: 4px; }
.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ma-black);
  margin: 0;
  line-height: 28px;
}
.auth-sub {
  font-size: 14px;
  line-height: 20px;
  color: var(--ma-gray-700);
  margin: 0 0 8px;
}
.auth-gsi {
  display: flex;
  justify-content: center;
  min-height: 44px;
  width: 100%;
}
.auth-gsi > div {  /* GSI's wrapper */
  margin: 0 auto;
}
.auth-error {
  font-size: 13px;
  line-height: 18px;
  color: #B01C2E;
  background: var(--ma-red-light);
  border: 1px solid var(--ma-red-border);
  padding: 10px 12px;
  border-radius: var(--ma-radius-sm);
  margin: 4px 0 0;
  text-align: left;
}
.auth-fine {
  font-size: 12px;
  color: var(--ma-gray-600);
  margin: 8px 0 0;
  line-height: 18px;
}
.auth-fine code {
  background: var(--ma-gray-100);
  border: 1px solid var(--ma-gray-200);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
  color: var(--ma-gray-800);
}

/* App is hidden visually until unlocked (aria-hidden=true) */
#app[aria-hidden="true"] {
  visibility: hidden;
  pointer-events: none;
}

/* ============ USER CHIP + SIGN OUT ============ */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px 0 4px;
  background: var(--ma-gray-100);
  border: 1px solid var(--ma-gray-300);
  border-radius: var(--ma-radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--ma-gray-900);
  max-width: 180px;
}
.user-chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ma-red);
  color: var(--ma-white);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.user-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.help-menu-divider {
  height: 1px;
  background: var(--ma-gray-200);
  margin: 6px 0;
}
.help-menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--ma-radius-sm);
  color: var(--ma-black);
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.help-menu-btn:hover { background: var(--ma-gray-100); }
.help-menu-btn svg { color: var(--ma-gray-600); }

@media (max-width: 640px) {
  .user-chip-name { display: none; }   /* avatar only on mobile */
  .user-chip { padding: 0 4px; }
  .auth-card { padding: 28px 22px 22px; }
  .auth-title { font-size: 20px; }
}

/* Custom Sign in with Google button (Firebase-powered) */
.gsi-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--ma-white);
  border: 1px solid var(--ma-gray-300);
  color: var(--ma-gray-900);
  font-family: var(--ma-font);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: var(--ma-radius-pill);
  cursor: pointer;
  box-shadow: var(--ma-shadow-1);
  transition: background 160ms ease, box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
  min-height: 44px;
}
.gsi-btn:hover {
  background: var(--ma-gray-100);
  border-color: var(--ma-gray-400);
  box-shadow: var(--ma-shadow-2);
}
.gsi-btn:active { transform: translateY(1px); }
.gsi-btn:focus-visible {
  outline: 2px solid var(--ma-red);
  outline-offset: 3px;
}
.gsi-placeholder {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--ma-gray-100);
  border: 1px solid var(--ma-gray-300);
  color: var(--ma-gray-700);
  font-family: var(--ma-font);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: var(--ma-radius-pill);
  min-height: 44px;
}
