/* ---------- Tokens ---------- */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fill: #f0f0f3;          /* pills, search field */
  --fill-hover: #e8e8ed;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --hair: rgba(0, 0, 0, 0.09);
  --accent: #0071e3;
  --green: #248a3d;
  --red: #c9342c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --r: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: #2c2c2e;
    --fill-hover: #3a3a3c;
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #636366;
    --hair: rgba(255, 255, 255, 0.1);
    --accent: #2997ff;
    --green: #30d158;
    --red: #ff6961;
    --shadow: none;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Nav bar ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-bottom-color: var(--hair); }
/* Bar content lines up with the page column (same max width as .wrap) */
.nav-inner {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 52px; max-width: 720px; margin: 0 auto; padding: 0 12px;
}
@media (max-width: 420px) { .nav-inner { padding: 0 8px; } }
.nav-back { justify-self: start; display: flex; align-items: center; gap: 6px; padding: 8px; color: var(--accent); font-size: 17px; }
.nav-title { font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; }
.nav.scrolled .nav-title { opacity: 1; }
.nav-btn {
  grid-column: 3; justify-self: end;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  color: var(--accent);
}
.nav-btn:hover { background: var(--fill); }
.nav-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Page header ---------- */
.page-head { padding: 8px 0 20px; }
.page-head h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; }
.page-head p { margin: 6px 0 0; color: var(--text-2); font-size: 17px; }

.offline {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 10px 14px; border-radius: 12px;
  background: var(--fill); color: var(--text-2); font-size: 14px;
}

/* ---------- Grouped list (shared) ---------- */
.group {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden;
}
.section-label {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 28px 4px 8px; font-size: 13px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.02em;
}
.row {
  position: relative; display: flex; align-items: center; gap: 14px;
  min-height: 64px; padding: 12px 16px;
}
.item { position: relative; }
.item + .item::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px;
  border-top: 0.5px solid var(--hair);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.row-sub { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.row-sub .num { white-space: nowrap; }
.row-sub .sep { color: var(--text-3); margin: 0 5px; }

/* Home rows */
a.row { transition: background .15s; }
a.row:hover { background: var(--fill); }
a.row:active { background: var(--fill-hover); }
.glyph {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--fill); color: var(--text);
}
.glyph svg { width: 24px; height: 24px; }
.row-title.lg { font-size: 17px; font-weight: 600; }
.chev { flex: none; color: var(--text-3); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 8px; vertical-align: middle; }
.ver { color: var(--text-2); font-size: 15px; white-space: nowrap; }

/* ---------- Release hero ---------- */
.hero { padding: 22px 20px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.hero-ver { margin-top: 6px; font-size: 40px; line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; }
.hero-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; color: var(--text-2); }
.signed { display: inline-flex; align-items: center; gap: 6px; }
.signed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.signed.yes { color: var(--green); }
.signed.no { color: var(--red); }

/* ---------- Search ---------- */
.search {
  position: relative; margin-top: 20px;
}
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.search input {
  width: 100%; height: 40px; padding: 0 12px 0 36px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--fill); border: 0; border-radius: 10px; outline: none;
}
.search input::placeholder { color: var(--text-2); }
.search input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- Actions ---------- */
.actions { flex: none; display: flex; align-items: center; gap: 6px; }
.get {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 92px; height: 30px; padding: 0 14px; border-radius: 15px;
  background: var(--fill); color: var(--accent);
  font-size: 15px; font-weight: 600; letter-spacing: 0;
  transition: background .15s;
}
.get:hover { background: var(--fill-hover); }
.get:active { transform: scale(0.97); }
.icon-act {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-2); transition: background .15s, color .15s;
}
.icon-act:hover { background: var(--fill); color: var(--text); }

/* ---------- Disclosure (older models) ---------- */
.disclose {
  width: 100%; display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 16px; text-align: left; color: var(--accent); font-size: 17px;
}
.disclose:hover { background: var(--fill); }
.disclose .chev { margin-left: auto; transition: transform .2s; color: var(--text-3); }
.disclose[aria-expanded="true"] .chev { transform: rotate(90deg); }

/* ---------- States ---------- */
.skel { display: inline-block; height: 12px; border-radius: 6px; background: var(--fill); animation: pulse 1.3s ease-in-out infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .45; } }
.muted { color: var(--text-2); }
.note { padding: 14px 16px; font-size: 14px; color: var(--text-2); }
.empty { padding: 48px 0; text-align: center; color: var(--text-2); }

/* ---------- Footer ---------- */
.foot {
  display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center;
  padding-top: 40px; padding-bottom: calc(28px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--text-3);
}
.foot a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 30;
  padding: 10px 18px; border-radius: 22px;
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg);
  font-size: 15px; font-weight: 500;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 420px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .hero-ver { font-size: 34px; }
  .get { min-width: 0; }
  .row { gap: 10px; }
}

