:root {
  --accent: #1475e1;
  --ink: #141b26;
  --ink-2: #3a4556;
  --muted: #6e7889;
  --line: #e2e7ef;
  --panel: rgba(255, 255, 255, 0.78);
  --bg-top: #f5f7fb;
  --bg-bottom: #e9eef5;
  --frame: #0f131a;
  /* Screenshot is 390×844 CSS px; the status bar adds 44 px on top. */
  --shot-ratio: 2.1641; /* 844 / 390 */
  --bar-ratio: 0.1128;  /* 44 / 390 */
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(900px 480px at 50% 108%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 72%),
    radial-gradient(600px 360px at 12% -10%, rgba(255, 255, 255, 0.9), transparent 70%),
    linear-gradient(var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  transition: background 0.5s;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 18px 28px 22px; gap: 14px; }

/* ── top bar ───────────────────────────── */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-weight: 800; letter-spacing: -0.5px; font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 16px; letter-spacing: 0.5px; }
.brand-text small { font-size: 11px; color: var(--muted); }
.headline { text-align: center; min-width: 0; }
.headline h1 { font-size: 22px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.headline p { margin-top: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loading .headline h1, .loading .headline p { width: 220px; max-width: 60vw; margin-inline: auto; border-radius: 8px; color: transparent;
  background: linear-gradient(110deg, #e6eaf0 30%, #f5f7fa 45%, #e6eaf0 60%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.loading .headline p { width: 140px; margin-top: 8px; }
.loading .list::before { content: ""; width: 80%; height: 60%; border-radius: 12px;
  background: linear-gradient(110deg, #e6eaf0 30%, #f5f7fa 45%, #e6eaf0 60%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.t-layout { color: inherit; }
.s-layout { display: none; }
.top-right { justify-self: end; display: flex; align-items: center; gap: 14px; }
.stat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stat b { color: var(--ink); font-weight: 600; }
.mode-switch {
  display: flex; padding: 3px; border-radius: 999px; flex: none;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px);
}
.mode-switch button { padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); transition: 0.2s; white-space: nowrap; }
.mode-switch button[aria-checked="true"] { background: var(--ink); color: #fff; }
.mode-switch button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── stage ─────────────────────────────── */
.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: 128px 1fr 140px; gap: 24px; }
.panel {
  display: flex; flex-direction: column; min-height: 0;
  padding: 16px 8px 10px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(12px); box-shadow: 0 12px 32px rgba(20, 27, 38, 0.06);
}
.panel h2 { font-size: 14px; font-weight: 600; text-align: center; margin-bottom: 10px; }
.panel h2 small { font-weight: 400; font-size: 11px; color: var(--muted); }
.list {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px 4px 6px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}

.skin {
  position: relative; width: 100%; flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 4px; border-radius: 14px; font-size: 12px; line-height: 1.3; color: var(--muted); transition: background 0.2s, color 0.2s;
}
/* WG swatch: primary over the skin's base colour (bg_1). */
.swatch {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: conic-gradient(from -45deg, var(--c) 0 50%, var(--bgc) 50% 100%);
  box-shadow: 0 0 0 1px rgba(20, 27, 38, 0.12), 0 4px 10px rgba(20, 27, 38, 0.1); transition: box-shadow 0.2s, transform 0.2s;
}
.skin span { max-width: 100%; text-align: center; word-break: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.skin:hover { color: var(--ink); }
.skin:hover .swatch { transform: translateY(-2px); }
.skin[aria-current="true"] { color: var(--ink); font-weight: 600; background: #fff; box-shadow: 0 4px 12px rgba(20, 27, 38, 0.06); }
.skin[aria-current="true"] .swatch { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c), 0 6px 14px rgba(20, 27, 38, 0.14); }

.group { width: 100%; margin: 8px 0 2px; font-size: 11px; font-weight: 500; color: var(--muted); text-align: center; letter-spacing: 1px; }
.group:first-child { margin-top: 0; }
.layout {
  width: 100%; flex: none; padding: 9px 8px; border-radius: 12px; text-align: center; font-size: 14px; line-height: 1.3;
  color: var(--ink-2); transition: 0.2s;
}
.layout:hover { background: #fff; color: var(--ink); }
.layout[aria-current="true"] { background: var(--ink); color: #fff; font-weight: 600; }

/* ── showcase ──────────────────────────── */
.showcase { position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; container-type: inline-size; }
.device { position: relative; z-index: 2; display: flex; align-items: center; gap: 20px; }
/* Previous, current and next skin as three equal phones; the side ones are
   one click away. They drop out when the column cannot fit three. */
.phones { display: flex; align-items: flex-start; gap: 22px; }
.slot { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.slot figcaption { max-width: var(--w); font-size: 13px; line-height: 18px; height: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.main figcaption { color: var(--ink); font-weight: 600; }
.slot.main figcaption::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.slot.side { cursor: pointer; }
.slot.side .phone { box-shadow: 0 18px 40px rgba(20, 27, 38, 0.16), inset 0 0 0 2px #2a303b, inset 0 0 0 5px #0b0e13; transition: transform 0.2s; }
.slot.side:hover .phone { transform: translateY(-4px); }
.slot.side:hover figcaption { color: var(--ink); }
.slot.side[hidden] { display: none; }
/* The phone is sized by width so the screen keeps the screenshot's exact
   aspect ratio (no side cropping). Height = width × (bar + shot) + bezel. */
.phone {
  --w: clamp(220px, min(calc((100dvh - 240px) / 2.33), calc((100cqw - 220px) / 3)), 340px);
  width: var(--w); padding: 11px; border-radius: 50px; background: var(--frame); flex: none;
  box-shadow: 0 40px 80px rgba(20, 27, 38, 0.28), inset 0 0 0 2px #2a303b, inset 0 0 0 5px #0b0e13;
}
.screen { position: relative; border-radius: 39px; overflow: hidden; background: var(--bar, #0b0f15); }
.statusbar {
  --fg: #fff;
  position: relative; height: calc((var(--w) - 22px) * var(--bar-ratio)); display: flex; align-items: center; justify-content: space-between;
  padding: 0 7%; background: var(--bar, #0b0f15); color: var(--fg); font-size: calc((var(--w) - 22px) * 0.038); font-weight: 600; transition: background 0.3s;
}
.statusbar.light { --fg: #111; }
.island { position: absolute; left: 50%; top: 22%; width: 31%; height: 56%; transform: translateX(-50%); border-radius: 999px; background: #000; }
.sys { display: flex; align-items: center; gap: 5px; }
.sig { display: flex; align-items: flex-end; gap: 1.5px; height: 0.75em; }
.sig b { width: 3px; background: var(--fg); border-radius: 1px; }
.sig b:nth-child(1) { height: 35%; } .sig b:nth-child(2) { height: 55%; } .sig b:nth-child(3) { height: 78%; } .sig b:nth-child(4) { height: 100%; }
.wifi { width: 1.05em; height: 0.78em; background: var(--fg);
  -webkit-mask: radial-gradient(circle at 50% 100%, #000 18%, transparent 19%, transparent 38%, #000 39%, #000 55%, transparent 56%, transparent 72%, #000 73%) ;
  mask: radial-gradient(circle at 50% 100%, #000 18%, transparent 19%, transparent 38%, #000 39%, #000 55%, transparent 56%, transparent 72%, #000 73%); }
.bat { position: relative; width: 1.7em; height: 0.82em; border: 1.2px solid color-mix(in srgb, var(--fg) 45%, transparent); border-radius: 3px; padding: 1.3px; }
.bat::after { content: ""; position: absolute; right: -3.5px; top: 30%; width: 2px; height: 40%; border-radius: 0 1px 1px 0; background: color-mix(in srgb, var(--fg) 45%, transparent); }
.bat b { display: block; width: 80%; height: 100%; border-radius: 1.5px; background: var(--fg); }
.shot-wrap { position: relative; aspect-ratio: 390 / 844; background: linear-gradient(110deg, #e9edf3 30%, #f6f8fb 45%, #e9edf3 60%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.shot-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.shot-wrap img:not([src]) { visibility: hidden; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* Narrower columns keep all three phones at equal size and drop the arrows
   instead (the side phones are clickable). Only very narrow columns fall back
   to the current phone alone. */
@container (max-width: 960px) {
  .nav { display: none; }
  .phones { gap: 14px; }
  .phone { --w: clamp(150px, min(calc((100dvh - 240px) / 2.33), calc((100cqw - 40px) / 3)), 300px); padding: 7px; border-radius: 34px; }
  .screen { border-radius: 28px; }
  .statusbar { height: calc((var(--w) - 14px) * var(--bar-ratio)); font-size: calc((var(--w) - 14px) * 0.038); }
}
@container (max-width: 480px) {
  .slot.side { display: none; }
  .phone { --w: clamp(220px, calc((100dvh - 240px) / 2.33), 340px); }
}

.nav {
  position: relative; width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, 0.9); border: 1px solid var(--line); box-shadow: 0 8px 20px rgba(20, 27, 38, 0.12); transition: transform 0.2s, background 0.2s;
}
.nav:hover { transform: scale(1.06); background: #fff; }
.nav::before { content: ""; position: absolute; inset: 0; margin: auto; width: 10px; height: 10px; border: solid var(--ink); border-width: 0 0 2px 2px; }
.nav.prev::before { transform: translateX(2px) rotate(45deg); }
.nav.next::before { transform: translateX(-2px) rotate(-135deg); }
.nav[hidden] { visibility: hidden; display: block; }

.pager { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.try {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 40px; border-radius: 999px;
  background: var(--ink); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  box-shadow: 0 12px 26px rgba(20, 27, 38, 0.22); transition: transform 0.2s, box-shadow 0.2s;
}
.try span { color: color-mix(in srgb, var(--accent) 60%, #fff); font-size: 18px; transition: transform 0.2s; }
.try:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(20, 27, 38, 0.26); }
.try:hover span { transform: translateX(3px); }
.try[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.floor { display: none; }

/* ── narrow desktop / tablet ───────────── */
@media (max-width: 1100px) and (min-width: 761px) {
  .stat { display: none; }
  .stage { gap: 16px; grid-template-columns: 112px 1fr 120px; }
  .device { gap: 12px; }
  .nav { width: 40px; height: 40px; }
}

/* ── short screens (landscape phones, small laptops): let the page scroll ── */
@media (min-width: 761px) and (max-height: 600px) {
  .page { height: auto; min-height: 100dvh; }
  .stage { min-height: 560px; }
  .panel { max-height: 560px; }
  .phone { --w: clamp(150px, calc((100cqw - 40px) / 3), 220px); }
}

/* ── phones: big preview first; pickers stick to the top, CTA to the bottom ── */
@media (max-width: 760px) {
  .page { height: auto; min-height: 100dvh; padding: 0 0 calc(76px + env(safe-area-inset-bottom)); gap: 0; }
  .topbar { position: sticky; top: 0; z-index: 10; grid-template-columns: 1fr auto; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 8px; background: rgba(245, 247, 251, 0.92); backdrop-filter: blur(14px); }
  .brand, .stat { display: none; }
  .headline { text-align: left; }
  .headline h1 { font-size: 17px; }
  .headline h1 .t-layout { display: none; }
  .headline p { font-size: 12px; margin-top: 2px; }
  .headline p .s-layout { display: inline; }
  .mode-switch button { padding: 5px 10px; font-size: 12px; }
  .stage { display: flex; flex-direction: column; gap: 0; }
  /* Pickers stick right under the title bar while the preview scrolls. */
  .panel { position: sticky; z-index: 9; flex: none; padding: 6px 0; border-radius: 0; border-width: 0;
    background: rgba(245, 247, 251, 0.92); backdrop-filter: blur(14px); box-shadow: none; }
  .panel.layouts { order: 1; top: calc(58px + env(safe-area-inset-top)); }
  .panel.skins { order: 2; top: calc(104px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
  .panel h2 { display: none; }
  .list { flex-direction: row; overflow-x: auto; overflow-y: hidden; align-items: center; gap: 4px; padding: 2px 14px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .list::-webkit-scrollbar { display: none; }
  .skin { width: 64px; padding: 4px 2px; gap: 4px; font-size: 11px; scroll-snap-align: center; }
  .skin span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
  .swatch { width: 34px; height: 34px; }
  .group { width: auto; flex: none; margin: 0 2px 0 8px; font-size: 10px; letter-spacing: 0; white-space: nowrap; }
  .group:first-child { margin-left: 0; }
  .layout { width: auto; flex: none; padding: 7px 12px; font-size: 13px; background: #fff; scroll-snap-align: center; }
  .showcase { order: 3; padding: 16px 0 8px; gap: 10px; }
  .nav { display: none; }
  .device { gap: 0; }
  /* Large preview: ~88% of the screen width, page scrolls for the rest. */
  .phone { --w: min(88vw, 380px); padding: 7px; border-radius: 42px; }
  .screen { border-radius: 35px; }
  .statusbar { height: calc((var(--w) - 14px) * var(--bar-ratio)); font-size: calc((var(--w) - 14px) * 0.038); }
  .pager { font-size: 12px; }
  .slot figcaption { display: none; }
  .try { position: fixed; z-index: 20; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    padding: 12px 44px; font-size: 15px; box-shadow: 0 10px 30px rgba(20, 27, 38, 0.3); }
  .try:hover { transform: translateX(-50%) translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
