:root {
  color-scheme: light;
  --bg: #f3efe7;
  --bg-soft: #f8f5ef;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-border: rgba(46, 43, 38, 0.12);
  --text: #161413;
  --muted: #5e5851;
  --accent: var(--portal-accent, #3a6ea5);
  --accent-soft: var(--portal-accent-soft, rgba(58, 110, 165, 0.14));
  --accent-strong: var(--portal-accent-strong, #274d79);
  --success: #1f7a4f;
  --error: #a9352a;
  --shadow: 0 20px 60px rgba(21, 18, 14, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 40%),
    linear-gradient(160deg, #fbf8f2 0%, var(--bg) 45%, #ece3d4 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family:
    "Iowan Old Style",
    "Palatino Linotype",
    "Book Antiqua",
    Georgia,
    serif;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, var(--accent-soft), transparent 28%),
    radial-gradient(circle at 85% 0%, rgba(255, 255, 255, 0.42), transparent 20%),
    radial-gradient(circle at 85% 85%, rgba(0, 0, 0, 0.04), transparent 24%);
  opacity: 0.95;
}

.portal-custom::before,
.portal-custom::after {
  display: none;
}

.portal-theme-civic {
  --bg: #f6f4f1;
  --bg-soft: #fffdf8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(237, 1, 57, 0.16);
  --text: #171717;
  --muted: #55514e;
  --shadow: 0 24px 70px rgba(80, 0, 20, 0.12);
  font-family:
    Arial,
    Helvetica,
    ui-sans-serif,
    system-ui,
    sans-serif;
}

.portal-theme-genome {
  --bg: #edf5f1;
  --bg-soft: #fbfcfb;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(0, 110, 97, 0.13);
  --text: #18191f;
  --muted: #52615d;
  --shadow: 0 24px 70px rgba(0, 76, 67, 0.14);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

.portal-theme-civic::before {
  background:
    linear-gradient(90deg, rgba(237, 1, 57, 0.08), rgba(255, 210, 0, 0.1) 42%, rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 244, 241, 0.5));
}

.portal-theme-genome::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.1)),
    url("/static/genome-background.png") center bottom / cover no-repeat;
  opacity: 1;
}

.portal-theme-genome::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(0, 155, 123, 0.08), rgba(255, 255, 255, 0) 48%);
}

.portal-shell {
  position: relative;
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero {
  padding: clamp(24px, 4vw, 40px);
  margin-bottom: 20px;
}

.portal-theme-civic .hero {
  position: relative;
  overflow: hidden;
}

.portal-theme-genome .hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 220px);
  gap: clamp(20px, 4vw, 42px);
  align-items: center;
  overflow: hidden;
}

.portal-theme-genome .hero .eyebrow-row,
.portal-theme-genome .hero h1,
.portal-theme-genome .hero .lede,
.portal-theme-genome .hero .civic-banner {
  grid-column: 1;
}

.portal-theme-genome .hero .genome-identity {
  grid-column: 2;
  grid-row: 1 / span 4;
}

.portal-theme-civic .hero::after {
  content: "";
  position: absolute;
  inset: auto clamp(22px, 4vw, 40px) 0 auto;
  width: min(42%, 420px);
  height: 5px;
  background: linear-gradient(90deg, #ed0139, #ffd200);
}

.portal-theme-genome .hero::after {
  content: "";
  position: absolute;
  inset: auto 4% 0 auto;
  width: 260px;
  height: 4px;
  background: linear-gradient(90deg, #ff3030, #ff8a00, #c2d500, #009b7b, #20a9cb, #6b2a86);
}

.eyebrow-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow-muted {
  color: var(--muted);
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.portal-theme-genome h1 {
  max-width: 11ch;
  letter-spacing: 0;
}

.lede {
  max-width: 60ch;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.04rem;
}

.genome-identity {
  justify-self: center;
  width: min(100%, 220px);
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(0, 110, 97, 0.1);
  box-shadow: 0 18px 44px rgba(0, 76, 67, 0.12);
}

.genome-identity img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.hero-meta div,
.info-list div {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(46, 43, 38, 0.08);
}

.civic-banner {
  display: grid;
  gap: 12px;
  margin-top: 28px;
  padding: 18px 20px;
  border-radius: 22px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(7, 35, 61, 0.96), rgba(12, 56, 94, 0.92)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0));
  box-shadow: 0 18px 40px rgba(7, 35, 61, 0.2);
}

.portal-theme-civic .civic-banner {
  border-radius: 8px;
  background:
    linear-gradient(135deg, #ed0139, #b0002b),
    linear-gradient(90deg, rgba(255, 210, 0, 0.2), rgba(255, 255, 255, 0));
  box-shadow: 0 18px 42px rgba(176, 0, 43, 0.18);
}

.portal-theme-genome .civic-banner {
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 110, 97, 0.96), rgba(0, 76, 67, 0.94)),
    linear-gradient(90deg, rgba(255, 138, 0, 0.18), rgba(255, 255, 255, 0));
  box-shadow: 0 18px 40px rgba(0, 76, 67, 0.18);
}

