*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

a { color: inherit; text-decoration: none; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }

.hidden { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; }
.sublead { margin-top: 0.375rem; max-width: 56ch; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
  border-radius: var(--radius-sm);
}

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --panel: #f9fafb;
  --card: #ffffff;
  --card-2: #f4f5f7;
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --text: #1f2937;
  --muted: #6b7280;
  --muted2: #9ca3af;

  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);

  --radius: 8px;
  --radius-sm: 6px;

  --accent: #3b82f6;
  --accent2: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;

  --focus: rgba(59, 130, 246, 0.5);

  --profile-accent: var(--accent);
  --profile-accent-2: var(--accent2);
  --profile-accent-soft: rgba(59, 130, 246, 0.14);
  --profile-accent-2-soft: rgba(16, 185, 129, 0.12);
  --profile-focus: rgba(59, 130, 246, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --panel: #1f2937;
    --card: #1f2937;
    --card-2: #374151;
    --border: #374151;
    --border-2: #4b5563;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --muted2: #6b7280;

    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-soft: 0 1px 3px 0 rgba(0, 0, 0, 0.25), 0 1px 2px 0 rgba(0, 0, 0, 0.2);

    --focus: rgba(59, 130, 246, 0.5);
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 0.75rem;
  top: 0.75rem;
  z-index: 999;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  outline: none;
}

.container {
  width: min(1280px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.375rem 0 3.125rem;
}
.panel { padding-top: 0.5rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  width: min(1280px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 0.875rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  flex-wrap: wrap; /* allows mobile wrapping */
}
.brand {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}
.brand:focus-visible { border-radius: var(--radius-sm); }

.logo {
  width: 2.625rem;
  height: 2.625rem;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
}
.logo-img {
  width: 100%;
  height: 100%;
  display: block;
}
.brand-text .title {
  font-weight: 700;
  line-height: 1.1;
}
.brand-text .subtitle {
  font-size: 0.875rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap; /* allows buttons/search to wrap on small screens */
  min-width: 0;
}

.layout {
  display: grid;
  grid-template-columns: 22.5rem 1fr;
  gap: 1.125rem;
  align-items: start;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .layout-aside { order: 0; }
}
.layout-aside.sticky {
  position: sticky;
  top: 5.375rem;
}
@media (max-width: 980px) {
  .layout-aside.sticky { position: static; top: auto; }
}

#view-home {
  min-height: calc(100svh - 7.25rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
#view-home .layout {
  flex: 1 1 auto;
  min-height: 0;
}
#view-home .layout-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tests-window {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 0.25rem;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
}
.card.subtle {
  background: var(--card-2);
  box-shadow: none;
}
.hero { padding: 1.125rem; }

.kicker {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.875rem;
  color: var(--muted);
  letter-spacing: 0.025px;
}
.hero-title {
  margin: 0.5rem 0 0;
  font-size: 1.875rem;
  line-height: 1.2;
  letter-spacing: -0.025rem;
}

.bullet-list {
  margin: 0.5rem 0 0;
  padding-left: 1.125rem;
}
.bullet-list li { margin: 0.375rem 0; }

.home-bottom { margin-top: 0; }
.about-card { padding: 1.125rem; }
.about-head { margin-bottom: 0.75rem; }
.about-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 980px) {
  .about-grid { grid-template-columns: 1fr; }
}
.about-p { margin: 0.5rem 0 0; max-width: 70ch; }
.about-col:first-child .about-p:first-child { margin-top: 0; }

.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}
.pagehead h2, .pagehead h1 { margin: 0; }
.page-actions {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.025px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.btn:active { box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn-block { width: 100%; }
.btn:focus { outline: none; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--focus); }

.pill, .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.375rem 0.625rem;
  font-weight: 600;
  font-size: 0.875rem;
  background: var(--card-2);
}
.pill.subtle, .chip.subtle {
  background: transparent;
  font-weight: 600;
  color: var(--muted);
}

.search {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  background: var(--card-2);
  width: 16.25rem;
  max-width: 100%;
  min-width: 0; /* IMPORTANT: allow shrink in flex rows on mobile */
  flex: 1 1 16.25rem;
}
.search-icon { color: var(--muted); }
.search-input {
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  width: 100%;
  font-size: 0.875rem;
  min-width: 0;
}
.search-input::placeholder { color: var(--muted2); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
}

