/* 1rem is 10pt on a widget frame of 888 x 438pt, so a widget scales with its frame. */
:root {
  --bg: #0f1b2d; --panel: #18283d; --line: #2c3e57; --ink: #f2f5f9; --muted: #a3b3c6; --acc: #5eead4;
  font-size: min(calc(100vw / 88.8), calc(100vh / 43.8));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body {
  font-family: "Segoe UI", "Microsoft JhengHei UI", "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", sans-serif;
  -webkit-user-select: none; user-select: none;
}
#stage { position: absolute; inset: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: .2rem solid var(--acc); outline-offset: .2rem; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; gap: .6rem; padding: 3rem; text-align: center; }
.empty strong { font-size: 1.8rem; }
.empty span { font-size: 1.3rem; color: var(--muted); }

/* Before / after wipe */
.wipe { position: absolute; inset: 0; overflow: hidden; cursor: ew-resize; touch-action: none; background: #000; }
.wipe img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; transition: filter .25s; }
.wipe .top { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.wipe .tag { position: absolute; top: 1.4rem; padding: .4rem 1rem; border-radius: .4rem; font-size: 1.3rem; font-weight: 600; color: #fff; background: rgba(15, 27, 45, .74); }
.wipe .tag.left { left: 1.4rem; }
.wipe .tag.right { right: 1.4rem; }
.wipe .rule { position: absolute; top: 0; bottom: 0; left: var(--p); width: .2rem; margin-left: -.1rem; background: #fff; box-shadow: 0 0 .8rem rgba(0, 0, 0, .45); }
.wipe .knob {
  position: absolute; top: 50%; left: 50%; width: 4.6rem; height: 4.6rem; margin: -2.3rem 0 0 -2.3rem;
  display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: 0 .3rem 1.2rem rgba(0, 0, 0, .4);
}
.wipe .knob svg { width: 2.6rem; height: 2.6rem; fill: none; stroke: var(--bg); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.wipe .styles {
  position: absolute; left: 50%; bottom: 1.4rem; transform: translateX(-50%); display: flex; gap: .2rem; padding: .3rem;
  border-radius: .7rem; background: rgba(15, 27, 45, .8); cursor: default;
}
.wipe .styles button { padding: .5rem 1.2rem; border: 0; border-radius: .5rem; background: none; font-size: 1.2rem; color: var(--ink); cursor: pointer; }
.wipe .styles button[aria-pressed="true"] { background: var(--acc); color: var(--bg); font-weight: 600; }

/* Zipper reveal */
.zipper { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.zipper .reveal { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .8rem; padding: 3rem; text-align: center; }
.zipper .reveal img { max-width: 60%; max-height: 40%; object-fit: contain; }
.zipper .reveal h2 { margin: 0; font-size: 5.6rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.05; }
.zipper .reveal p { margin: 0; font-size: 1.7rem; }
.zipper svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.zipper .half { transition: transform .55s cubic-bezier(.5, 0, .75, 0); }
.zipper.open .half.a { transform: translateX(-560px); }
.zipper.open .half.b { transform: translateX(560px); }
.zipper .pull { cursor: grab; outline: none; transition: opacity .2s; }
.zipper .pull:active { cursor: grabbing; }
.zipper .pull:focus-visible .tab { stroke: var(--acc); stroke-width: 3; }
.zipper.open .pull { opacity: 0; pointer-events: none; }
.zipper .hint { position: absolute; left: calc(50% + 4.6rem); top: 3rem; padding: .4rem .9rem; border-radius: .4rem; font-size: 1.3rem; color: #fff; background: rgba(15, 27, 45, .74); pointer-events: none; transition: opacity .2s; }
.zipper .again { position: absolute; right: 1.4rem; bottom: 1.4rem; padding: .5rem 1.2rem; border: .1rem solid currentColor; border-radius: .5rem; background: none; font-size: 1.2rem; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .25s .5s; }
.zipper.open .again { opacity: .85; pointer-events: auto; }

/* Compare dashboard */
.compare { position: absolute; inset: 0; display: grid; grid-template-columns: 41rem 1fr; grid-template-rows: 1fr 7.4rem; gap: 1rem 1.6rem; padding: 0; }
.compare .tiles { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 1fr; gap: .4rem; min-height: 0; }
.compare .tile {
  display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 0; padding: 0; border: 0; border-radius: .6rem;
  line-height: 1.25; cursor: pointer; transition: background-color .22s, box-shadow .12s;
}
.compare .tile b { font-size: 1.25rem; font-weight: 600; white-space: nowrap; }
.compare .tile span { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.compare .tile[aria-pressed="true"] { box-shadow: 0 0 0 .22rem var(--bg), 0 0 0 .44rem var(--ink); }
.compare .side { display: flex; flex-direction: column; gap: .9rem; min-width: 0; min-height: 0; }
.compare .head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.compare .head strong { font-size: 1.5rem; font-weight: 600; }
.compare .head span { font-size: 1.1rem; color: var(--muted); }
.compare .bars { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: .9rem; min-height: 0; }
.compare .bar { display: grid; grid-template-columns: 6.2rem 1fr 7.8rem; align-items: center; gap: .8rem; font-size: 1.25rem; }
.compare .bar .name { font-weight: 600; white-space: nowrap; }
.compare .bar.ref .name { font-weight: 400; color: var(--muted); }
.compare .bar .track { position: relative; height: 1.9rem; border-radius: .3rem; background: var(--panel); }
.compare .bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: .3rem; background: var(--acc); transition: width .22s; }
.compare .bar.ref .fill { background: #62748b; }
.compare .bar .mark { position: absolute; top: -.5rem; bottom: -.5rem; width: .2rem; margin-left: -.1rem; background: var(--ink); }
.compare .bar .val { text-align: right; font-variant-numeric: tabular-nums; }
.compare .bar .val small { display: block; font-size: 1rem; color: var(--muted); }
.compare .none { font-size: 1.3rem; color: var(--muted); text-align: center; }
.compare .ask { display: flex; align-items: center; gap: .9rem; font-size: 1.25rem; }
.compare .ask label { white-space: nowrap; }
.compare .ask input {
  width: 10rem; padding: .4rem .7rem; border: .1rem solid var(--line); border-radius: .4rem; background: var(--panel);
  font-size: 1.4rem; font-variant-numeric: tabular-nums; -webkit-user-select: text; user-select: text;
}
.compare .ask output { flex: 1; color: var(--acc); font-weight: 600; }
.compare .scrub { grid-column: 1 / -1; position: relative; touch-action: none; cursor: ew-resize; }
.compare .scrub .rail { position: absolute; top: 0; bottom: 0; left: 3.2rem; right: 3.2rem; }
.compare .scrub .trend { position: absolute; left: 0; top: .2rem; font-size: 1.05rem; color: var(--muted); pointer-events: none; }
.compare .scrub svg { position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 5.2rem; display: block; }
.compare .scrub .area { fill: #1f3148; }
.compare .scrub .ln { fill: none; stroke: #62748b; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.compare .scrub .base { position: absolute; left: 0; right: 0; top: 5.2rem; height: .1rem; background: var(--line); }
.compare .scrub .edge { position: absolute; bottom: 0; font-size: 1.05rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.compare .scrub .edge.first { left: 0; transform: translateX(-50%); }
.compare .scrub .edge.last { right: 0; transform: translateX(50%); }
.compare .scrub .thumb {
  position: absolute; left: var(--x); bottom: 0; top: 0; width: 6.4rem; margin-left: -3.2rem; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; outline: none;
}
.compare .scrub .thumb::before { content: ""; flex: 1; width: .2rem; background: var(--ink); }
.compare .scrub .thumb b { padding: .1rem .8rem; border-radius: .4rem; background: var(--ink); color: var(--bg); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.compare .scrub .thumb:focus-visible b { box-shadow: 0 0 0 .2rem var(--acc); }

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