.civic-banner p {
  max-width: 44ch;
  color: rgba(255, 255, 255, 0.84);
}

.civic-banner-mark strong {
  display: block;
  font-size: 1.32rem;
  letter-spacing: -0.03em;
}

.civic-banner .meta-label {
  color: rgba(255, 255, 255, 0.7);
}

.meta-label,
.info-list dt {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.content-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
}

.portal-flow-terms_only .content-grid {
  grid-template-columns: minmax(0, 1fr);
}

.form-panel,
.info-panel {
  padding: clamp(20px, 3vw, 28px);
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 1.4rem;
  letter-spacing: -0.03em;
}

.panel-header p {
  margin-top: 8px;
  color: var(--muted);
}

.coa-form {
  display: grid;
  gap: 18px;
}

.consent-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 249, 252, 0.96));
  border: 1px solid rgba(7, 35, 61, 0.08);
}

.consent-panel-header {
  display: grid;
  gap: 8px;
}

.consent-panel h3 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.04em;
}

.consent-kicker {
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.terms-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 1.4rem;
  color: var(--muted);
}

.terms-list li {
  padding-left: 0.2rem;
}

.terms-toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(12, 56, 94, 0.06);
  border: 1px solid rgba(12, 56, 94, 0.1);
}

.terms-toggle input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent-strong);
}

.terms-toggle span {
  color: var(--text);
  font-weight: 600;
}

.terms-toggle a {
  color: var(--accent-strong);
  font-weight: 800;
  text-underline-offset: 3px;
}

.terms-agreement {
  margin: 0;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(12, 56, 94, 0.06);
  border: 1px solid rgba(12, 56, 94, 0.1);
  color: var(--text);
  font-weight: 600;
}

.terms-agreement a {
  color: var(--accent-strong);
  font-weight: 800;
  text-underline-offset: 3px;
}

.portal-theme-genome .consent-panel {
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 250, 247, 0.96));
}

.portal-theme-genome .terms-toggle,
.portal-theme-genome .terms-agreement {
  border-radius: 8px;
  background: rgba(0, 155, 123, 0.07);
  border-color: rgba(0, 110, 97, 0.13);
}

