@layer components {
  /* On-paper form row: tracked uppercase label · ink value · quiet edit affordance. */
  .row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    gap: var(--space-4);
  }
  .row:last-child { border-bottom: none; }
  .row .lbl {
    font-size: var(--cap-lg);
    letter-spacing: var(--tracking-cap-tight);
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: var(--weight-semibold);
    flex-shrink: 0;
    min-width: 130px;
  }
  .row .val {
    font-size: 15px;
    color: var(--ink);
    flex: 1;
  }
  .row .val.empty { color: var(--ink-faint); font-style: italic; }
  .row .edit {
    font-size: 12px;
    color: var(--ink-faint);
    border-bottom: 1px solid var(--ink-faint);
    padding-bottom: 1px;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
  }
  .row .edit:hover { color: var(--ink); border-bottom-color: var(--ink); text-decoration: none; }

  .row-required .lbl::after { content: ' *'; color: var(--ink-soft); }

  /* Stacked form fields (used in multi-step solo + first-timer gate). */
  .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
  .field label {
    font-size: var(--cap-lg);
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: var(--tracking-cap-tight);
    font-weight: var(--weight-semibold);
  }
  .input, .textarea, .select {
    font-family: inherit;
    font-size: 15px;
    border: 1px solid rgba(0,0,0,0.18);
    background: rgba(255,255,255,0.5);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    width: 100%;
  }
  .textarea { min-height: 120px; resize: vertical; }
  .input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--ink);
    background: #fff;
  }

  /* Ruled paper-style textarea (used in decline letter). */
  .textarea-ruled {
    background: rgba(0,0,0,0.025);
    border: 1px solid rgba(0,0,0,0.12);
    background-image: repeating-linear-gradient(transparent 0 27px, rgba(0,0,0,0.08) 27px 28px);
    font-style: italic;
    color: var(--ink-soft);
    line-height: 28px;
    padding: 14px 16px;
  }

  /* Steps (multi-step indicator) — ink rule with done/active marks. */
  .steps { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); }
  .step { flex: 1; height: 2px; background: rgba(0,0,0,0.12); }
  .step.done   { background: var(--ink); }
  .step.active { background: var(--ink); }

  /* ── Nominate-form fields (ported from Circle).
     Display label above an underline-only input. Required star in slate.
     Pairs cleanly with the paper sheet — no boxes, just hairlines. */
  .nom-field { margin-bottom: var(--space-4); }
  .nom-field:last-child { margin-bottom: 0; }

  .nom-label {
    display: block;
    font-family: var(--display);
    font-size: 14px;
    font-weight: var(--weight-semibold);
    color: var(--ink-soft);
    margin-bottom: 6px;
  }
  .nom-required { color: var(--required); font-weight: var(--weight-bold); margin-left: 2px; }

  .nom-input,
  .nom-select {
    width: 100%;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.18);
    border-radius: 0;
    padding: 10px 2px;
    background: transparent;
    font-family: var(--sans);
    font-size: 16px;
    color: var(--ink);
    transition: border-color 0.15s ease;
  }
  .nom-input::placeholder { color: var(--ink-faint); font-style: italic; }
  .nom-input:focus,
  .nom-select:focus {
    outline: none;
    border-bottom-color: var(--ink);
  }
  .nom-textarea {
    width: 100%;
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: var(--radius-xs, 3px);
    padding: 10px 12px;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    resize: vertical;
    min-height: 60px;
  }
  .nom-textarea::placeholder { color: var(--ink-faint); font-style: italic; }
  .nom-textarea:focus { outline: none; border-color: var(--ink); background: #fff; }

  /* Native <select> reset to match the underline aesthetic. */
  .nom-select {
    appearance: none;
    background-image:
      linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
      linear-gradient(-45deg, transparent 50%, var(--ink-soft) 50%);
    background-position:
      calc(100% - 12px) center,
      calc(100% - 6px) center;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 26px;
    cursor: pointer;
  }

  /* Identity row — photo left, name + pronouns right. */
  .nom-identity {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    margin-bottom: var(--space-7);
  }
  .nom-identity-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  /* Two-up grid for short fields (dietary | allergies, etc.). */
  .nom-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4) var(--space-6);
  }
  @media (max-width: 768px) {
    .nom-grid-2 { grid-template-columns: 1fr; gap: var(--space-5); }
  }

  /* ── Segmented mode toggle (Flying / Driving) — radio inputs styled
     as a single pill control. The checked input's adjacent label
     gets the "selected" treatment. ── */
  .mode-toggle {
    display: inline-flex;
    background: rgba(0,0,0,0.06);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
  }
  .mode-toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  .mode-toggle label {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: var(--weight-semibold);
    cursor: pointer;
    border-radius: 999px;
    color: var(--ink-soft);
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
    user-select: none;
    line-height: 1;
  }
  .mode-toggle input[type="radio"]:checked + label {
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  }
  .mode-toggle input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
  }
  .mode-toggle--small label {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Hide the inactive mode-only block based on the controller's mode. */
  [data-mode="flying"]  [data-mode-only="driving"],
  [data-mode="driving"] [data-mode-only="flying"]  { display: none; }

  /* Photo upload — circular crop + dashed empty state. */
  .nom-photo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--paper-edge);
    border: 1px dashed rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-faint);
    font-size: var(--cap-md);
    letter-spacing: var(--tracking-cap-tight);
    text-transform: uppercase;
    font-weight: var(--weight-bold);
    flex-shrink: 0;
    cursor: pointer;
    overflow: hidden;
    text-decoration: none;
  }
  .nom-photo:hover { border-style: solid; color: var(--ink); }

  /* ── First-time welcome on the profile edit page ───────────────────
     Shown only when the user has arrived via an onboarding redirect
     (params[:next] set) AND hasn't filled in any bio answers yet —
     i.e., immediately after their first invite acceptance.

     Sits BELOW the page title. Copy on top, "Skip for now" button on
     its own line beneath, left-aligned. The skip option lives ONLY
     here — once a returning user is past onboarding, there's no skip
     on the regular edit page. */
  .profile-welcome {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin: 0 0 32px;
    padding: 18px 22px;
    background: rgba(79, 109, 122, 0.10);
    border: 1px solid rgba(79, 109, 122, 0.25);
    border-radius: 6px;
  }
  .profile-welcome-body-col { min-width: 0; width: 100%; }
  .profile-welcome-eyebrow {
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: var(--tracking-cap-wide);
    text-transform: uppercase;
    font-weight: var(--weight-bold);
    color: var(--slate);
    margin: 0 0 6px;
  }
  .profile-welcome-body {
    margin: 0;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
  }
  .profile-welcome-skip { flex-shrink: 0; }

  /* Page title — centered, italic display face, title-cased. */
  .profile-title {
    font-style: italic;
    text-align: center;
    margin: 8px 0 28px;
  }

  /* Bio sub-section — low-opacity slate band so the community-facing
     prompts read as a separate, softer band from the practical fields
     above (name, dietary, accessibility). */
  .profile-bio-section {
    margin-top: 32px;
    padding: 22px 24px 6px;
    background: rgba(79, 109, 122, 0.08);
    border: 1px solid rgba(79, 109, 122, 0.18);
    border-radius: 6px;
  }
  .profile-subsection-h {
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: var(--tracking-cap-wide);
    text-transform: uppercase;
    font-weight: var(--weight-bold);
    color: var(--slate);
    margin: 0 0 18px;
  }

  /* ── Profile avatar (Circle-style upload) ──────────────────────────
     Big circular avatar with hover overlay, AJAX-uploaded by the
     profile-photo Stimulus controller. Mirrors the Circle profile
     pattern, mapped onto gather's ink/paper tokens. */
  .profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
  }
  .profile-avatar-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--paper-edge);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    color: var(--ink);
  }
  .profile-avatar-circle--empty {
    background: rgba(255, 255, 255, 0.5);
    border: 2px dashed rgba(0, 0, 0, 0.22);
  }
  .profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .profile-avatar-initials {
    font-family: var(--display);
    font-size: 40px;
    font-weight: var(--weight-semibold);
    color: var(--ink-soft);
    letter-spacing: 0.04em;
  }

  /* Hover overlay — darkens the photo and reveals Change/Remove. */
  .profile-avatar-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0);
    transition: background 0.16s ease;
    padding: 12px;
  }
  .profile-avatar-overlay-btn,
  .profile-avatar-overlay-remove {
    opacity: 0;
    transition: opacity 0.16s ease;
    pointer-events: none;
  }
  .profile-avatar-overlay-btn {
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: var(--weight-semibold);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.08);
  }
  .profile-avatar-overlay-remove {
    font-size: 11px;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: underline;
    cursor: pointer;
  }
  .profile-avatar-overlay-remove:hover { color: #fff; }
  .profile-avatar-circle:hover .profile-avatar-overlay { background: rgba(0, 0, 0, 0.45); }
  .profile-avatar-circle:hover .profile-avatar-overlay-btn,
  .profile-avatar-circle:hover .profile-avatar-overlay-remove {
    opacity: 1;
    pointer-events: auto;
  }

  .profile-avatar-prompt {
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink-soft);
    cursor: pointer;
    letter-spacing: 0.04em;
  }
  .profile-avatar-prompt:hover { color: var(--ink); }

  /* Upload shimmer — applied during AJAX upload. */
  @keyframes profile-shimmer-sweep {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
  }
  .profile-avatar-circle.is-uploading::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    background: linear-gradient(
      105deg,
      transparent 30%,
      rgba(255, 255, 255, 0.55) 50%,
      transparent 70%
    );
    animation: profile-shimmer-sweep 1.2s ease-in-out infinite;
  }
}
