/* Little Worlds: Friends mode. Builds on css/app.css tokens and components. */
.fr { position: absolute; inset: 0; background: var(--bg); overflow: hidden; }
.fr-app { position: absolute; inset: 0; display: flex; flex-direction: column; }
.fr-bar { height: 60px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.fr-bar .title { font-weight: 650; font-size: 17px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-muted { color: var(--muted); }
.fr-hand { font-family: var(--hand); font-size: 22px; line-height: 1; }

/* ---------- home ---------- */
.fr-home { flex: 1; min-height: 0; overflow: auto; }
.fr-home-in { max-width: 1120px; margin: 0 auto; padding: 4px 24px 64px; }
.fr-head { margin: 4px 0 22px; }
.fr-h1 { font-size: clamp(30px, 4vw, 42px); font-weight: 650; letter-spacing: -.025em; line-height: 1.05; margin: 0 0 6px; }
.fr-sub { color: var(--muted); margin: 0; max-width: 46ch; }
.fr-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.fr-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 10px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper); cursor: pointer; text-align: left; transition: border-color .15s var(--ease), transform .15s var(--ease); }
.fr-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.fr-card:focus-visible, .fr-key:focus-visible, .fr-doc-img:focus-visible, .fr-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fr-ph { width: 100%; aspect-ratio: 1; border-radius: 10px; background: var(--paper-2); display: grid; place-items: center; margin-bottom: 8px; overflow: hidden; }
.fr-ph img { width: 92%; height: 92%; object-fit: contain; }
.fr-card-n { font-weight: 600; font-size: 15px; }
.fr-card-s { font-size: 12px; color: var(--muted); }
.fr-make { border-style: dashed; border-color: var(--line-2); background: transparent; justify-content: center; min-height: 220px; }
.fr-make:hover { border-color: var(--accent-line); }
.fr-make-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-weak); color: var(--accent); border: 1px solid var(--accent-line); margin-bottom: 10px; }
.fr-make-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fr-keys { margin-top: 24px; }
.fr-keyrow { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.fr-key { flex: none; width: 140px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; transition: border-color .15s var(--ease), transform .15s var(--ease); }
.fr-key:hover { border-color: var(--line-2); transform: translateY(-2px); }
.fr-key-ph { aspect-ratio: 1000 / 1400; width: 100%; border-radius: 8px; background: var(--paper-2); overflow: hidden; display: block; }
.fr-key-ph img { width: 100%; height: 100%; display: block; }
.fr-key-n { font-size: 13px; font-weight: 600; }
.fr-empty { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- split layout (stage + panel) ---------- */
.fr-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; padding: 0 16px 16px; }
.fr-stage-slot { position: relative; min-height: 0; min-width: 0; }
.fr-stage { position: absolute; inset: 0; border-radius: 18px; border: 1px solid var(--line); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 38%, #fffaf2 0%, #f6ecdf 60%, #efe3d2 100%); }
.fr-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
.fr-canvas:active { cursor: grabbing; }
.fr-stage-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 253, 249, .8); pointer-events: none; transition: opacity .2s var(--ease); }
.fr-stage-hint svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fr-stage.used .fr-stage-hint { opacity: 0; }
.fr-side { min-height: 0; display: flex; }
.fr-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.fr-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px 22px; }
.fr-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.fr-foot .spacer { flex: 1; }

/* stepper */
.fr-steps { flex: none; border-bottom: 1px solid var(--line); padding: 10px 10px; }
.fr-steps ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; justify-content: space-between; }
.fr-steps li { flex: 1; min-width: 0; }
.fr-step { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 4px; border: 1px solid transparent; border-radius: 10px;
  background: none; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 550; transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease); }
