:root {
  --bg-0: #0b0c0e;
  --bg-1: #12141a;
  --bg-2: #181b22;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eaef;
  --muted: #8b919e;
  --accent: #c8d0dc;
  --focus: #9aa8bc;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Outfit", sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(90, 110, 140, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(40, 50, 70, 0.35), transparent 50%),
    linear-gradient(180deg, #0b0c0e 0%, #0e1014 100%);
  pointer-events: none;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(1.25rem + var(--safe-top)) calc(1.5rem + var(--safe-right)) 1.25rem calc(1.5rem + var(--safe-left));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(11, 12, 14, 0.72);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}

.header.is-scrolled {
  border-bottom-color: var(--line);
}

.brand {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.brand:hover {
  color: var(--accent);
}

.main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 2.5rem calc(1.5rem + var(--safe-right)) calc(4rem + var(--safe-bottom)) calc(1.5rem + var(--safe-left));
}

.home-title {
  margin: 0 0 0.4rem;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 2.75rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s var(--ease) 0.05s forwards;
}

.home-sub {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 300;
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s var(--ease) 0.15s forwards;
}

.sections {
  display: grid;
  gap: 0.65rem;
}

.section-btn {
  appearance: none;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  min-height: 3rem;
  padding: 1.05rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 27, 34, 0.55);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
  opacity: 1;
  transform: translateY(0);
  transition:
    background 0.22s var(--ease),
    border-color 0.22s var(--ease),
    transform 0.22s var(--ease),
    color 0.22s var(--ease),
    box-shadow 0.22s var(--ease),
    filter 0.22s var(--ease);
}

.section-btn.is-booting {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.55s var(--ease) forwards;
}

.section-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.14) 50%, transparent 70%);
  background-size: 220% 100%;
  background-position: 120% 0;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  transition: opacity 0.2s var(--ease);
}

.section-btn.is-pressed::after {
  opacity: 1;
  animation: sheen 0.55s var(--ease);
}

.section-btn:nth-child(1).is-booting { animation-delay: 0.2s; }
.section-btn:nth-child(2).is-booting { animation-delay: 0.25s; }
.section-btn:nth-child(3).is-booting { animation-delay: 0.3s; }
.section-btn:nth-child(4).is-booting { animation-delay: 0.35s; }
.section-btn:nth-child(5).is-booting { animation-delay: 0.4s; }
.section-btn:nth-child(6).is-booting { animation-delay: 0.45s; }
.section-btn:nth-child(7).is-booting { animation-delay: 0.5s; }
.section-btn:nth-child(8).is-booting { animation-delay: 0.55s; }
.section-btn:nth-child(9).is-booting { animation-delay: 0.6s; }
.section-btn:nth-child(10).is-booting { animation-delay: 0.65s; }
.section-btn:nth-child(11).is-booting { animation-delay: 0.7s; }

.section-btn-featured {
  text-align: center;
  grid-column: 1 / -1;
}