/* ---------- Families (generation groups) ---------- */
.fam { margin-top: 28px; }
.fam-title { margin: 0 4px 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.older { margin-top: 40px; }
.older-hint { margin: 8px 4px 0; font-size: 13px; color: var(--text-2); }
#olderList .fam { margin-top: 24px; }
#olderList .fam-title { font-size: 17px; font-weight: 600; color: var(--text-2); }
.disclose .muted { font-size: 15px; }

/* ---------- Downgrade ---------- */
.hero-dg {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px;
  margin-top: 16px; padding-top: 14px; border-top: 0.5px solid var(--hair);
  font-size: 15px;
}
.hero-dg-label { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; min-width: 92px; }
.chip {
  display: inline-block; margin: 2px 6px 2px 0; padding: 2px 9px; border-radius: 8px;
  background: var(--fill); font-size: 14px; font-weight: 500; color: var(--text);
}
.hero-dg.yes > span:last-child { color: var(--green); }

.dg-toggle {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px;
  font-size: 13px; font-weight: 600; color: var(--green);
}
.dg-toggle .chev { width: 6px; height: 10px; color: currentColor; transition: transform .2s; }
.dg-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }

.dg-panel { margin: 0 16px 12px; border-radius: 10px; background: var(--fill); overflow: hidden; }
.dg-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.dg-row + .dg-row::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 0.5px solid var(--hair); }
.dg-ver { font-size: 15px; font-weight: 600; }
.dg-panel .get { background: var(--surface); }
.dg-panel .icon-act:hover { background: var(--surface); }
.get.sm { min-width: 0; height: 28px; font-size: 14px; }
.dg-no { color: var(--red); font-weight: 600; }

/* ---------- Small phones ---------- */
.dg-toggle { white-space: nowrap; }
@media (max-width: 400px) {
  .get { padding: 0 12px; }
  .dg-panel { margin: 0 12px 12px; }
  .hero-dg-label { min-width: 0; width: 100%; }
}

/* ---------- Device lookup ---------- */
.lookup { display: flex; gap: 8px; align-items: center; }
.lookup .search { flex: 1; margin-top: 0; }
.lookup .get { height: 40px; border-radius: 10px; min-width: 0; padding: 0 16px; }
.lookup input { text-transform: none; }
#lookupResult .result { margin-top: 12px; }
.result-head { padding: 16px 16px 12px; border-bottom: 0.5px solid var(--hair); }
.result-head:only-child { border-bottom: 0; }
.result-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.result-sub { margin-top: 4px; font-size: 14px; color: var(--text-2); line-height: 1.45; }
.result-sub b { color: var(--text); font-weight: 600; }

/* Home list separators */
a.row + a.row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 70px;
  border-top: 0.5px solid var(--hair);
}

/* =========================================================
   Device family colors + home tiles
   Solid, deep "finish" colors (no gradients), white text.
   ========================================================= */
:root {
  --c-iphone: #1d3557;    /* midnight blue */
  --c-ipad: #4a3b6b;      /* deep plum */
  --c-macbook: #3a3f47;   /* graphite */
  --c-imac: #24584a;      /* deep green */
}
body[data-cat="iphone"]  { --cat: var(--c-iphone); }
body[data-cat="ipad"]    { --cat: var(--c-ipad); }
body[data-cat="macbook"] { --cat: var(--c-macbook); }
body[data-cat="imac"]    { --cat: var(--c-imac); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  aspect-ratio: 1.15 / 1; padding: 16px;
  border-radius: 18px; color: #fff; text-align: center;
  background: var(--t);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform .15s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover { filter: brightness(1.08); }
.tile:active { transform: scale(0.98); }
.tile-iphone  { --t: var(--c-iphone); }
.tile-ipad    { --t: var(--c-ipad); }
.tile-macbook { --t: var(--c-macbook); }
.tile-imac    { --t: var(--c-imac); }

.tile-glyph { color: rgba(255, 255, 255, 0.95); }
.tile-glyph svg { width: 40px; height: 40px; display: block; }
.tile-name { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.tile-dot {             /* new version since your last visit */
  position: absolute; top: 14px; right: 14px;
  width: 9px; height: 9px; border-radius: 50%; background: #fff;
}

@media (min-width: 640px) {
  .tile { aspect-ratio: 2.2 / 1; }
  .tile-glyph svg { width: 48px; height: 48px; }
  .tile-name { font-size: 22px; }
}
@media (max-width: 360px) {
  .tiles { gap: 10px; }
  .tile { border-radius: 16px; gap: 10px; }
  .tile-glyph svg { width: 34px; height: 34px; }
  .tile-name { font-size: 17px; }
}
@media (prefers-color-scheme: dark) {
  .tile { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
}

/* Category pages: a touch of the family color in the release card */
.eyebrow { display: flex; align-items: center; gap: 8px; }
.cat-badge {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--cat, var(--accent)); color: #fff;
}
.cat-badge svg { width: 15px; height: 15px; }
@media (prefers-color-scheme: dark) { .cat-badge { box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); } }

/* =========================================================
   Check page + camera scanner
   ========================================================= */
.check-card {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow);
  transition: background .15s;
}
.check-card:hover { background: var(--fill); }
.check-card:active { transform: scale(0.99); }
.check-card .row-title, .check-card .row-sub { display: block; }
.check-icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--text); color: var(--bg);
}
.check-card .chev { color: var(--text-3); }