.test-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.875rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-2);
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.test-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.test-card:focus { outline: none; }
.test-card:focus-visible { box-shadow: 0 0 0 3px var(--focus); }

.test-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.test-card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025rem;
}
.test-card-desc {
  margin-top: 0.375rem;
  color: var(--muted);
}
.test-card-meta {
  margin-top: 0.625rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  color: var(--muted2);
  font-size: 0.875rem;
}
.test-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text);
  border-radius: 999px;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border);
  background: var(--card-2);
}

.questions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

fieldset.q {
  min-width: 0;
  margin: 0;
}

.q {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-2);
  padding: 0.875rem;
  box-shadow: none;
}
.q legend {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
  padding: 0;
  flex-wrap: wrap; /* mobile: allow wrap */
}
.qnum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.625rem;
  height: 1.875rem;
  padding: 0 0.625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  font-weight: 700;
  color: var(--muted);
}
.qtext {
  font-weight: 700;
  letter-spacing: -0.025rem;
}
.q.unanswered {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
}

.choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice:hover { border-color: var(--border-2); }
.choice:active { background: var(--card-2); }

.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.choice:focus-within { box-shadow: 0 0 0 3px var(--focus); }

.choice-ui {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 999px;
  border: 2px solid var(--muted2);
  margin-top: 0.125rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
.choice-ui::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: transparent;
  transform: scale(0.6);
  transition: transform 0.15s ease, background 0.15s ease;
}
.choice-text {
  font-weight: 500;
  color: var(--text);
}

.choice-input:checked ~ .choice-ui { border-color: var(--accent); }
.choice-input:checked ~ .choice-ui::after {
  background: var(--accent);
  transform: scale(1);
}
.choice.is-checked {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}
.choice.is-checked .choice-ui { border-color: var(--accent); }
.choice.is-checked .choice-ui::after {
  background: var(--accent);
  transform: scale(1);
}

@supports selector(:has(*)) {
  .choice:has(input:checked) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
  }
  .choice:has(input:checked) .choice-ui { border-color: var(--accent); }
  .choice:has(input:checked) .choice-ui::after {
    background: var(--accent);
    transform: scale(1);
  }
}

.actions-bar {
  margin-top: 0.875rem;
  position: sticky;
  bottom: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem;
  box-shadow: var(--shadow);
}
@media (max-width: 760px) {
  .actions-bar { position: static; bottom: auto; }
}
.row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}
.space-between { justify-content: space-between; }

.progress-wrap { display: flex; flex-direction: column; gap: 0.625rem; }
.progress-head { display: flex; justify-content: space-between; gap: 0.625rem; }
.progress {
  height: 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.625rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
}

.alert {
  margin-top: 0.75rem;
  border: 1px solid var(--danger);
  background: rgba(239, 68, 68, 0.05);
  padding: 0.75rem;
  border-radius: var(--radius);
  color: var(--text);
}

.result-archetype {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025rem;
}
.result-summary {
  margin-top: 0.375rem;
  color: var(--muted);
}
.result-pills {
  margin-top: 0.625rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.closest-profile-banner {
  margin: 0.625rem 0 1rem;
  padding: 1.125rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-2);
  box-shadow: var(--shadow);
}
.closest-profile-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
@media (max-width: 760px) {
  .closest-profile-banner-inner {
    flex-direction: column;
    align-items: stretch;
  }
}
.closest-profile-banner-left { min-width: 0; }
.closest-profile-kicker {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.spark {
  width: 1.625rem;
  height: 1.625rem;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--card-2);
  box-shadow: var(--shadow-soft);
}
.closest-profile-title {
  margin-top: 0.5rem;
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025rem;
}
.closest-profile-meta {
  margin-top: 0.625rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}
#closest-profile-blurb { color: var(--muted); }
.closest-profile-banner-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 22.5rem;
}
@media (max-width: 760px) {
  .closest-profile-banner-right {
    align-items: stretch;
    max-width: none;
  }
}