.fr-step:hover { color: var(--ink); }
.fr-step-n { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 11px; font-weight: 650; }
.fr-step-n svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fr-step.done .fr-step-n { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.fr-step.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-weak); }
.fr-step.on .fr-step-n { border-color: var(--accent); background: var(--accent); color: #fff; }

/* step content */
.fr-step-h { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 2px; }
.fr-step-p { color: var(--muted); margin: 0 0 16px; }
.fr-sec { margin-bottom: 18px; }
.fr-sub-sw { margin-top: 10px; }
.fr-animals { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.fr-animal { padding: 6px 6px 8px; }
.fr-animal.on { border-color: var(--accent-line); background: var(--accent-weak); }
.fr-animal.on .nm { color: var(--accent); font-weight: 600; }
.fr-ath { display: block; width: 100%; aspect-ratio: 1; }
.fr-ath img { width: 100%; height: 100%; object-fit: contain; display: block; }
.fr-ath:empty { background: radial-gradient(circle at 50% 60%, rgba(42, 35, 32, .06) 0 30%, transparent 31%); }
.fr-range { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.fr-form { display: flex; flex-direction: column; gap: 16px; }
.fr-form .chips { margin-top: 6px; }
.fr-form .chip { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; }
.fr-form .field .chip[data-act="persona"] { text-transform: capitalize; }
.fr-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fr-2col .input { min-width: 0; width: 100%; }
.fr-inrow { display: flex; gap: 8px; }
.fr-inrow .input { flex: 1; min-width: 0; }
.fr-err { color: var(--accent); font-size: 13px; }
.fr-docs { display: grid; grid-template-columns: 1.55fr 1fr; gap: 12px; align-items: start; }
.fr-doc { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.fr-doc-img { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper-2); cursor: zoom-in; transition: border-color .15s var(--ease), transform .15s var(--ease); }
.fr-doc-img:hover { border-color: var(--line-2); transform: translateY(-1px); }
.fr-doc.cert .fr-doc-img { aspect-ratio: 2000 / 1400; }
.fr-doc.key .fr-doc-img { aspect-ratio: 1000 / 1400; }
.fr-doc-img img { width: 100%; height: 100%; display: block; object-fit: cover; }
.fr-doc figcaption .btn { width: 100%; }
.fr-wide { width: 100%; margin-top: 14px; }
.fr-loading { display: grid; place-items: center; height: 100%; font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

/* identity card */
.fr-idcard { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper-2); padding: 18px; }
.fr-id-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px dashed var(--line-2); }
.fr-id-name { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.fr-id-kind { font-size: 13px; color: var(--muted); margin-top: 2px; }
.fr-tag { height: 24px; display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--accent-line); background: var(--accent-weak); color: var(--accent);
  border-radius: 7px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
.fr-idl { margin: 8px 0 0; }
.fr-idrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fr-idrow:last-child { border-bottom: 0; }
.fr-idrow dt { font-size: 12px; color: var(--muted); }
.fr-idrow dd { margin: 0; text-align: right; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.fr-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-2); display: inline-block; }
.fr-actions .btn.accent { order: -1; flex-basis: 100%; }

/* modals */
.fr-modal.wide { max-width: 960px; }
.fr-m-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fr-m-h { font-size: 19px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 6px; }
.fr-m-top .fr-m-h { margin: 0; }
.fr-m-p { color: var(--muted); margin: 0 0 18px; }
.fr-m-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.fr-m-img { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper-2); margin-bottom: 14px; }
.fr-m-img.cert { aspect-ratio: 2000 / 1400; }
.fr-m-img.key { aspect-ratio: 1000 / 1400; max-height: 64dvh; margin-inline: auto; }
.fr-m-img img { width: 100%; height: 100%; display: block; object-fit: contain; }

/* confetti of paper hearts */
.fr-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 80; }
.fr-confetti span { position: absolute; top: -24px; display: block; opacity: 0; animation: fr-fall 2s cubic-bezier(.3, .5, .4, 1) forwards; }
.fr-confetti svg { width: 100%; height: 100%; }
@keyframes fr-fall {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  12% { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--dx), 62vh) rotate(var(--rot)); }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .fr-split { grid-template-columns: minmax(0, 1fr) 380px; } }
@media (max-width: 860px) {
  .fr-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 42dvh) minmax(0, 1fr); gap: 12px; padding: 0 12px 12px; }
  .fr-home-in { padding: 4px 16px 48px; }
  .fr-shelf { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .fr-make { min-height: 180px; }
}
@media (max-width: 520px) {
  .fr-bar { padding: 0 12px; }
  .fr-step-l { display: none; }
  .fr-step.on .fr-step-l { display: inline; }
  .fr-scroll { padding: 16px 16px 20px; }
  .fr-docs { grid-template-columns: 1fr; }
  .fr-doc.key { max-width: 220px; justify-self: center; width: 100%; }
  .fr-2col { grid-template-columns: 1fr; }
  .fr-split { grid-template-rows: minmax(240px, 40dvh) minmax(0, 1fr); }
  .fr-foot .btn { padding: 0 12px; }
}