.scan-btn {
  width: 100%; margin-top: 10px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--text); color: var(--bg); font-size: 16px; font-weight: 600;
  transition: opacity .15s;
}
.scan-btn:hover { opacity: .9; }
.scan-btn:active { transform: scale(0.99); }

.scan-reading { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 14px 16px;
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); color: var(--text-2); font-size: 15px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fill-hover); border-top-color: var(--text); animation: spin .8s linear infinite; }
#scanFound .result { margin-top: 16px; }
.found { margin-top: 16px; }
.found-label { font-size: 14px; color: var(--text-2); margin: 0 4px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.found-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 10px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  font-size: 16px; font-weight: 600; text-align: left;
}
.found-chip small { font-size: 12px; font-weight: 500; color: var(--text-2); }
.found-chip:hover { background: var(--fill); }

/* Full-screen camera */
body.no-scroll { overflow: hidden; }
.scanner { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-shade { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan-frame {
  width: min(86vw, 520px); height: min(24vw, 140px); min-height: 90px;
  border-radius: 14px; border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
}
.scan-hint {
  position: absolute; left: 0; right: 0; top: calc(50% - min(12vw, 70px) - 64px);
  text-align: center; font-size: 15px; font-weight: 500; padding: 0 24px; text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.scan-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 20px 24px calc(28px + env(safe-area-inset-bottom));
}
.scan-side { color: #fff; font-size: 17px; padding: 10px; }
.scan-side:first-child { justify-self: start; }
.scan-side:last-child { justify-self: end; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.shutter span { width: 58px; height: 58px; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(0.9); }

/* Auto-capture status on the camera screen */
.scan-status {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(50% + min(12vw, 70px) + 24px);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 500;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.spinner.light { width: 14px; height: 14px; border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.scan-frame { transition: border-color .15s, box-shadow .15s; }
.scan-frame.locked { border-color: #34c759; border-width: 3px; }

/* No zooming anywhere (double-tap / pinch) */
html, body { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.scanner, .scanner * { touch-action: none; }

/* Check page: give the input a little more room from the title */
.check-form { margin-top: 28px; }

/* Footer always at the bottom, even on short pages */
#app { flex: 1; }

/* Camera scan only on touch devices (phones, tablets); hidden on laptops and desktops */
@media not (any-pointer: coarse) { .scan-btn { display: none; } }

/* No extra scrolling or rubber-band bounce when a page fits on screen.
   100dvh = the height you actually see (100vh on iPhone includes space behind the bars). */
html, body { overscroll-behavior: none; }
body { min-height: 100vh; min-height: 100dvh; }
.foot { padding-top: 24px; }

/* =========================================================
   Phones: one "⋯" button per row instead of copy + Download
   ========================================================= */
.more-btn { display: none; }
@media (max-width: 600px) {
  .actions .icon-act, .actions .get { display: none; }
  .more-btn {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
    color: var(--accent); background: var(--fill);
  }
  .more-btn:active { background: var(--fill-hover); }
  .dg-panel .more-btn { background: var(--surface); }
}

/* Bottom menu (action sheet) */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0); transition: background .2s; }
.sheet-wrap.open .sheet-backdrop { background: rgba(0, 0, 0, 0.35); }
.sheet {
  position: absolute; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
  transform: translateY(110%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-group, .sheet-cancel { border-radius: 14px; overflow: hidden; background: var(--surface); }
.sheet-head { padding: 14px 16px 12px; text-align: center; border-bottom: 0.5px solid var(--hair); }
.sheet-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.sheet-sub { margin-top: 2px; font-size: 13px; color: var(--text-3); }
.sheet-btn {
  display: block; width: 100%; padding: 17px 16px; text-align: center;
  font-size: 19px; color: var(--accent); background: var(--surface);
}
.sheet-group .sheet-btn + .sheet-btn { border-top: 0.5px solid var(--hair); }
.sheet-btn:active { background: var(--fill); }
.sheet-cancel { font-weight: 600; }

/* =========================================================
   iPad: one card per restore file
   ========================================================= */
.file-card + .file-card { margin-top: 12px; }
.file-head { border-bottom: 0.5px solid var(--hair); }
.file-ver { font-size: 17px; font-weight: 600; }
.file-ver .num { font-weight: 400; color: var(--text-2); font-size: 15px; margin-left: 4px; }
.file-card .dg-panel { margin-top: 12px; }
.file-models { padding: 6px 0; }
.file-model {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 16px; font-size: 15px;
}
.file-model-name { min-width: 0; }
.file-model .num { flex: none; font-size: 13px; color: var(--text-2); }

/* File name as the card title; long names (e.g. "iPad17,1,iPad17,2,…_Restore.ipsw") wrap cleanly */
.file-name {
  font-size: 17px; font-weight: 600; line-height: 1.3;
  overflow-wrap: break-word;   /* breaks after _ and , (via <wbr>), mid-word only if unavoidable */
}

.fam-year { margin-left: 8px; font-size: 15px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.nowrap { white-space: nowrap; }