.meter {
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.meter-track {
  position: relative;
  height: 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  overflow: hidden;
}
.meter-center {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--border-2);
}
.meter-fill {
  position: absolute;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
}
.meter-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0.625rem;
  height: 1.375rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--bg);
  box-shadow: var(--shadow-soft);
}
.meter-foot { margin-top: 0.625rem; }

.metrics {
  margin-top: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.metric-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.625rem;
}
.metric-name { font-weight: 600; }
.metric-value { font-weight: 700; }
.metric-bar {
  margin-top: 0.375rem;
  height: 0.625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  overflow: hidden;
}
.metric-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
}
.metric-hint { margin-top: 0.375rem; }

.section { margin-top: 1rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.625rem;
}
.section-head h2 { margin: 0; }

.insight-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.insight {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  background: var(--card-2);
}
.insight-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.insight-q {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-weight: 600;
}
.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.375rem 0.625rem;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
}
.tag.neg { background: rgba(16, 185, 129, 0.1); }
.tag.pos { background: rgba(59, 130, 246, 0.1); }
.tag.neu { background: rgba(107, 114, 128, 0.1); }

.impactbox {
  margin-top: 0.625rem;
  border-top: 1px solid var(--border);
  padding-top: 0.625rem;
}
.impact-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.375rem;
}
.impact-track {
  height: 0.625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  overflow: hidden;
}
.impact-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
}

.accordion {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-2);
}
.acc-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.acc-btn:focus { outline: none; }
.acc-btn:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }
.acc-panel { padding: 0.875rem; }
.acc-chevron { color: var(--muted); }

.share-row {
  display: flex;
  gap: 0.625rem;
  margin-top: 0.5rem;
}
.share-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  background: var(--card-2);
  color: var(--text);
  min-width: 0;
}

.perq-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
  flex-wrap: wrap;
}
.perq {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.perq-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--card-2);
}
.perq-left { flex: 1; min-width: 0; }
.perq-title {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-weight: 600;
}
.perq-right {
  width: 11.25rem;
  flex: 0 0 auto;
}
.perq-impact {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.profile-hero .profile-blurb {
  margin-top: 0.5rem;
  font-weight: 500;
  color: var(--muted);
}
.profile-kind-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.profile-sections {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.profile-section {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.profile-section::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--profile-accent), var(--profile-accent-2));
  opacity: 0.8;
}
.profile-section-head {
  padding: 0.875rem 0.875rem 0;
}
.profile-section-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.profile-section-head h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025rem;
}
.section-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  display: grid;
  place-items: center;
  color: var(--muted);
}
.section-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}
.profile-body {
  padding: 0.625rem 0.875rem 0.875rem;
  color: var(--muted);
}
.profile-p { margin: 0.625rem 0 0; }
.profile-bullets {
  margin: 0.625rem 0 0;
  padding-left: 1.125rem;
}
.profile-bullets li { margin: 0.375rem 0; }

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* Uniform “Other profiles” card layout */
.profile-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-2);
  padding: 0.75rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 4.25rem;
}
.profile-item:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.profile-item.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.profile-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.profile-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-item-title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-item-sub {
  margin-top: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 1.1rem; /* keeps cards same height even if blurb is empty */
}

.profile-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.375rem;
  flex: 0 0 auto;
}

/* Profile hero layout */
.profile-page-hero {
  display: flex;
  gap: 0.875rem;
  align-items: center;
}

.profile-page-img {
  width: 4.75rem;
  flex: 0 0 auto;
  position: relative;
  display: grid;
  place-items: center;
}

