/* Upgrade 3: install + notifications screen (#app), the offline banner and the update toast. Prefix: .pw- */
.pw-head { text-align: center; margin: 8px auto 4px; max-width: 640px; }
.pw-title { font-size: clamp(30px, 5vw, 46px); margin: 12px 0 6px; }
.pw-sub { color: var(--ink-2); margin: 0 auto; max-width: 520px; font-size: 14.5px; }

/* hero: the app icon as a floating 3D tile */
.pw-hero { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 20px 0 26px; }
.pw-icon3d { position: relative; width: 180px; height: 192px; perspective: 900px; display: grid; justify-items: center; align-content: start; padding-top: 6px; }
.pw-tilt { --rx: 10deg; --ry: -14deg; position: relative; width: 152px; height: 152px; border-radius: 34px; overflow: hidden;
  transform: rotateX(var(--rx)) rotateY(var(--ry)); transition: transform .45s cubic-bezier(.2, .7, .2, 1); animation: pwFloat 6s ease-in-out infinite;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 34px 60px -24px rgba(0, 0, 0, .9), 0 0 70px -12px rgba(16, 188, 131, .5); }
.pw-tilt img { width: 100%; height: 100%; display: block; transform: scale(1.067); }
.pw-shine { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(118deg, rgba(255, 255, 255, .24), rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, .06)); }
.pw-floor { position: absolute; bottom: 4px; width: 150px; height: 20px; border-radius: 50%; background: radial-gradient(closest-side, rgba(16, 188, 131, .6), transparent); filter: blur(7px); animation: pwFloor 6s ease-in-out infinite; }
@keyframes pwFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes pwFloor { 0%, 100% { opacity: .9; scale: 1; } 50% { opacity: .6; scale: .9; } }

