:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: #15281e;
  background: #f3f6f2;
  --ink: #15281e;
  --muted: #4f6457;
  --line: #dce6de;
  --green: #18563c;
  --night: #0d261b;
  --lime: #dcf989;
  --amber: #ffb547;
  --amber-dark: #e8962a;
  --cream: #f3ebdd;
  --white: #fff;
  --soft: #edf4ee;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body, h1, h2, h3, p { margin: 0; }
body { min-width: 0; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--green); text-underline-offset: .2em; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid #44845b; outline-offset: 3px; }
[hidden] { display: none !important; }
.container { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.sprites { position: absolute; }

/* Шапка */
.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 5;
  background: #0d261be6;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.bar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  color: var(--white);
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand img { display: block; width: 40px; }
.brand b { color: var(--amber); font-weight: 800; }
nav { display: flex; align-items: center; gap: 18px; min-width: 0; }
nav a { padding: 12px 0; color: #cfe3d6; font-size: .9375rem; text-decoration: none; }
nav a:hover { color: var(--white); text-decoration: underline; }
nav a:focus-visible { border-radius: 4px; outline-color: var(--lime); }

/* Кнопки */
.outline, .primary, .cta {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 8px 15px;
  font-size: .9375rem;
  font-weight: 720;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}
.outline { color: var(--ink); background: var(--white); }
.outline:hover:enabled, a.outline:hover { background: var(--soft); }
.primary { border-color: var(--green); background: var(--green); color: var(--white); }
.primary:hover:enabled, a.primary:hover { background: #11462f; }
.cta {
  min-height: 52px;
  padding: 12px 22px;
  border: 0;
  border-radius: 16px;
  background: var(--amber);
  color: #1e1d22;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 7px 0 -2px var(--amber-dark), 0 18px 30px -12px #ffb5478c;
  transition: transform .12s;
}
.cta:hover { background: #ffc266; }
.cta:active { transform: translateY(3px); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Первый экран: ночь и енотик с фонариком */
.night {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 90% at 15% 0%, #1f6a4a 0%, #14432f 38%, var(--night) 78%);
  color: var(--white);
}
.moon {
  display: none;
  position: absolute;
  inset: 30px auto auto 47%;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 0 14px #f3ebdd12, 0 0 60px 20px #f3ebdd2e;
  opacity: .9;
}
.moon::after { position: absolute; inset: -6% auto auto 30%; width: 86%; height: 86%; border-radius: 50%; background: #184a35; content: ""; }
.firefly {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px 3px #dcf98999;
  animation: firefly-drift 7s ease-in-out infinite, firefly-glow 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes firefly-drift { 0%, 100% { transform: translate(0, 0); } 33% { transform: translate(16px, -22px); } 66% { transform: translate(-14px, -10px); } }
@keyframes firefly-glow { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }
.hero { position: relative; display: grid; grid-template-columns: 1fr 1.05fr; align-items: center; gap: 30px; padding-block: 44px 96px; }
h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); line-height: 1.05; letter-spacing: -.03em; font-weight: 800; }
h1 span { color: var(--amber); white-space: nowrap; }
.hero p { max-width: 30em; margin: 14px 0 20px; color: #cfe3d6; font-size: 1.125rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.hero-link { display: inline-flex; min-height: 44px; align-items: center; color: #eff9ef; font-weight: 650; }
.stage {
  position: relative;
  aspect-ratio: 10 / 9;
  --ox: 30%;
  --oy: 85.5%;
  --r: 60px;
  --x: 62%;
  --y: 22%;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.stage-icons { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); align-content: start; gap: 5% 4%; padding: 2% 1% 0 30%; }
.stage-icons img { display: block; width: 100%; aspect-ratio: 1; border-radius: 23%; object-fit: cover; transition: transform .25s; }
.stage-icons.dim img { filter: grayscale(1) brightness(.36) contrast(.9); opacity: .55; }
.stage-icons.lit {
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle var(--r) at var(--x) var(--y), #000 55%, transparent 100%);
  mask-image: radial-gradient(circle var(--r) at var(--x) var(--y), #000 55%, transparent 100%);
}
.stage-icons.lit img.is-lit { transform: scale(1.1); }
.spot {
  position: absolute;
  inset: var(--y) auto auto var(--x);
  width: calc(var(--r) * 2.6);
  height: calc(var(--r) * 2.6);
  margin: calc(var(--r) * -1.3) 0 0 calc(var(--r) * -1.3);
  border-radius: 50%;
  background: radial-gradient(circle, #ffd68c66 0%, #ffb54729 45%, transparent 70%);
  mix-blend-mode: screen;
  pointer-events: none;
}
.beam {
  position: absolute;
  inset: var(--oy) auto auto var(--ox);
  height: calc(var(--r) * 1.9);
  margin-top: calc(var(--r) * -.95);
  transform-origin: 0 50%;
  clip-path: polygon(0 46%, 100% 0, 100% 100%, 0 54%);
  background: linear-gradient(90deg, #ffd68cd9, #ffb5471a);
  mix-blend-mode: screen;
  pointer-events: none;
}
.stage-enot { position: absolute; inset: auto auto -2% -3%; width: 38%; filter: drop-shadow(0 10px 14px #00000059); pointer-events: none; }
.torch {
  position: absolute;
  inset: var(--oy) auto auto var(--ox);
  width: 9%;
  aspect-ratio: 2 / 1;
  border-radius: 30%;
  background: var(--amber);
  box-shadow: inset -7px 0 0 #3a3840;
  transform: translate(-28%, -50%);
  transform-origin: 28% 50%;
  pointer-events: none;
}
.hill { position: absolute; inset: auto 0 -1px; display: block; width: 100%; height: 90px; }

/* Рабочая часть */
.webview-note { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; padding: 12px 14px; border-radius: 18px; background: var(--cream); color: #4a4238; }
.webview-note img { flex: none; width: 72px; }
.webview-note .outline { margin-top: 8px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); align-items: start; gap: 20px; margin-top: 6px; }
.sidebar { position: relative; display: grid; gap: 16px; min-width: 0; margin-top: 56px; }
.peeker { position: absolute; inset: -70px 22px auto auto; z-index: 0; width: 128px; pointer-events: none; }
.panel {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 8px 22px #17382009;
  scroll-margin-top: 74px;
}
h2 { font-size: clamp(1.3rem, 2.5vw, 1.6rem); line-height: 1.15; letter-spacing: -.02em; }
h3 { font-size: 1rem; line-height: 1.3; }
.workspace-header, .account-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.workspace-header p, .account p { margin-top: 5px; color: var(--muted); font-size: .9375rem; line-height: 1.4; }
.account p { overflow-wrap: anywhere; }
.account-heading > div { min-width: 0; }
.account-apple { display: grid; gap: 13px; margin-top: 15px; padding: 14px; border-radius: 16px; background: var(--soft); }
.account-apple .actions { justify-content: start; }
.account-apple .actions button { overflow-wrap: anywhere; }

.catalog-toolbar { display: grid; gap: 8px; margin: 12px 0 6px; }
.catalog-controls { display: flex; min-width: 0; align-items: center; gap: 8px; }
.tabs { display: flex; max-width: 100%; gap: 4px; padding: 4px; border-radius: 14px; background: #eaf0ea; }
.tabs button {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  padding: 5px 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 680;
  text-align: center;
}
.tabs button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px #15281e1f; }
.tabs button:hover:enabled { color: var(--green); }
.search { display: flex; position: relative; flex: 1; min-width: 0; align-items: center; }
.search input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 10px 0 36px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fafcfa;
  color: var(--ink);
  font-size: 1rem;
}
.search input:focus { border-color: var(--green); background: var(--white); outline: 0; }
.search input::placeholder { color: var(--muted); }
.glass { position: absolute; inset-inline-start: 13px; width: 13px; height: 13px; border: 1.6px solid var(--muted); border-radius: 50%; pointer-events: none; }
.glass::after { position: absolute; right: -4px; bottom: -2px; width: 5px; height: 1.6px; transform: rotate(45deg); background: var(--muted); content: ""; }
.category-filter { flex: 0 0 clamp(132px, 38%, 172px); }
.category-filter select {
  width: 100%;
  min-height: 46px;
  padding-inline: 8px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--white);
  color: var(--green);
  font: inherit;
}
body[data-state="guest"] .catalog-toolbar, body[data-state="guest"] #refresh { display: none; }

#status-box { margin: 10px 0; padding: 11px 13px; border-radius: 14px; background: var(--soft); color: #284c38; }
#status-box.error { background: #fff0e9; color: #7c3020; }
#status-box.inline-status { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip-path: inset(50%); }
#status-box:has(.activity-track:not([hidden])) { min-height: 62px; padding-left: 78px; background: var(--soft) url("enot/focus.webp") 12px center / 54px auto no-repeat; }
.activity-track { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 6px; background: #d1e4d4; }
.activity-track::before {
  display: block;
  width: 36%;
  height: 100%;
  border-radius: inherit;
  background: var(--amber);
  animation: purchase-progress 1.35s ease-in-out infinite alternate;
  content: "";
}
@keyframes purchase-progress { to { transform: translateX(178%); } }
.apple-feedback.is-waiting::before {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 2px solid #c8dccb;
  border-top-color: var(--green);
  border-right-color: var(--green);
  border-radius: 50%;
  animation: activity-spin .85s linear infinite;
  content: "";
}
@keyframes activity-spin { to { transform: rotate(1turn); } }
#file-link { margin-bottom: 10px; }
.results-count { margin: 7px 0 3px; color: var(--muted); font-size: .875rem; }
.empty { display: grid; justify-items: center; min-height: 180px; padding: 22px 10px 18px; text-align: center; }
.empty-face { width: 120px; margin-bottom: 8px; }
.empty p { max-width: 31ch; margin: 6px 0 10px; color: var(--muted); }
.showcase-cta { display: grid; justify-items: stretch; gap: 10px; margin-top: 14px; }
.showcase-cta p { color: var(--muted); font-size: .9375rem; text-align: center; }

/* Строки каталога */
.app-list { margin: 0; padding: 0; list-style: none; }
.app-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 1px;
  border-bottom: 1px solid var(--line);
}
.app-row:last-child { border-bottom: 0; }
.initial, .app-icon { width: 48px; height: 48px; border-radius: 23%; }
.initial { display: grid; place-items: center; background: #e6efdc; color: #2b4c34; font-weight: 750; }
.app-row:nth-child(even) .initial { background: #e7eef0; color: #314c59; }
.app-icon { display: block; object-fit: cover; box-shadow: 0 2px 6px #15281e24; }
.app-row h3, .app-row p { overflow-wrap: anywhere; }
.app-row p { margin-top: 2px; color: var(--muted); font-size: .875rem; line-height: 1.3; }
.app-row > .outline { min-width: 112px; border-color: var(--green); background: var(--green); color: var(--white); transition: transform .1s; }
.app-row > .outline:hover:enabled { background: #11462f; }
.app-row > .outline:active:enabled { transform: scale(.96); }
.app-row.is-downloading > .outline { gap: 7px; max-width: none; border-color: var(--line); background: var(--soft); color: var(--muted); opacity: 1; overflow-wrap: normal; white-space: nowrap; }
.app-row.is-downloading > .outline::before {
  flex: none;
  width: 38px;
  height: 28px;
  background: url("enot/focus.webp") center / contain no-repeat;
  animation: enot-scrub .5s ease-in-out infinite alternate;
  content: "";
}
.app-row.is-downloading > .app-icon { animation: enot-scrub .5s ease-in-out infinite alternate; }
@keyframes enot-scrub { to { transform: translateX(3px) rotate(4deg); } }
.editions-toggle {
  display: inline-flex;
  max-width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
}
.editions-indicator {
  position: relative;
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eaf0ea;
  color: var(--muted);
}
.editions-indicator span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.editions-toggle:hover .editions-indicator, .editions-toggle[aria-expanded="true"] .editions-indicator { background: #dbe7dc; color: var(--green); }
.editions-indicator::after {
  position: absolute;
  inset: 8px auto auto 10px;
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform .2s;
  content: "";
}
.editions-toggle[aria-expanded="true"] .editions-indicator::after { transform: translateY(4px) rotate(225deg); }
.app-list.app-editions { grid-column: 1 / -1; min-width: 0; padding-left: 14px; border-left: 2px solid var(--line); }
.app-editions .app-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
.app-editions .app-icon, .app-editions .initial { width: 40px; height: 40px; }
.show-more { display: flex; width: 100%; margin-top: 13px; }

/* Инструкция */
.guide ol { list-style: none; padding: 0; margin: 14px 0 0; }
.guide li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 0 0 14px; }
.guide-step { width: 32px; height: 32px; fill: var(--green); }
.guide li:nth-child(2) .guide-step { transform: rotate(14deg) translateX(6px); }
.guide li:nth-child(3) .guide-step { transform: rotate(-10deg); }
.guide p { margin-top: 3px; color: var(--muted); }
.free-note { margin-top: 2px; padding: 12px 13px; border-radius: 14px; background: var(--soft); color: var(--ink); }
.prices { margin: 10px 0 0; }
.prices div { display: flex; gap: 8px; justify-content: space-between; border-top: 1px solid var(--line); padding: 7px 0; }
.prices dd { margin: 0; font-weight: 700; white-space: nowrap; }

/* Окна */
dialog { width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 24px; border: 1px solid var(--line); border-radius: 26px; background: var(--white); color: var(--ink); box-shadow: 0 18px 65px #142c2344; }
dialog::backdrop { background: #0d261b8c; }
dialog h2 { margin-right: 40px; }
dialog p { margin: 8px 0 13px; color: var(--muted); }
.dialog-enot { display: block; width: 112px; margin: -4px auto 6px; }
.dialog-close { position: absolute; right: 10px; top: 9px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 1.5rem; }
.dialog-close:hover { background: #dbe7dc; }
dialog label { display: grid; gap: 6px; font-weight: 650; }
dialog input { width: 100%; min-height: 48px; padding: 0 13px; border: 1.5px solid var(--line); border-radius: 13px; background: #fafcfa; color: var(--ink); font-size: 1rem; }
dialog input:focus { border-color: var(--green); background: var(--white); outline: 0; }
dialog form .primary, dialog form .outline { width: 100%; min-height: 50px; margin-top: 14px; }
#dialog-error, #apple-status.error { color: #7c3020; }
#dialog-error { margin-bottom: 0; }
.apple-credentials { display: grid; gap: 12px; }
dialog .apple-note { margin: 0; padding: 11px 13px; border-radius: 14px; background: var(--cream); color: #4a4238; font-size: .875rem; }
.apple-feedback { margin-top: 13px; }
.apple-feedback.is-waiting { display: flex; align-items: flex-start; gap: 9px; padding: 12px 13px; border-radius: 13px; background: var(--soft); }
.apple-feedback.is-waiting::before { margin-top: 3px; }
.apple-feedback p { margin: 0; }
.apple-feedback .apple-elapsed { margin-top: 3px; font-size: .875rem; font-variant-numeric: tabular-nums; }

#install-dialog .actions .primary, #install-dialog .actions .outline { flex: 1; min-height: 52px; font-size: 1rem; }
#install-dialog #install-link.primary { border: 0; background: var(--amber); color: #1e1d22; font-weight: 800; box-shadow: 0 6px 0 -1px var(--amber-dark); }
.install-preview { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.home-tile { flex: none; width: 104px; padding: 12px 6px 8px; border-radius: 20px; background: linear-gradient(160deg, #2b6f8f, #1b3a5c 60%, #3a2a5a); text-align: center; }
.home-tile small { display: block; margin-top: 5px; color: var(--white); font-size: .6875rem; }
.install-preview-icon {
  position: relative;
  display: grid;
  width: 60px;
  height: 60px;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 23%;
  background: var(--green);
}
.install-preview-icon img { width: 100%; height: 100%; object-fit: cover; }
.install-preview-icon::before { position: absolute; inset: 0; background: #00000085; content: ""; }
.install-preview-icon::after {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid #ffffff70;
  border-top-color: #fff;
  border-right-color: #fff;
  border-radius: 50%;
  animation: activity-spin 1.1s linear infinite;
  content: "";
}
.install-preview strong { display: block; }
.install-preview div span { color: var(--muted); font-size: .875rem; }
.install-ask { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.install-ask ul { margin: 10px 0 0; padding-left: 18px; font-size: .9375rem; }
.install-ask li { margin-bottom: 6px; }
.install-ask .actions { margin-top: 12px; }

/* Енотик уносит иконку */
.runner { position: fixed; inset: auto auto 8px 0; z-index: 2147483647; width: 150px; transform: translateX(-170px); pointer-events: none; }
.runner.is-running { animation: runner-run 1.9s cubic-bezier(.45, .05, .55, .95) forwards; }
@keyframes runner-run { to { transform: translateX(calc(100vw + 30px)); } }
.runner-bob { position: relative; animation: runner-bob .2s ease-in-out infinite alternate; }
.runner-bob img { display: block; }
@keyframes runner-bob { to { transform: translateY(-9px) rotate(3deg); } }
.runner-icon { position: absolute; inset: 44% auto auto 66%; width: 46px; height: 46px; border-radius: 23%; box-shadow: 0 3px 8px #00000040; transform: rotate(8deg); }
.runner-icon:not([src]) { display: none; }
.confetti { position: fixed; z-index: 2147483647; width: 9px; height: 14px; border-radius: 3px; pointer-events: none; animation: confetti-fly 1.4s ease-out forwards; }
@keyframes confetti-fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rt)); opacity: 0; } }

.footer { margin-block: 26px; padding-block: 12px 6px; color: var(--muted); font-size: .875rem; text-align: center; }

@media (min-width: 900px) { .moon { display: block; } }
@media (max-width: 899px) {
  .container { width: calc(100% - 36px); }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-block: 22px 58px; }
  .hero p { margin: 10px 0 16px; font-size: 1rem; }
  .stage { aspect-ratio: auto; height: 186px; --ox: 35.5%; --oy: 72%; --x: 70%; --y: 30%; }
  .stage-icons { grid-template-columns: repeat(3, 1fr); gap: 9% 6%; padding: 3% 1% 0 47%; }
  .stage-icons img:nth-child(n+7) { display: none; }
  .stage-enot { inset: auto auto -4% -2%; width: 44%; max-width: 170px; }
  .hill { height: 50px; }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 580px) {
  .container { width: calc(100% - 24px); }
  .bar { gap: 8px; }
  nav { gap: 13px; }
  nav a { min-height: 44px; display: inline-flex; align-items: center; font-size: .875rem; }
  nav a[href="#setup"] { display: none; }
  .hero-link { display: none; }
  .split, .sidebar { gap: 13px; }
  .panel { padding: 16px; border-radius: 20px; scroll-margin-top: 66px; }
  .workspace-header { gap: 7px; }
  .workspace-header .actions button { max-width: 140px; padding-inline: 10px; }
  .app-row { gap: 10px; }
  .app-row > .outline { min-width: 0; max-width: 118px; padding-inline: 10px; overflow-wrap: anywhere; }
  .app-row.is-downloading > .outline::before { width: 30px; height: 22px; }
  dialog { width: 100%; max-width: 100%; max-height: 92%; margin: auto 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); border: 0; border-radius: 28px 28px 0 0; }
}
@media (max-width: 359px) { nav a[href="#workspace"] { display: none; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