/* Sigil styling */
.profile-sigil {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:
    radial-gradient(closest-side at 30% 30%, var(--profile-accent-soft), transparent 70%),
    radial-gradient(closest-side at 70% 70%, var(--profile-accent-2-soft), transparent 70%),
    var(--card);
  box-shadow: var(--shadow-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.profile-sigil svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Large sigil for hero (replaces avatar) */
.profile-sigil-lg {
  width: 4.75rem;
  height: 4.75rem;
  border-radius: 16px;
}

.profile-item-sigil {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
}

.profile-page-title {
  margin: 0.5rem 0 0;
  font-size: 1.875rem;
  line-height: 1.2;
  letter-spacing: -0.025rem;
}
.profile-page-sub {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.profile-essence {
  margin-top: 0.625rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:
    linear-gradient(90deg, var(--profile-accent-soft), var(--profile-accent-2-soft));
  color: var(--muted);
  font-weight: 700;
  font-size: 0.875rem;
}

.toc {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.toc a {
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.625rem;
  background: var(--card-2);
  color: var(--muted);
  font-weight: 600;
}
.toc a:hover {
  color: var(--text);
  border-color: var(--border-2);
}
.toc a:focus-visible { box-shadow: 0 0 0 3px var(--focus); }

.footer {
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}
.footer-inner {
  width: min(1280px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1rem 0 1.375rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.375rem;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  min-width: 13.75rem;
  text-align: center;
  max-width: calc(100% - 2.5rem); /* mobile safe */
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

.compass {
  border: 1px solid var(--border);
  background: var(--card-2);
  border-radius: var(--radius);
  padding: 0.625rem;
  box-shadow: none;
}
.compass.small { padding: 0.5rem; }
.compass svg {
  display: block;
  width: 100%;
  height: auto;
}

.axis-chips {
  margin-top: 0.625rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.axis-chip {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.profile-theme {
  --accent: var(--profile-accent);
  --accent2: var(--profile-accent-2);
  --focus: var(--profile-focus);
}

.profile-theme .pill,
.profile-theme .chip {
  border-color: rgba(255,255,255,0.0);
  background:
    linear-gradient(90deg, var(--profile-accent-soft), var(--profile-accent-2-soft));
}
.profile-theme .pill.subtle,
.profile-theme .chip.subtle {
  background: transparent;
  border-color: var(--border);
}

/* -----------------------------
   Mobile-specific improvements
   ----------------------------- */

/* Phones: stack header sections, reduce gutters, avoid fixed-width columns */
@media (max-width: 600px) {
  .container {
    width: min(1280px, calc(100% - 2rem));
    padding: 1rem 0 2.5rem;
  }
  .topbar-inner,
  .footer-inner {
    width: min(1280px, calc(100% - 2rem));
  }

  .topbar-inner {
    padding: 0.75rem 0;
    align-items: flex-start;
  }

  /* Make actions take full width under brand when needed */
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  /* Search should become full-width in the header row on phones */
  .search {
    width: 100%;
    flex: 1 1 100%;
  }

  /* Page headers: stack title + actions */
  .pagehead {
    flex-direction: column;
    align-items: stretch;
  }
  .page-actions {
    width: 100%;
  }

  /* Reduce card padding slightly for narrow screens */
  .card { padding: 0.875rem; }
  .hero { padding: 1rem; }

  /* Large titles scale down */
  .hero-title { font-size: 1.5rem; }
  .closest-profile-title { font-size: 1.25rem; }
  .profile-page-title { font-size: 1.5rem; }

  /* Avoid “two-column” feeling and fixed widths */
  .perq-row {
    flex-direction: column;
    align-items: stretch;
  }
  .perq-right {
    width: 100%;
  }

  /* Share row should stack */
  .share-row {
    flex-direction: column;
  }

  /* Prevent horizontal overflow in tight flex rows */
  .row { flex-wrap: wrap; }

  /* Home view: avoid awkward min-height issues on some mobile browsers */
  #view-home { min-height: 0; }

  /* Tests window: remove right padding so it doesn't feel clipped */
  .tests-window { padding-right: 0; }
}

/* Small phones: tighten brand + hero further */
@media (max-width: 420px) {
.logo {
  width: 2.375rem;
  height: 2.375rem;
}
  .brand { gap: 0.625rem; }
  .brand-text .subtitle { font-size: 0.8125rem; }

  .hero-title { font-size: 1.375rem; }

  .profile-page-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .profile-page-img {
    width: auto;
  }
  .profile-sigil-lg {
    width: 4.25rem;
    height: 4.25rem;
  }

  .profile-item {
    align-items: flex-start;
  }
  .profile-item-meta {
    align-items: flex-start;
  }

  .toast {
    min-width: 0;
    width: calc(100% - 2rem);
  }
}