:root {
  /* Color tokens */
  --color-ink: #242424;
  --color-page: #f4f4f4;
  --color-surface: #ffffff;
  --color-surface-subtle: #fafafa;
  --color-border: #dedede;
  --color-border-input: #bdbdbd;
  --color-text-muted: #686868;
  --color-text-label: #3d3d3d;
  --color-accent: #4a4a4a;
  --color-accent-hover: #303030;
  --color-accent-soft: rgb(74 74 74 / 18%);
  --color-accent-label: #606060;
  --color-error: #555555;
  --color-on-accent: #ffffff;

  /* Typography tokens */
  --font-family-sans:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --font-size-eyebrow: 0.78rem;
  --font-size-label: 0.9rem;
  --font-size-heading-min: 1.75rem;
  --font-size-heading-max: 2.25rem;
  --font-weight-label: 600;
  --font-weight-strong: 700;
  --letter-spacing-eyebrow: 0.1em;
  --line-height-heading: 1.1;
  --line-height-body: 1.5;
  --line-height-error: 1.4;

  /* Spacing tokens */
  --space-page: 24px;
  --space-card: 40px;
  --space-card-mobile-block: 30px;
  --space-card-mobile-inline: 24px;
  --space-eyebrow-bottom: 10px;
  --space-intro-top: 12px;
  --space-intro-bottom: 28px;
  --space-form-gap: 9px;
  --space-label-top: 8px;
  --space-input-block: 12px;
  --space-input-inline: 13px;
  --space-button-top: 16px;
  --space-button-block: 13px;
  --space-button-inline: 16px;
  --space-error-top: 10px;

  /* Layout tokens */
  --page-min-height: 100vh;
  --card-width: 420px;
  --space-action-gap: 16px;

  /* Shape tokens */
  --radius-card: 16px;
  --radius-control: 8px;

  /* Depth tokens */
  --shadow-card: 0 16px 40px rgb(0 0 0 / 8%);

  color: var(--color-ink);
  background: var(--color-page);
  font-family: var(--font-family-sans);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

.page {
  min-height: var(--page-min-height);
  display: grid;
  place-items: center;
  padding: var(--space-page);
}

.card {
  width: min(100%, var(--card-width));
  padding: var(--space-card);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.eyebrow {
  margin: 0 0 var(--space-eyebrow-bottom);
  color: var(--color-accent-label);
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-strong);
  letter-spacing: var(--letter-spacing-eyebrow);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(
    var(--font-size-heading-min),
    5vw,
    var(--font-size-heading-max)
  );
  line-height: var(--line-height-heading);
}

.intro {
  margin: var(--space-intro-top) 0 var(--space-intro-bottom);
  color: var(--color-text-muted);
  line-height: var(--line-height-body);
}

form {
  display: grid;
  gap: var(--space-form-gap);
}

label {
  margin-top: var(--space-label-top);
  color: var(--color-text-label);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-label);
}

.optional-label {
  color: var(--color-text-muted);
  font-weight: 400;
}

input {
  width: 100%;
  padding: var(--space-input-block) var(--space-input-inline);
  color: var(--color-ink);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-control);
}

input:focus {
  outline: 3px solid var(--color-accent-soft);
  border-color: var(--color-accent-label);
}

button {
  margin-top: var(--space-button-top);
  padding: var(--space-button-block) var(--space-button-inline);
  color: var(--color-on-accent);
  background: var(--color-accent);
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
  font-weight: var(--font-weight-strong);
}

button:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-error {
  margin: var(--space-error-top) 0 0;
  color: var(--color-error);
  font-size: var(--font-size-label);
  line-height: var(--line-height-error);
}

.form-message,
.status-message,
.account-email {
  margin: var(--space-error-top) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-label);
  line-height: var(--line-height-body);
}

.account-email {
  margin-bottom: var(--space-intro-bottom);
}

.secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-action-gap);
  margin-top: var(--space-action-gap);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-action-gap);
}