.section-btn:hover {
  background: rgba(32, 36, 46, 0.9);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.section-btn:active,
.section-btn.is-pressed {
  transform: scale(0.98);
  filter: brightness(1.12);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.section-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.home,
.panel {
  will-change: opacity, transform;
}

.home.is-enter {
  animation: viewIn 0.48s var(--ease) both;
}

.home.is-leave {
  animation: viewOut 0.28s ease both;
  pointer-events: none;
}

.panel {
  opacity: 0;
  transform: translateY(10px);
}

.panel.is-enter {
  animation: viewIn 0.5s var(--ease) both;
}

.panel.is-leave {
  animation: viewOut 0.28s ease both;
  pointer-events: none;
}

.panel.is-enter .panel-bar {
  animation: rise 0.45s var(--ease) 0.05s both;
}

.panel.is-enter .panel-title {
  animation: rise 0.5s var(--ease) 0.1s both;
}

.panel.is-enter .panel-body {
  animation: rise 0.55s var(--ease) 0.16s both;
}

.panel.hidden,
.home.hidden {
  display: none;
}

.panel-bar {
  margin: 0 0 1.75rem;
}

.back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  min-height: 2.5rem;
  padding: 0.35rem 0.15rem;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    color 0.2s var(--ease),
    transform 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.back:hover {
  color: var(--text);
  transform: translateX(-2px);
}

.back:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
}

.panel-title {
  margin: 0 0 1.5rem;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.panel-body {
  min-height: 40vh;
  border-top: 1px solid var(--line);
  padding-top: 1.75rem;
  color: #c4c8d0;
  font-size: 1.02rem;
  font-weight: 350;
  line-height: 1.7;
  overflow-wrap: break-word;
  word-break: break-word;
}

.panel-body > *:first-child {
  margin-top: 0;
}

.panel-body > *:last-child {
  margin-bottom: 0;
}

.panel-body h3,
.panel-body h4,
.panel-body h5 {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.panel-body h3 {
  margin: 2.25rem 0 0.85rem;
  font-size: 1.35rem;
}

.panel-body h4 {
  margin: 1.75rem 0 0.65rem;
  font-size: 1.12rem;
  color: #d5d9e0;
}

.panel-body h5 {
  margin: 1.4rem 0 0.5rem;
  font-size: 0.98rem;
  font-weight: 600;
  color: #b8bec9;
  font-family: "Outfit", sans-serif;
  letter-spacing: 0.01em;
  text-transform: none;
}

.panel-body p {
  margin: 0 0 1rem;
}

.panel-body .empty {
  color: var(--muted);
  font-weight: 300;
}

.panel-body ul,
.panel-body ol {
  margin: 0 0 1.15rem;
  padding-left: 1.25rem;
}

.panel-body li {
  margin: 0.35rem 0;
  padding-left: 0.25rem;
}

.panel-body li::marker {
  color: #6f7684;
}

.panel-body strong {
  color: var(--text);
  font-weight: 600;
}

.panel-body em {
  font-style: italic;
  color: #d0d4dc;
}

.panel-body a {
  color: #b8c4d6;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-color: rgba(184, 196, 214, 0.45);
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.panel-body a:hover {
  color: var(--text);
  text-decoration-color: rgba(232, 234, 239, 0.7);
}

.panel-body code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #dce1ea;
}

.panel-body blockquote {
  margin: 1.25rem 0;
  padding: 0.9rem 1rem 0.9rem 1.1rem;
  border-left: 2px solid rgba(180, 190, 210, 0.35);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0 10px 10px 0;
  color: #b8bec9;
}

.panel-body blockquote p {
  margin: 0;
}

.panel-body hr {
  margin: 2rem 0;
  border: 0;
  height: 1px;
  background: var(--line);
}

.panel-body .content-figure {
  margin: 1.25rem 0 1.5rem;
}

.panel-body .content-figure img,
.panel-body p img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.panel-body .content-pair {
  margin: 1.25rem 0 1.5rem;
}

.panel-body .content-pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.panel-body .content-pair-grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.panel-body .content-pair figcaption {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 300;
  line-height: 1.5;
  text-align: center;
}

.panel-body .table-wrap {
  margin: 1rem 0 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(24, 27, 34, 0.55);
  scrollbar-width: thin;
}

.panel-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.45;
  min-width: 520px;
}

.panel-body thead th {
  position: sticky;
  top: 0;
  padding: 0.7rem 0.75rem;
  text-align: left;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #e8eaef;
  background: #1c2230;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.panel-body tbody td {
  padding: 0.65rem 0.75rem;
  vertical-align: top;
  color: #c4c8d0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-body tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.panel-body tbody tr:last-child td {
  border-bottom: 0;
}

.panel-body td strong {
  color: var(--text);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes viewOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.99);
  }
}

@keyframes softPulse {
  0% { box-shadow: 0 0 0 0 rgba(200, 208, 220, 0.2); }
  100% { box-shadow: 0 0 0 14px rgba(200, 208, 220, 0); }
}

