/* Shared UI for both pages: language toggle, card-photo lightbox and the
   try-on studio. Self-contained tokens (--atl-*) with light and dark sets. */
:root {
  --atl-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --atl-ease: cubic-bezier(0.28, 0, 0.22, 1);
  --atl-fg: #1d1d1f;
  --atl-fg-2: #424245;
  --atl-muted: #6e6e73;
  --atl-accent: #0071e3;
  --atl-accent-hover: #0077ed;
  --atl-on-accent: #fff;
  --atl-sheet: rgba(252, 252, 251, 0.9);
  --atl-line: rgba(0, 0, 0, 0.08);
  --atl-ctl: rgba(118, 118, 128, 0.12);
  --atl-ctl-hover: rgba(118, 118, 128, 0.2);
  --atl-seg-on: #fff;
  --atl-seg-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
  --atl-backdrop: rgba(238, 237, 233, 0.45);
  --atl-stage: #ebe9e4;
  --atl-shadow: 0 2px 6px rgba(20, 18, 14, 0.06), 0 30px 80px rgba(20, 18, 14, 0.2);
  --atl-thumb-bg: #fff;
  --atl-danger: #d70015;
  --atl-pill: rgba(29, 29, 31, 0.78);
  --atl-pill-fg: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --atl-fg: #f5f5f7;
    --atl-fg-2: #d2d2d7;
    --atl-muted: #a8a49e;
    --atl-accent: #0a84ff;
    --atl-accent-hover: #2997ff;
    --atl-sheet: rgba(34, 32, 30, 0.92);
    --atl-line: rgba(255, 246, 232, 0.1);
    --atl-ctl: rgba(255, 246, 232, 0.1);
    --atl-ctl-hover: rgba(255, 246, 232, 0.17);
    --atl-seg-on: rgba(255, 246, 232, 0.2);
    --atl-seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --atl-backdrop: rgba(14, 13, 12, 0.55);
    --atl-stage: #1a1816;
    --atl-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 30px 80px rgba(0, 0, 0, 0.5);
    --atl-thumb-bg: #f2efe9;
    --atl-danger: #ff6961;
    --atl-pill: rgba(242, 239, 233, 0.92);
    --atl-pill-fg: #1d1d1f;
  }
}
:root[data-theme="dark"] {
  --atl-fg: #f5f5f7;
  --atl-fg-2: #d2d2d7;
  --atl-muted: #a8a49e;
  --atl-accent: #0a84ff;
  --atl-accent-hover: #2997ff;
  --atl-sheet: rgba(34, 32, 30, 0.92);
  --atl-line: rgba(255, 246, 232, 0.1);
  --atl-ctl: rgba(255, 246, 232, 0.1);
  --atl-ctl-hover: rgba(255, 246, 232, 0.17);
  --atl-seg-on: rgba(255, 246, 232, 0.2);
  --atl-seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --atl-backdrop: rgba(14, 13, 12, 0.55);
  --atl-stage: #1a1816;
  --atl-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 30px 80px rgba(0, 0, 0, 0.5);
  --atl-thumb-bg: #f2efe9;
  --atl-danger: #ff6961;
  --atl-pill: rgba(242, 239, 233, 0.92);
  --atl-pill-fg: #1d1d1f;
}

/* ---------------------------------------------------------- language toggle */
.lang-seg {
  display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 4px; border-radius: 980px; flex: none;
}
.lang-seg button {
  height: 32px; min-width: 36px; padding: 0 8px; border: 0; border-radius: 980px; background: transparent;
  font: 600 12px/1 var(--atl-font); letter-spacing: 0.04em; color: var(--atl-muted); cursor: pointer;
  transition: background .2s, color .2s;
}
.lang-seg button:hover { color: var(--atl-fg); }
.lang-seg button[aria-pressed="true"] { background: var(--atl-seg-on); color: var(--atl-fg); box-shadow: var(--atl-seg-shadow); }
.lang-seg button:focus-visible { outline: 2px solid var(--atl-accent); outline-offset: 1px; }

/* ---------------------------------------------------------- shared shell */
.atl-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; font-family: var(--atl-font); color: var(--atl-fg); letter-spacing: -0.01em; }
.atl-modal[hidden] { display: none !important; }
.atl-backdrop {
  position: absolute; inset: 0; background: var(--atl-backdrop);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: 0; transition: opacity .35s var(--atl-ease);
}
.atl-sheet {
  position: relative; display: flex; flex-direction: column; overflow: hidden; border-radius: 28px;
  background: var(--atl-sheet); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--atl-shadow), inset 0 0 0 0.5px var(--atl-line);
  transform: translateY(24px) scale(.98); opacity: 0; transition: transform .45s var(--atl-ease), opacity .3s;
}
.atl-modal.is-open .atl-backdrop { opacity: 1; }
.atl-modal.is-open .atl-sheet { transform: none; opacity: 1; }
.atl-sheet:focus { outline: none; }
.atl-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 24px; min-height: 60px; }
.atl-title { margin: 0; flex: 1; min-width: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atl-title small { font-weight: 400; color: var(--atl-muted); margin-left: 8px; font-size: 14px; }
.atl-round {
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--atl-ctl); color: var(--atl-fg-2); transition: background .2s, transform .2s var(--atl-ease);
}
.atl-round:hover { background: var(--atl-ctl-hover); }
.atl-round:active { transform: scale(.92); }
.atl-round:disabled { opacity: .35; cursor: default; }
.atl-modal svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.atl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 0; border-radius: 980px;
  font: 500 14px/1 var(--atl-font); color: var(--atl-fg); background: var(--atl-ctl); cursor: pointer; transition: background .2s, transform .2s var(--atl-ease);
}
.atl-btn:hover { background: var(--atl-ctl-hover); }
.atl-btn:active { transform: scale(.97); }
.atl-btn:disabled { opacity: .4; cursor: default; }
.atl-btn.primary { background: var(--atl-accent); color: var(--atl-on-accent); }
.atl-btn.primary:hover { background: var(--atl-accent-hover); }
.atl-btn.danger { color: var(--atl-danger); }
.atl-modal :focus-visible { outline: 2px solid var(--atl-accent); outline-offset: 2px; }