.form-actions .secondary-button {
  margin-top: var(--space-button-top);
}

.text-button {
  margin: 0;
  padding: 0;
  color: var(--color-text-muted);
  background: transparent;
  border-radius: 0;
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-label);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover:not(:disabled) {
  color: var(--color-ink);
  background: transparent;
}

.secondary-button {
  width: 100%;
  color: var(--color-ink);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border-input);
}

.secondary-button:hover:not(:disabled) {
  background: var(--color-border);
}

#clerk-captcha {
  margin-top: var(--space-action-gap);
}

@media (max-width: 480px) {
  .card {
    padding: var(--space-card-mobile-block) var(--space-card-mobile-inline);
  }

  .secondary-actions {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Authenticated account shell */
.authenticated-shell,
.authenticated-shell-content {
  min-height: 100dvh;
}

.authenticated-shell-content {
  width: 100%;
  padding-left: 56px;
}

.account-rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 56px;
  align-items: center;
  flex-direction: column;
  padding: 14px 8px;
  background: rgb(250 250 249 / 94%);
  border-right: 1px solid rgb(61 68 79 / 14%);
  box-shadow: 5px 0 18px rgb(35 42 54 / 4%);
  backdrop-filter: blur(10px);
}

.account-rail-button,
.account-drawer-close {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  color: #596273;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
}

.account-rail-button:hover:not(:disabled),
.account-drawer-close:hover:not(:disabled) {
  color: #283142;
  background: #eff1f3;
  border-color: #dfe2e6;
}

.account-rail-button:focus-visible,
.account-drawer-close:focus-visible,
.account-drawer-actions button:focus-visible,
.account-drawer-backdrop:focus-visible {
  outline: 3px solid rgb(78 91 112 / 28%);
  outline-offset: 2px;
}

.account-rail-button svg,
.account-drawer-close svg,
.account-drawer-signout svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.account-rail-initial {
  display: grid;
  width: 32px;
  height: 32px;
  margin-top: 20px;
  place-items: center;
  color: #4f596b;
  background: #eceff3;
  border: 1px solid #dce1e8;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
}

.account-rail-signout {
  margin-top: auto;
}

.account-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 31;
  width: 100%;
  margin: 0;
  padding: 0;
  pointer-events: none;
  opacity: 0;
  background: rgb(31 38 49 / 22%);
  border: 0;
  border-radius: 0;
  transition: opacity 220ms ease;
}

.account-drawer-backdrop.is-open {
  pointer-events: auto;
  opacity: 1;
}

.account-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 32;
  display: flex;
  width: min(280px, 88vw);
  padding: 22px 20px;
  flex-direction: column;
  color: #293142;
  background: #fbfbfa;
  border-right: 1px solid #d9dde3;
  box-shadow: 16px 0 42px rgb(31 38 49 / 13%);
  transform: translateX(-102%);
  visibility: hidden;
  transition:
    transform 240ms ease,
    visibility 0s linear 240ms;
}

.account-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  transition:
    transform 240ms ease,
    visibility 0s linear 0s;
}

.account-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.account-drawer-eyebrow {
  margin: 0;
  color: #727b89;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.account-drawer-identity {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 34px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e0e3e7;
}

.account-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #465064;
  background: #e9edf2;
  border: 1px solid #d7dde5;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
}

.account-drawer-name,
.account-drawer-email {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-drawer-name {
  font-size: 0.98rem;
  font-weight: 700;
}

.account-drawer-email {
  margin-top: 4px;
  color: #737c8a;
  font-size: 0.78rem;
}

.account-drawer-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.account-drawer-actions button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 0;
  padding: 11px 12px;
  color: #394356;
  background: transparent;
  border: 1px solid #dfe3e8;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.account-drawer-actions button:hover:not(:disabled) {
  color: #252d3b;
  background: #f0f2f4;
  border-color: #d2d7df;
}