@keyframes sheen {
  from { background-position: 120% 0; }
  to { background-position: -40% 0; }
}

@media (min-width: 640px) {
  .main {
    padding-top: 3.5rem;
  }

  .sections {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Phone layout ===== */
html.is-phone body {
  overscroll-behavior-y: none;
}

html.is-phone .header {
  padding: calc(0.85rem + var(--safe-top)) calc(1rem + var(--safe-right)) 0.85rem calc(1rem + var(--safe-left));
}

html.is-phone .brand {
  font-size: 1.05rem;
}

html.is-phone .main {
  padding: 1.35rem calc(1rem + var(--safe-right)) calc(2.75rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
}

html.is-phone .home-title {
  font-size: clamp(1.85rem, 9vw, 2.35rem);
  margin-bottom: 0.3rem;
}

html.is-phone .home-sub {
  margin-bottom: 1.35rem;
  font-size: 0.95rem;
}

html.is-phone .sections {
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

html.is-phone .section-btn {
  min-height: 3.25rem;
  padding: 1rem 1.1rem;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(42, 48, 60, 0.9), rgba(28, 32, 40, 0.85));
  border-color: rgba(255, 255, 255, 0.14);
}

html.is-phone .section-btn-featured {
  min-height: 3.6rem;
  font-size: 1.05rem;
}

html.is-phone .section-btn:hover {
  transform: none;
  box-shadow: none;
  filter: none;
}

html.is-phone .section-btn:active,
html.is-phone .section-btn.is-pressed {
  transform: scale(0.985);
  filter: brightness(1.14);
  background: linear-gradient(180deg, rgba(52, 60, 74, 0.95), rgba(34, 40, 52, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

html.is-phone .section-btn.is-pressed {
  animation: none;
}

html.is-phone .panel-bar {
  position: sticky;
  top: calc(3.1rem + var(--safe-top));
  z-index: 5;
  margin: 0 0 1.1rem;
  padding: 0.35rem 0 0.55rem;
  background: linear-gradient(180deg, rgba(11, 12, 14, 0.96) 55%, rgba(11, 12, 14, 0));
}

html.is-phone .back {
  min-height: 2.75rem;
  padding: 0.45rem 0.85rem 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(24, 27, 34, 0.85);
  color: var(--text);
  font-size: 0.92rem;
}

html.is-phone .back:hover {
  transform: none;
}

html.is-phone .back:active {
  transform: scale(0.97);
  background: rgba(40, 45, 56, 0.95);
}

html.is-phone .panel-title {
  margin-bottom: 1.15rem;
  font-size: clamp(1.45rem, 7vw, 1.85rem);
}

html.is-phone .panel-body {
  padding-top: 1.25rem;
  font-size: 1.05rem;
  line-height: 1.65;
}

html.is-phone .panel-body h3 {
  margin-top: 1.75rem;
  font-size: 1.22rem;
}

html.is-phone .panel-body h4 {
  margin-top: 1.4rem;
  font-size: 1.05rem;
}

html.is-phone .panel-body ul,
html.is-phone .panel-body ol {
  padding-left: 1.1rem;
}

html.is-phone .panel-body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 0.85rem 0.9rem;
}

html.is-phone .panel-body .table-wrap {
  margin-left: -0.15rem;
  margin-right: -0.15rem;
  border-radius: 10px;
}

html.is-phone .panel-body .table-wrap::before {
  content: "← листай таблицу →";
  display: block;
  padding: 0.45rem 0.75rem 0.15rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

html.is-phone .panel-body table {
  font-size: 0.78rem;
  min-width: 440px;
}

html.is-phone .panel-body .content-pair-grid {
  gap: 0.45rem;
}

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

  .home-title,
  .home-sub,
  .section-btn,
  .panel,
  .home,
  .panel.is-enter .panel-bar,
  .panel.is-enter .panel-title,
  .panel.is-enter .panel-body {
    opacity: 1;
    transform: none;
  }
}