/* ---------------------------------------------------------- photo lightbox */
.phx-sheet { width: min(1120px, calc(100vw - 48px)); height: min(860px, calc(100vh - 64px)); }
.phx-stage {
  position: relative; flex: 1; min-height: 0; margin: 0 14px 14px; border-radius: 18px; overflow: hidden;
  background: var(--atl-stage); touch-action: none; cursor: zoom-in;
}
.phx-stage.is-zoomed { cursor: grab; }
.phx-stage.is-panning { cursor: grabbing; }
.phx-stage canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; border-radius: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.phx-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 7px 12px; border-radius: 980px;
  background: var(--atl-pill); color: var(--atl-pill-fg); font-size: 12px; white-space: nowrap; pointer-events: none;
  transition: opacity .4s;
}
.phx-hint.is-out { opacity: 0; }
.phx-zoom { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--atl-muted); min-width: 42px; text-align: right; }

/* ---------------------------------------------------------- try-on studio */
.to-sheet { width: min(1240px, calc(100vw - 32px)); height: min(860px, calc(100vh - 48px)); }
.to-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; }
.to-left { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 14px 14px; gap: 10px; }
.to-stage {
  position: relative; flex: 1; min-height: 0; border-radius: 18px; overflow: hidden; background: var(--atl-stage);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
}
.to-stage canvas { position: absolute; display: block; border-radius: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.to-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--atl-muted); font-size: 15px; }
.to-sel { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 50% 50%; }
.to-sel::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.to-handle {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 0; padding: 0;
  background: #fff; color: #1d1d1f; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); display: grid; place-items: center; pointer-events: auto; cursor: grab; touch-action: none;
}
.to-handle svg { width: 13px; height: 13px; }
.to-handle.rot { left: 50%; top: -22px; }
.to-handle.size { left: calc(100% + 6px); top: calc(100% + 6px); cursor: nwse-resize; }
.to-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 7px 12px; border-radius: 980px;
  background: var(--atl-pill); color: var(--atl-pill-fg); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; transition: opacity .4s;
}
.to-hint.is-out { opacity: 0; }
.to-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: thin; flex: none; }
.to-photo {
  flex: none; width: 64px; height: 64px; border: 0; padding: 0; border-radius: 10px; cursor: pointer; background-color: var(--atl-thumb-bg);
  background-repeat: no-repeat; box-shadow: inset 0 0 0 1px var(--atl-line); transition: transform .2s var(--atl-ease), box-shadow .2s;
}
.to-photo:hover { transform: translateY(-2px); }
.to-photo[aria-pressed="true"] { box-shadow: inset 0 0 0 2.5px var(--atl-accent); }
.to-label { margin: 0 2px 6px; font-size: 12px; font-weight: 600; color: var(--atl-muted); text-transform: uppercase; letter-spacing: .05em; }
.to-panel { display: flex; flex-direction: column; min-height: 0; border-left: 0.5px solid var(--atl-line); }
.to-scroll { flex: 1; min-height: 0; overflow: auto; padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.to-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.to-btn-thumb {
  position: relative; aspect-ratio: 1; border: 0; padding: 4px; border-radius: 12px; background: var(--atl-thumb-bg); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--atl-line); transition: transform .2s var(--atl-ease), box-shadow .2s;
}
.to-btn-thumb img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; display: block; pointer-events: none; }
.to-btn-thumb:hover { transform: translateY(-2px); }
.to-btn-thumb[aria-pressed="true"] { box-shadow: inset 0 0 0 2.5px var(--atl-accent); }
.to-ctl { display: grid; gap: 12px; }
.to-row { display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; color: var(--atl-fg-2); }
.to-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--atl-muted); font-size: 12px; }
.to-row input[type="range"] { width: 100%; accent-color: var(--atl-accent); }
.to-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.to-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; cursor: pointer; }
.to-switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--atl-ctl-hover); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.to-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--atl-ease); }
.to-switch input:checked { background: #34c759; }
.to-switch input:checked::after { transform: translateX(18px); }
.to-foot { padding: 12px 20px 16px; border-top: 0.5px solid var(--atl-line); display: flex; gap: 8px; align-items: center; }
.to-foot .atl-btn.primary { flex: 1; height: 40px; }
.to-count { font-size: 12px; color: var(--atl-muted); font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .atl-modal { place-items: end center; }
  .atl-sheet { width: 100vw; height: 94vh; height: 94dvh; border-radius: 22px 22px 0 0; transform: translateY(100%); }
  .phx-sheet { height: 88vh; height: 88dvh; }
  .to-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr); }
  .to-panel { border-left: 0; border-top: 0.5px solid var(--atl-line); }
  .to-left { padding: 0 10px 8px; }
  .to-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .atl-head { padding-left: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .atl-sheet, .atl-backdrop { transition-duration: .01ms !important; }
}
.atl-modal .atl-sheet:focus-visible { outline: none; }