.account-drawer-actions .account-drawer-signout {
  color: #596273;
}

@media (max-width: 640px) {
  .account-rail {
    width: 52px;
    padding-inline: 6px;
  }

  .account-drawer {
    width: min(320px, 88vw);
  }

  .authenticated-shell-content {
    padding-left: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .account-drawer,
  .account-drawer-backdrop {
    transition: none;
  }
}

/* Reflection experience */
.reflection-page {
  min-height: 100dvh;
  padding: clamp(12px, 2vw, 20px);
  color: #273248;
  background: #f0f1f4;
}

.reflection-environment {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: calc(100dvh - clamp(24px, 4vw, 40px));
  overflow: hidden;
  background: #f9fafb;
  border: 1px solid #d9dce2;
  border-radius: clamp(22px, 3vw, 30px);
  box-shadow: 0 10px 35px rgb(48 57 75 / 6%);
}

.reflection-environment::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(rgb(249 250 251 / 32%), rgb(249 250 251 / 32%)),
    url("/reflection-lake.png") center / cover no-repeat;
  content: "";
  pointer-events: none;
}

.reflection-background {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.reflection-blob {
  position: absolute;
  border-radius: 48%;
  will-change: transform;
}

.reflection-blob-one {
  top: 3%;
  left: 24%;
  width: 25%;
  height: 44%;
  background: #e8edf6;
  opacity: 0.8;
}

.reflection-blob-two {
  bottom: 8%;
  left: 20%;
  width: 29%;
  height: 47%;
  background: #e4ebf8;
  opacity: 0.7;
}

.reflection-blob-three {
  top: 23%;
  right: 14%;
  width: 22%;
  height: 39%;
  background: #eef0f7;
  opacity: 0.8;
}

.reflection-stage {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: clamp(64px, 9vh, 92px) clamp(20px, 5vw, 64px)
    clamp(112px, 16vh, 144px);
}

.reflection-card {
  width: min(100%, 680px);
  padding: clamp(42px, 6vw, 56px);
  background: rgb(255 254 250 / 90%);
  border: 1px solid rgb(92 107 133 / 16%);
  border-radius: 27px;
  box-shadow: 0 18px 50px rgb(54 64 86 / 5.5%);
  backdrop-filter: blur(3px);
  transition:
    opacity 700ms ease,
    transform 700ms ease;
}

.reflection-card-receded {
  opacity: 0.76;
  transform: scale(0.965);
}

.reflection-question {
  margin: 0;
  color: #273248;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.35rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.045em;
  text-align: center;
}

.reflection-response {
  min-height: 0;
  margin-top: clamp(42px, 7vw, 56px);
}

.reflection-listening {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 4px;
  color: #8994a6;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

.reflection-listening-dot {
  position: relative;
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  background: #edf1f7;
  border-radius: 50%;
  animation: reflection-breathe 2.4s ease-in-out infinite;
}

.reflection-listening-ring {
  position: absolute;
  inset: 0;
  border: 1px solid #aab8ce;
  border-radius: 50%;
  animation: reflection-listening-ring 2.4s ease-out infinite;
}

.reflection-listening-center {
  width: 6px;
  height: 6px;
  background: #98a9c7;
  border-radius: 50%;
}

.reflection-listening-bars {
  display: flex;
  height: 12px;
  align-items: center;
  gap: 2px;
}

.reflection-listening-bars span {
  width: 2px;
  height: 10px;
  background: #aab8ce;
  border-radius: 999px;
  transform-origin: center;
  animation: reflection-listening-signal 1.8s ease-in-out infinite;
}

.reflection-listening-bars span:first-child {
  height: 6px;
}

.reflection-listening-bars span:nth-child(2) {
  animation-delay: 180ms;
}

.reflection-listening-bars span:nth-child(3) {
  height: 8px;
  animation-delay: 360ms;
}

.reflection-textarea {
  width: 100%;
  min-height: 122px;
  padding: 16px;
  resize: vertical;
  color: #354158;
  background: #fbfcfd;
  border: 1px solid #dfe3ea;
  border-radius: 16px;
  outline: none;
  font: inherit;
  font-size: 1rem;
  line-height: 1.75;
}

.reflection-textarea:focus {
  border-color: #bbc8dc;
  box-shadow: 0 0 0 4px #e9edf5;
}

.reflection-textarea::placeholder {
  color: #aab3c0;
}

.reflection-preparing,
.reflection-cue,
.reflection-checkin-question {
  margin: 0;
  color: #8a94a4;
  font-size: 0.88rem;
}

.reflection-copy {
  margin: 0;
  color: #455169;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
  line-height: 1.45;
}

.reflection-quote {
  color: #273248;
}

.reflection-checkin {
  display: grid;
  gap: 20px;
}

.reflection-checkin-question {
  letter-spacing: 0.04em;
}

.reflection-ended p {
  margin: 0;
  color: #536078;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
}

.reflection-cue {
  margin-top: 16px;
  color: #9aa3af;
}

.reflection-continue {
  position: absolute;
  right: clamp(24px, 3vw, 36px);
  bottom: clamp(24px, 3vw, 32px);
  z-index: 2;
  width: auto;
  margin: 0;
  padding: 12px 20px;
  color: #8e96a2;
  background: rgb(249 250 251 / 86%);
  border: 1px solid #d9dce2;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 400;
  transition:
    background-color 300ms ease,
    border-color 300ms ease,
    color 300ms ease,
    opacity 300ms ease,
    transform 300ms ease;
}

.reflection-continue:hover:not(:disabled) {
  color: #758095;
  background: rgb(249 250 251 / 90%);
  border-color: #cbd2dd;
  transform: translateY(-2px);
}

.reflection-continue:focus-visible {
  outline: 2px solid #aab3c0;
  outline-offset: 3px;
}

.reflection-continue:disabled {
  cursor: default;
  opacity: 0.55;
}

@keyframes reflection-drift-one {
  0%,
  100% {
    transform: translate3d(-18%, -9%, 0) rotate(-5deg);
  }
  25% {
    transform: translate3d(-3%, 7%, 0) rotate(-1deg);
  }
  50% {
    transform: translate3d(16%, 10%, 0) rotate(5deg);
  }
  75% {
    transform: translate3d(9%, -6%, 0) rotate(2deg);
  }
}

@keyframes reflection-drift-two {
  0%,
  100% {
    transform: translate3d(16%, 10%, 0) rotate(5deg);
  }
  25% {
    transform: translate3d(1%, -7%, 0) rotate(1deg);
  }
  50% {
    transform: translate3d(-17%, -11%, 0) rotate(-5deg);
  }
  75% {
    transform: translate3d(-8%, 6%, 0) rotate(-2deg);
  }
}

@keyframes reflection-breathe {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.92);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.06);
  }
}

@keyframes reflection-listening-ring {
  0% {
    opacity: 0.48;
    transform: scale(0.55);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(1.55);
  }
}

@keyframes reflection-listening-signal {
  0%,
  100% {
    opacity: 0.32;
    transform: scaleY(0.45);
  }
  50% {
    opacity: 0.82;
    transform: scaleY(1);
  }
}

@media (max-width: 640px) {
  .reflection-environment::before {
    background-position:
      center,
      52% center;
  }

  .reflection-stage {
    padding-inline: 16px;
  }

  .reflection-card {
    padding: 36px 28px;
  }

  .reflection-blob-one,
  .reflection-blob-two,
  .reflection-blob-three {
    width: 48%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reflection-blob,
  .reflection-listening-dot,
  .reflection-listening-ring,
  .reflection-listening-bars span {
    animation: none;
  }

  .reflection-card,
  .reflection-continue {
    transition: none;
  }

  .reflection-card-receded,
  .reflection-continue:hover:not(:disabled) {
    transform: none;
  }
}