/* friend view on narrow screens: the whole panel scrolls so the card is never squeezed */
@media (max-width: 860px) {
  .is-view .fr-panel { overflow: auto; }
  .is-view .fr-scroll { flex: none; overflow: visible; }
  .is-view .fr-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .is-view .fr-actions .btn.accent { grid-column: 1 / -1; }
  .is-view .fr-actions .btn.danger { grid-column: 1 / -1; }
  .fr .toast { bottom: 88px; }
}

/* round 2: hints, wardrobe theme toggle, halloween markers, about header */
.fr-hint { font-size: 12px; color: var(--muted); margin: -2px 0 2px; line-height: 1.35; }
.fr-sec > .fr-hint { margin: -4px 0 8px; }
.fr-seg { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-2); margin-bottom: 16px; }
.fr-seg button { height: 32px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--muted);
  transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease); }
.fr-seg button:hover { color: var(--ink); }
.fr-seg button.on { background: var(--paper); border-color: var(--line-2); color: var(--ink); }
.fr-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fr-hw-note { margin: -6px 0 14px; }
.chip.hw::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #e0843a; display: inline-block; margin-right: 6px; vertical-align: 1px; }
.fr-about-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fr-about-h .btn { flex: none; margin-top: 2px; }
.fr-favname { display: inline-flex; align-items: center; gap: 6px; height: 30px; font-size: 13px; font-weight: 550; padding: 0 4px; }
.fr-form .field > .chips { margin-top: 4px; }
.fr-form .field > .sws { margin-top: 8px; }
.fr-form .fr-pick + .input { margin-top: 8px; }

/* round 3: Izzy's friends row */
.fr-izzy { border: 1px solid var(--accent-line); background: var(--accent-weak); border-radius: var(--r); padding: 12px; margin-bottom: 18px; }
.fr-izzy-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.fr-izzy-h .sec-h { margin: 0; color: var(--accent); }
.fr-izzy-h .fr-hint { margin: 0; }
.fr-izzy-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fr-preset { background: var(--paper); padding: 6px 6px 8px; }
.fr-preset .nm { font-size: 13px; font-weight: 600; color: var(--ink); }
.fr-preset.on { border-color: var(--accent); }
.fr-preset.on .nm { color: var(--accent); }

/* round 4: preview tiles for looks and wardrobe */
.fr-wear-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.fr-wear { padding: 5px 5px 7px; gap: 4px; }
.fr-wear.on { border-color: var(--accent-line); background: var(--accent-weak); }
.fr-wear.on .nm { color: var(--accent); font-weight: 600; }
.fr-wear .nm { font-size: 12px; line-height: 1.2; }
.fr-wth { display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--paper); }
.fr-wth:empty { background: radial-gradient(circle at 50% 58%, rgba(42, 35, 32, .06) 0 30%, var(--paper) 31%); }
.fr-wth img { width: 100%; height: 100%; object-fit: contain; display: block; }
.fr-hwdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #e0843a; margin-right: 5px; vertical-align: 1px; }
