.portal-body {
  min-height: 100vh;
}

.portal-shell {
  min-height: 100vh;
}

.portal-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(18px, 5vw, 68px);
  border-bottom: 1px solid rgba(255, 247, 232, 0.11);
  background: rgba(6, 8, 7, 0.78);
  backdrop-filter: blur(20px) saturate(130%);
}

.portal-topbar nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 247, 232, 0.1);
  border-radius: 999px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.035);
}

.portal-topbar nav a,
.portal-session {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 15px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 900;
}

.portal-session {
  justify-self: end;
  border: 1px solid rgba(55, 241, 154, 0.34);
  color: var(--ink);
}

[data-auth-state="signed-in"] .portal-session {
  color: var(--green);
}

.portal-main {
  padding: 42px clamp(18px, 5vw, 72px) 72px;
}

.portal-hero {
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(340px, 480px);
  gap: clamp(26px, 6vw, 82px);
  align-items: center;
  padding: clamp(28px, 6vw, 70px) 0 50px;
  border-bottom: 1px solid var(--line);
}

.portal-hero h1 {
  max-width: 9ch;
}

.portal-hero p:not(.eyebrow) {
  max-width: 690px;
  color: var(--text);
  font-size: clamp(18px, 2.1vw, 25px);
  font-weight: 650;
  line-height: 1.42;
}

.login-console,
.identity-card,
.presence-meter,
.device-card,
.preference-builder,
.temple-preview {
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.018)),
    var(--panel);
}

.login-console {
  display: grid;
  gap: 18px;
  padding: 18px;
  box-shadow: 0 28px 92px rgba(0, 0, 0, 0.34);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid rgba(255, 247, 232, 0.1);
  border-radius: 14px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.18);
}

.mode-switch button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.mode-switch button.active {
  background: rgba(55, 241, 154, 0.14);
  color: var(--ink);
}

.portal-form {
  display: grid;
  gap: 14px;
}

.portal-form [hidden] {
  display: none !important;
}

.portal-form h2 {
  font-size: clamp(34px, 5vw, 58px);
}

.portal-form label,
.preference-builder label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 900;
}

.portal-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 247, 232, 0.18);
  border-radius: 12px;
  padding: 0 13px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--ink);
  outline: 0;
}

.portal-form input:focus {
  border-color: rgba(55, 241, 154, 0.62);
  box-shadow: 0 0 0 3px rgba(55, 241, 154, 0.13);
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
}

.form-status[data-tone="danger"] {
  color: #ffb0a6;
}

.form-status[data-tone="success"] {
  color: var(--green);
}

.portal-submit,
.identity-card button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #051008;
  cursor: pointer;
  font-weight: 950;
}

.portal-submit:disabled {
  cursor: wait;
  opacity: 0.68;
}

.portal-dashboard {
  display: grid;
  grid-template-columns: 1.1fr 0.82fr 0.9fr;
  gap: 14px;
  padding-top: 34px;
}

.portal-dashboard article {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 20px;
}

.portal-dashboard small,
.device-list span {
  color: var(--gold);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.portal-dashboard strong {
  font-size: clamp(26px, 3.2vw, 40px);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.portal-dashboard span,
.temple-lab p {
  color: var(--soft);
  font-size: 14px;
  line-height: 1.58;
}

.identity-card button {
  width: max-content;
  min-width: 112px;
  min-height: 40px;
  padding: 0 16px;
}

.device-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.device-list span {
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.device-list span.online {
  border: 1px solid rgba(55, 241, 154, 0.28);
  background: rgba(55, 241, 154, 0.13);
  color: var(--green);
}

.temple-lab {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 0.9fr);
  gap: clamp(28px, 6vw, 80px);
  align-items: start;
  padding-top: 78px;
}

.preference-builder {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.preference-builder input[type="range"] {
  accent-color: var(--green);
}

.temple-preview {
  --preview-surface: 0.5;
  --preview-scale: 18px;
  --preview-glow: 0.74;
  min-height: 210px;
  display: grid;
  align-content: end;
  gap: 10px;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(55, 241, 154, calc(var(--preview-glow) * 0.24)), transparent),
    rgba(255, 255, 255, var(--preview-surface));
  box-shadow: 0 0 calc(var(--preview-glow) * 62px) rgba(55, 241, 154, 0.18);
}

.temple-preview span {
  color: var(--gold);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.temple-preview strong {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

.temple-preview p {
  margin: 0;
  color: var(--soft);
  font-size: var(--preview-scale);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .portal-topbar,
  .portal-hero,
  .temple-lab {
    grid-template-columns: 1fr;
  }

  .portal-topbar nav,
  .portal-session {
    justify-self: stretch;
  }

  .portal-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .mode-switch {
    grid-template-columns: 1fr;
  }

  .portal-main {
    padding-top: 28px;
  }
}