.portal-theme-genome .button-primary {
  background: linear-gradient(135deg, #009b7b, #006e61);
}

.portal-theme-civic .button-primary {
  background: linear-gradient(135deg, #ed0139, #b0002b);
}

.portal-theme-civic .button-primary:focus-visible {
  outline: 4px solid rgba(255, 210, 0, 0.72);
  outline-offset: 3px;
}

.session-card {
  display: grid;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 24px;
  background: rgba(12, 56, 94, 0.04);
  border: 1px solid rgba(12, 56, 94, 0.08);
}

.session-card-header {
  display: grid;
  gap: 6px;
}

.session-card-header h3 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.session-card-header p {
  color: var(--muted);
  font-size: 0.94rem;
}

.session-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.advanced-panel {
  border-radius: 22px;
  border: 1px solid rgba(46, 43, 38, 0.1);
  background: rgba(255, 255, 255, 0.54);
  padding: 14px 16px 16px;
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
  list-style: none;
}

.advanced-panel summary::-webkit-details-marker {
  display: none;
}

.advanced-panel[open] summary {
  margin-bottom: 14px;
}

.advanced-grid {
  margin-top: 14px;
}

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

.field-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid rgba(46, 43, 38, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font: inherit;
  padding: 14px 16px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.field textarea {
  resize: vertical;
  min-height: 108px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #7f776d;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: translateY(-1px);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 16px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 28px rgba(21, 18, 14, 0.16);
}

.button-primary:disabled {
  cursor: progress;
  opacity: 0.72;
}

.helper {
  color: var(--muted);
  font-size: 0.92rem;
}

.helper code,
.info-list code {
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  background: rgba(255, 255, 255, 0.72);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  border-radius: 20px;
  padding: 16px 18px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.72);
}

.status-pending {
  border-color: rgba(46, 43, 38, 0.14);
  color: var(--muted);
}

.status-pending::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: portal-spin 0.8s linear infinite;
}

.status-success {
  border-color: rgba(31, 122, 79, 0.24);
  color: var(--success);
}

.status-error {
  border-color: rgba(169, 53, 42, 0.24);
  color: var(--error);
}

.custom-portal-shell {
  min-height: 100vh;
  background:
    var(--custom-bg-image, none),
    var(--custom-bg-color, #f3f4f6);
  background-position: center;
  background-repeat: var(--custom-bg-repeat, no-repeat), repeat;
  background-size: var(--custom-bg-size, cover), auto;
  color: #111827;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  overflow: auto;
}

.custom-portal-form {
  min-height: 100vh;
}

.custom-portal-stage {
  position: relative;
  width: min(100vw, 1180px);
  min-height: 100vh;
  margin: 0 auto;
}

.custom-portal-element {
  position: absolute;
  display: block;
  border: 0;
  border-radius: 0;
  padding: clamp(10px, 1.6vw, 22px);
  overflow-wrap: anywhere;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.14);
}

.custom-portal-element-transparent {
  box-shadow: none;
}

.custom-portal-text {
  line-height: 1.2;
}

.custom-portal-image {
  height: auto;
  object-fit: contain;
  padding: 0;
}

.custom-portal-image-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  text-decoration: none;
}

.custom-portal-image-link .custom-portal-image {
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.custom-portal-connect {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
}

.custom-portal-connect:disabled {
  cursor: progress;
  opacity: 0.72;
}

.coa-submit-loading {
  position: relative;
}

.coa-submit-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  transform: translateY(-50%);
  animation: portal-button-spin 0.8s linear infinite;
}

.custom-portal-connect-default {
  position: absolute;
  left: 8%;
  top: 40%;
  width: 36%;
  min-height: 56px;
  border: 0;
  background: #111827;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.custom-status {
  position: fixed;
  left: 50%;
  bottom: 18px;
  width: min(560px, calc(100vw - 32px));
  transform: translateX(-50%);
  z-index: 4;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.16);
}

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

@keyframes portal-button-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.portal-flow-terms_only .form-panel {
  padding: clamp(22px, 4vw, 34px);
  max-width: 780px;
  margin: 0 auto;
}

.portal-theme-genome.portal-flow-terms_only .form-panel,
.portal-theme-civic.portal-flow-terms_only .form-panel {
  max-width: 980px;
}

.portal-flow-terms_only .panel-header {
  margin-bottom: 14px;
}

.portal-flow-terms_only .button-primary {
  min-width: 220px;
}

.portal-flow-terms_only .helper {
  max-width: 44ch;
}

.portal-theme-genome .form-actions,
.portal-theme-civic .form-actions {
  flex-wrap: nowrap;
  gap: 18px 22px;
}

.portal-theme-genome .form-actions .terms-agreement,
.portal-theme-civic .form-actions .terms-agreement {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.portal-theme-civic .form-actions .terms-agreement a {
  color: #b0002b;
}

.info-list {
  display: grid;
  gap: 14px;
}

.info-list dd {
  color: var(--muted);
}

@media (max-width: 900px) {
  .content-grid,
  .field-grid,
  .hero-meta {
    grid-template-columns: 1fr;
  }

  .portal-theme-genome .hero {
    grid-template-columns: 1fr;
  }

  .portal-theme-genome .hero .genome-identity {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    max-width: 170px;
  }

  .portal-theme-genome .form-actions,
  .portal-theme-civic .form-actions {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .portal-shell {
    width: min(100vw - 20px, 1120px);
    padding: 10px 0 20px;
  }

  .panel {
    border-radius: 22px;
  }

  .hero,
  .form-panel,
  .info-panel {
    padding: 18px;
  }

  h1 {
    max-width: none;
  }

  .session-grid {
    grid-template-columns: 1fr;
  }

  .custom-portal-stage {
    width: 100vw;
    min-height: 100vh;
  }

  .custom-portal-element {
    padding: 12px;
  }
}