.pw-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pw-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-ctl); font-size: 12.5px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .03); color: var(--ink-2); white-space: nowrap; }
.pw-chip svg, .pw-saved svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-chip.on { color: var(--mint); border-color: rgba(16, 188, 131, .45); background: rgba(16, 188, 131, .08); }
.pw-chip.bad { color: #F7A3A6; border-color: rgba(242, 103, 107, .45); background: rgba(242, 103, 107, .08); }

/* the two cards */
.pw-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; max-width: 1120px; margin: 0 auto; }
.pw-card { padding: 22px; }
.pw-card .pw-h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 17px; font-weight: 500; color: var(--ink); }
.pw-h-ic { width: 32px; height: 32px; padding: 6px; border-radius: 10px; flex: none; color: var(--mint); fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  background: radial-gradient(120% 120% at 30% 20%, color-mix(in srgb, var(--accent) 38%, transparent), color-mix(in srgb, var(--accent) 8%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.pw-h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 18px 0 10px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.pw-card .pw-h2 + .pw-h3 { margin-top: 0; }
.pw-p { margin: 0 0 4px; color: var(--ink-2); font-size: 14px; line-height: 1.65; }

/* states */
.pw-state { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.pw-state b { font-weight: 500; font-size: 14.5px; }
.pw-state p { margin: 4px 0 0; }
.pw-state > p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.65; }
.pw-state-ic { width: 36px; height: 36px; flex: none; padding: 8px; border-radius: 12px; color: var(--ink-3); background: rgba(255, 255, 255, .05);
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-state.ok { border-color: rgba(16, 188, 131, .35); background: linear-gradient(rgba(16, 188, 131, .10), rgba(16, 188, 131, .02)); }
.pw-state.ok .pw-state-ic { color: var(--mint); background: rgba(16, 188, 131, .16); }
.pw-state.warn { border-color: rgba(240, 182, 90, .4); background: rgba(240, 182, 90, .06); }
.pw-state.warn .pw-state-ic { color: var(--warn); background: rgba(240, 182, 90, .12); }
.pw-state.bad { border-color: rgba(242, 103, 107, .35); background: rgba(242, 103, 107, .05); }
.pw-state.bad .pw-state-ic { color: var(--down); background: rgba(242, 103, 107, .12); }

/* topic switches */
.pw-topics { display: flex; flex-direction: column; gap: 8px; }
.pw-topic { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .02);
  text-align: start; cursor: pointer; color: var(--ink); font: inherit; transition: border-color .2s, background .2s; }
.pw-topic:hover { border-color: rgba(255, 255, 255, .26); }
.pw-topic:disabled { opacity: .6; cursor: default; }
.pw-topic[aria-checked="true"] { border-color: rgba(16, 188, 131, .42); background: rgba(16, 188, 131, .06); }
.pw-tp-ic { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; color: var(--gold);
  background: radial-gradient(120% 120% at 30% 20%, color-mix(in srgb, var(--gold) 32%, transparent), color-mix(in srgb, var(--gold) 6%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 35%, transparent); }
.pw-tp-ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pw-tp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pw-tp-txt b { font-weight: 500; font-size: 14px; }
.pw-tp-txt small { color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.pw-switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: var(--r-ctl); background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 1px var(--line-2); transition: background .2s; }
.pw-switch i { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); transition: inset-inline-start .2s; }
.pw-topic[aria-checked="true"] .pw-switch { background: var(--accent); box-shadow: 0 0 14px -2px rgba(16, 188, 131, .7); }
.pw-topic[aria-checked="true"] .pw-switch i { inset-inline-start: 21px; }
.pw-saved { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 400; color: var(--mint); margin-inline-start: 4px; }

.pw-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.pw-bi { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* each "open" link is a 41.5 px target (the line is 13 x 1.5 = 19.5 px): the margins give the padding back,
   so nothing moves; the 22 px row gap keeps two wrapped rows' targets apart (the 14 px above and the card's
   padding below already hold the 11 px). The sign-in link inside .pw-note sits in a sentence and stays inline. */
.pw-links { display: flex; flex-wrap: wrap; gap: 22px 18px; margin-top: 14px; font-size: 13px; }
.pw-links .pw-link { padding-block: 11px; margin-block: -11px; }
.pw-link { color: var(--mint); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--mint) 35%, transparent); text-underline-offset: 3px; }
.pw-note { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.pw-note.err { color: #F7A3A6; background: rgba(242, 103, 107, .08); border: 1px solid rgba(242, 103, 107, .35); }
.pw-note.warn { color: #F6CF8C; background: rgba(240, 182, 90, .07); border: 1px solid rgba(240, 182, 90, .35); }
/* "stopped when you signed out": icon + text, sits between the off state and the topics */
.pw-signed-out { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 2px; }
.pw-note-ic { width: 17px; height: 17px; flex: none; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* iPhone guide: four drawn mini screens */
.pw-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pw-step { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pw-step-t { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.pw-step-n { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; text-align: center !important;
  background: linear-gradient(180deg, #F4FFFA, #CFF2E6); color: #05070D; box-shadow: 0 0 12px -2px rgba(16, 188, 131, .6); }
.pw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pw-tip { margin-top: 12px; }
.pw-more { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
/* a 40 px target (the line is 20 px); the margins give the padding back, so nothing moves (open, the
   heading's 18 px top margin still sets the gap below it) */
.pw-more summary { cursor: pointer; color: var(--mint); font-size: 13.5px; width: fit-content; border-radius: 8px; padding-block: 10px; margin-block: -10px; }

.pw-mock { position: relative; height: 132px; border-radius: 18px; padding: 10px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  font-size: 10.5px; color: var(--ink-2); background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02)); border: 1px solid var(--line-2); box-shadow: var(--shadow-in); }
.pw-mock svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-hl { color: var(--mint) !important; position: relative; }
@keyframes pwRing { 0%, 100% { box-shadow: 0 0 0 0 rgba(16, 188, 131, .55); } 50% { box-shadow: 0 0 0 5px rgba(16, 188, 131, 0); } }
/* 1: Safari bottom bar */
.pw-m-url { height: 22px; border-radius: 9px; background: rgba(255, 255, 255, .08); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; }
.pw-m-lock { width: 7px; height: 8px; border-radius: 2px; background: var(--ink-3); }
.pw-m-host { height: 5px; width: 50%; border-radius: 3px; background: rgba(255, 255, 255, .2); }
.pw-m-bar { display: flex; justify-content: space-between; align-items: center; padding: 0 2px; color: var(--ink-3); }
.pw-m-bar i { font-style: normal; width: 24px; height: 24px; display: grid; place-items: center; font-size: 16px; border-radius: 8px; }
.pw-m-bar svg { width: 17px; height: 17px; }
.pw-m-bar .pw-hl { background: rgba(16, 188, 131, .16); box-shadow: inset 0 0 0 1.5px var(--accent); animation: pwRing 1.8s ease-in-out infinite; }
.pw-m-tip { position: absolute; top: 12px; left: 0; right: 0; margin-inline: auto; width: fit-content; max-width: calc(100% - 12px); text-align: center; padding: 3px 10px; border-radius: var(--r-ctl); background: var(--accent); color: #04130D; font-weight: 600; font-size: 11px; white-space: nowrap; }
.pw-m-tip::after { content: ""; position: absolute; top: 100%; left: 50%; translate: -50% 0; border: 5px solid transparent; border-top-color: var(--accent); }
.pw-m1 { gap: 10px; }
.pw-m1 .pw-m-url { margin-top: auto; }
/* 2: share sheet */
.pw-m-sheet { border-radius: 12px; background: rgba(255, 255, 255, .06); padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.pw-m-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; border-radius: 9px; min-height: 28px; }
.pw-m-row.dim { opacity: .55; }
.pw-m-ph { height: 5px; width: 62%; border-radius: 3px; background: rgba(255, 255, 255, .22); }
.pw-m-ph.short { width: 42%; }
.pw-m-ib { width: 13px; height: 13px; border-radius: 4px; border: 1.5px solid rgba(255, 255, 255, .3); flex: none; }
.pw-m-row.pw-hl { background: rgba(16, 188, 131, .14); box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 18px -4px rgba(16, 188, 131, .6); color: var(--ink) !important; }
.pw-m-rt { font-size: 10.5px; line-height: 1.3; min-width: 0; }
.pw-m-ri { width: 16px; height: 16px; flex: none; color: var(--mint); }
/* 3: name + "Open as Web App" */
.pw-m-app { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 500; color: var(--ink); }
.pw-m-app img { border-radius: 9px; flex: none; }
.pw-m3 { justify-content: space-between; }
.pw-m3 .pw-m-app { padding: 4px 2px 0; }
.pw-m3 .pw-m-row.pw-hl { color: var(--ink) !important; }
.pw-m-tog { position: relative; flex: none; width: 30px; height: 18px; border-radius: var(--r-ctl); background: var(--accent); box-shadow: 0 0 10px -2px rgba(16, 188, 131, .8); }
.pw-m-tog i { position: absolute; top: 2px; inset-inline-end: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; }
/* 4: "Add" in the sheet header */
.pw-m4 { justify-content: flex-start; }
.pw-m-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-3); }
.pw-m-tt { width: 36px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .2); }
.pw-m-link.pw-hl { padding: 3px 9px; border-radius: 8px; font-weight: 600; background: rgba(16, 188, 131, .14); box-shadow: inset 0 0 0 1.5px var(--accent); animation: pwRing 1.8s ease-in-out infinite; }
.pw-m-app.big { margin: auto 0; flex-direction: column; gap: 6px; justify-content: center; }
.pw-m-app.big img { border-radius: 11px; box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .7), 0 0 18px -6px rgba(16, 188, 131, .6); }

/* offline banner (fixed, under the top bar) */
.pw-offline { position: fixed; z-index: 70; top: var(--pw-top, calc(66px + env(safe-area-inset-top))); left: 0; right: 0; margin-inline: auto; width: fit-content; display: flex; align-items: center; gap: 8px;
  max-width: calc(100vw - 32px); padding: 8px 16px; border-radius: var(--r-ctl); font-size: 13px; line-height: 1.4; color: #F6CF8C;
  background: rgba(28, 20, 8, .94); border: 1px solid rgba(240, 182, 90, .45); box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .8); backdrop-filter: blur(8px); animation: toastIn .3s ease both; }
.pw-off-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* "update ready" toast */
.toast.pw-update { display: flex; align-items: center; gap: 10px; border-color: rgba(16, 188, 131, .5); box-shadow: 0 0 30px -6px rgba(16, 188, 131, .35), 0 20px 50px -10px rgba(0, 0, 0, .8); }
.pw-upd-ic { color: var(--gold); font-size: 15px; }
.pw-upd-t { flex: 1; min-width: 0; }
.pw-upd-x { width: 30px; height: 30px; font-size: 13px; flex: none; }

@media (max-width: 1180px) { .pw-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .pw-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .pw-card { padding: 18px 14px; }
  .pw-hero { margin: 14px 0 20px; }
  .pw-icon3d { width: 150px; height: 160px; }
  .pw-tilt { width: 124px; height: 124px; border-radius: 28px; }
  .pw-floor { width: 120px; }
  .pw-steps { gap: 8px; }
  .pw-mock { height: 124px; padding: 8px; }
  .pw-step-t { font-size: 12.5px; }
  .pw-actions .btn { flex: 1 1 auto; }
}

/* light theme */
html[data-theme="light"] .pw-tilt { box-shadow: 0 0 0 1px rgba(16, 48, 36, .1), 0 30px 50px -24px rgba(16, 48, 36, .55), 0 0 60px -14px rgba(16, 188, 131, .45); }
html[data-theme="light"] .pw-floor { background: radial-gradient(closest-side, rgba(16, 168, 117, .45), transparent); }
html[data-theme="light"] .pw-chip { background: rgba(255, 255, 255, .6); }
html[data-theme="light"] .pw-chip.on { color: #0B7552; background: rgba(16, 188, 131, .10); border-color: rgba(16, 168, 117, .45); }
html[data-theme="light"] .pw-chip.bad, html[data-theme="light"] .pw-note.err { color: #B23338; }
html[data-theme="light"] .pw-state { background: rgba(255, 255, 255, .55); }
html[data-theme="light"] .pw-state-ic { background: rgba(16, 48, 36, .06); }
html[data-theme="light"] .pw-topic { background: rgba(255, 255, 255, .6); }
html[data-theme="light"] .pw-topic:hover { border-color: rgba(16, 48, 36, .28); }
html[data-theme="light"] .pw-topic[aria-checked="true"] { background: rgba(16, 188, 131, .08); border-color: rgba(16, 168, 117, .45); }
html[data-theme="light"] .pw-switch { background: rgba(16, 48, 36, .14); }
html[data-theme="light"] .pw-topic[aria-checked="true"] .pw-switch { background: #12B07C; }
html[data-theme="light"] .pw-note.warn { color: #8A5A12; }
html[data-theme="light"] .pw-step-n { background: linear-gradient(180deg, #16C98E, #0DA472); color: #fff; }
html[data-theme="light"] .pw-mock { background: linear-gradient(180deg, #FFFFFF, #F1F5F2); border-color: rgba(16, 48, 36, .12); }
html[data-theme="light"] .pw-m-url, html[data-theme="light"] .pw-m-sheet { background: rgba(16, 48, 36, .06); }
html[data-theme="light"] .pw-m-host, html[data-theme="light"] .pw-m-ph, html[data-theme="light"] .pw-m-tt { background: rgba(16, 48, 36, .2); }
html[data-theme="light"] .pw-m-ib { border-color: rgba(16, 48, 36, .3); }
html[data-theme="light"] .pw-hl { color: #0B7552 !important; }
html[data-theme="light"] .pw-m-tip { background: #0FA875; color: #fff; }
html[data-theme="light"] .pw-m-tip::after { border-top-color: #0FA875; }
html[data-theme="light"] .pw-m-row.pw-hl, html[data-theme="light"] .pw-m3 .pw-m-row.pw-hl { color: var(--ink) !important; }
html[data-theme="light"] .pw-offline { color: #7A4E0C; background: rgba(255, 246, 228, .96); border-color: rgba(183, 121, 31, .45); box-shadow: 0 14px 34px -14px rgba(16, 48, 36, .35); }

@media (prefers-reduced-motion: reduce) {
  .pw-tilt, .pw-floor, .pw-m-bar .pw-hl, .pw-m-link.pw-hl, .pw-offline { animation: none; }
  .pw-tilt { transition: none; }
  .pw-switch, .pw-switch i, .pw-topic { transition: none; }
}
