/* UX finishing layer — intentionally loaded last. */
:root { --reading-progress: 0%; }

/* Compact, calmer global navigation. */
.header-inner { gap: 20px; }
.main-nav { margin-left: auto; }
.account-menu { position: relative; }
.account-menu > summary { list-style: none; cursor: pointer; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu[open] > summary { outline: 2px solid color-mix(in srgb, var(--accent) 42%, transparent); outline-offset: 2px; }
.account-popover {
  position: absolute;
  z-index: 140;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  width: 246px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-2) 94%, #080c13);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38), var(--premium-ring);
  backdrop-filter: blur(24px) saturate(140%);
}
.account-popover header { display: grid; gap: 3px; padding: 9px 11px 12px; border-bottom: 1px solid var(--line); }
.account-popover header b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-popover header small { color: var(--muted); }
.account-popover a {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 11px;
  border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 720;
}
.account-popover a:hover { color: var(--text); background: var(--accent-soft); }
.account-popover a span { margin-left: auto; color: var(--accent); }
.account-popover a b { display: grid; place-items: center; min-width: 21px; height: 21px; margin-left: auto; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; }
.account-popover a b + span { margin-left: 0; }
.account-popover .account-popover-logout { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; color: #ec8290; }

/* Home: shorter first screen and a clearly secondary topic rail. */
.solutions-hero { padding-top: 48px; }
.solutions-hero-inner { min-height: 356px; gap: clamp(38px, 6vw, 92px); }
.solutions-copy h1 { max-width: 640px; font-size: clamp(48px, 5.35vw, 72px); line-height: .98; }
.solutions-copy > p { max-width: 590px; margin-top: 19px; font-size: clamp(16px, 1.45vw, 19px); }
.solutions-actions { margin-top: 24px; }
.solutions-actions .button { min-height: 46px; }
.solutions-shortcuts { gap: 9px; }
.solutions-shortcuts > a { min-height: 66px; padding: 9px 12px; box-shadow: 0 10px 25px rgba(0,0,0,.13); }
.topic-dock {
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 4px;
  margin-top: 24px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  box-shadow: 0 14px 38px rgba(0,0,0,.2);
}
.topic-dock > a { grid-template-columns: 36px minmax(0,1fr); min-height: 56px; padding: 7px 9px; }
.topic-dock > a + a { border-left: 0; }
.topic-dock .topic-icon { width: 36px; height: 36px; }
.topic-dock em { display: none; }
.topic-dock b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.topic-dock small { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.home-pro-preview { padding-top: 34px; }
.collections-section { padding-top: 42px; }
.popular-materials { padding-bottom: 58px; }
.popular-materials .editorial-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.popular-materials .story-card-body { padding: 16px; }
.popular-materials .story-card h3 { font-size: 18px; }
.popular-materials .story-card p { -webkit-line-clamp: 2; font-size: 13px; }
.optimizer-home { margin-top: 18px; }

/* Stable cards while lazy images arrive. */
.story-card-media {
  overflow: hidden;
  background: linear-gradient(105deg, #101827 20%, #17253a 40%, #101827 60%);
  background-size: 220% 100%;
}
.story-card-media:not(.is-loaded) { animation: card-shimmer 1.5s linear infinite; }
.story-card-media img { opacity: 0; transition: opacity .32s ease, transform .4s ease; }
.story-card-media.is-loaded img { opacity: 1; }
@keyframes card-shimmer { to { background-position-x: -220%; } }

/* Article catalog. */
.all-articles-head { padding-bottom: 30px; }
.all-articles-head h1 { font-size: clamp(40px, 4.5vw, 58px); }
.article-catalog-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  margin: -4px 0 30px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  box-shadow: var(--shadow-xs), var(--premium-ring);
}
.article-catalog-filters label { display: grid; gap: 7px; min-width: 0; }
.article-catalog-filters label span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.article-catalog-filters select {
  width: 100%; min-height: 44px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px;
}
.article-catalog-filters button, .article-catalog-filters > a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 11px; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
}
.article-catalog-filters button { background: var(--accent); color: #fff; }
.article-catalog-filters > a { border-color: var(--line); color: var(--muted); background: var(--surface-2); }

/* Article: compact first screen, progress, readable navigation. */
.reading-progress { position: fixed; z-index: 99; top: 74px; left: 0; right: 0; height: 2px; pointer-events: none; }
.reading-progress span { display: block; width: var(--reading-progress); height: 100%; background: linear-gradient(90deg, #4c7cff, #9b76ff); box-shadow: 0 0 12px rgba(83,126,255,.6); }
.article-page { padding-top: clamp(34px, 4vw, 54px); }
.article-header { max-width: 900px; padding-bottom: 30px; }
.article-header h1 { max-width: 900px; font-size: clamp(34px, 3.4vw, 46px); line-height: 1.08; text-wrap: balance; }
.article-header > p { margin: 18px 0; font-size: clamp(17px, 1.45vw, 19px); }
.article-meta { display: inline-flex; gap: 0; overflow: hidden; margin-top: 18px; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 84%, transparent); }
.article-meta span { min-width: 126px; padding: 10px 14px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.article-meta span + span { border-left: 1px solid var(--line); }
.article-cover { margin-bottom: clamp(34px, 5vw, 58px); border-radius: 24px; }
.article-toc-toggle { display: none; }
.article-toc a.is-active { color: var(--text); background: var(--accent-soft); }
.back-to-top {
  position: fixed; z-index: 90; right: 24px; bottom: 24px; display: grid; width: 46px; height: 46px; place-items: center;
  border: 1px solid var(--line); border-radius: 14px; opacity: 0; transform: translateY(10px); pointer-events: none;
  background: color-mix(in srgb, var(--surface-2) 94%, transparent); color: var(--text); font: inherit; font-size: 19px;
  box-shadow: var(--shadow-sm); transition: opacity .2s ease, transform .2s ease; cursor: pointer;
}
.back-to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* PRO: useful summary fills the empty top area without extra decoration. */
.pro-home-intro { padding-block: 38px; }
.pro-dashboard-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 20px 0 44px; }
.pro-dashboard-links a { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; padding: 20px; border: 1px solid rgba(219,174,62,.22); border-radius: 17px; background: rgba(54,39,11,.28); box-shadow: var(--premium-ring); }
.pro-dashboard-links span { color: #f5d47a; font-size: 12px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.pro-dashboard-links b { grid-row: 1 / 3; grid-column: 2; align-self: center; color: #ffe299; font-size: 30px; }
.pro-dashboard-links small { color: #a99a75; }
.pro-home .pro-section { scroll-margin-top: 96px; }
.pro-library { scroll-margin-top: 82px; }

/* Optimizer visual: preserve proportions and make the mark readable. */
.optimizer-hero-visual { min-height: 390px; }
.optimizer-hero-visual::before { inset: 9%; opacity: .72; }
.optimizer-hero-visual img { width: min(78%, 340px); max-height: 340px; object-fit: contain; filter: brightness(1.28) contrast(1.08) drop-shadow(0 28px 48px rgba(25,103,255,.3)); }

@media (max-width: 1120px) {
  .popular-materials .editorial-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .article-catalog-filters { grid-template-columns: repeat(3, 1fr); }
  .article-catalog-filters button, .article-catalog-filters > a { grid-row: 2; }
}

@media (max-width: 760px) {
  .account-popover { right: -54px; width: min(250px, calc(100vw - 24px)); }
  .solutions-hero { padding: 30px 0 16px; }
  .solutions-hero-inner { min-height: auto; gap: 24px; }
  .solutions-copy h1 { font-size: clamp(38px, 11.5vw, 52px); line-height: 1; }
  .solutions-kicker { margin-bottom: 15px; }
  .solutions-copy > p { margin-top: 15px; }
  .solutions-actions { margin-top: 20px; }
  .solutions-shortcuts { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
  .solutions-shortcuts > a { display: flex; min-height: 58px; padding: 8px; }
  .solutions-shortcuts > a span { min-width: 0; }
  .solutions-shortcuts b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .solutions-shortcuts small, .solutions-shortcuts em { display: none; }
  .shortcut-icon { width: 38px; height: 38px; flex: 0 0 38px; }
  .topic-dock { grid-template-columns: repeat(7, 158px); margin-top: 18px; padding: 6px; }
  .topic-dock > a { min-height: 52px; }
  .collections-section { padding-top: 30px; }
  .popular-materials .editorial-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 82vw); grid-template-columns: none; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
  .popular-materials .story-card { scroll-snap-align: start; }
  .article-catalog-filters { grid-template-columns: 1fr; padding: 14px; }
  .article-catalog-filters button, .article-catalog-filters > a { grid-row: auto; width: 100%; }
  .reading-progress { top: 66px; }
  .article-page { padding-top: 28px; }
  .article-header { padding-bottom: 24px; }
  .article-header h1 { font-size: clamp(28px, 7.6vw, 36px); line-height: 1.1; }
  .article-header > p { font-size: 16px; line-height: 1.55; }
  .article-meta { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); width: 100%; }
  .article-meta span { min-width: 0; padding: 9px 8px; font-size: 12px; }
  .article-meta small { font-size: 8px; }
  .article-cover { margin-bottom: 28px; }
  .article-aside { width: 100%; }
  .article-toc-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 46px; padding: 0 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 800; }
  .article-toc-toggle span { transition: transform .2s ease; }
  .article-toc-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
  .article-toc { display: none; margin-top: 8px; max-height: min(55vh, 420px); overflow-y: auto; }
  .article-toc.is-open { display: grid; }
  .back-to-top { right: 14px; bottom: 14px; width: 42px; height: 42px; }
  .pro-dashboard-links { grid-template-columns: 1fr; margin-bottom: 32px; }
  .optimizer-hero-visual { min-height: 250px; }
  .optimizer-hero-visual img { width: min(65vw, 250px); max-height: 250px; }
}

@media (max-width: 420px) {
  .article-meta span { font-size: 11px; }
  .article-meta small { letter-spacing: .03em; }
}

@media (prefers-reduced-motion: reduce) {
  .story-card-media:not(.is-loaded) { animation: none; }
}

.customer-library { padding: clamp(52px, 8vw, 96px) 0 110px; min-height: 65vh; }
.customer-library-heading { max-width: 760px; margin: 0 0 34px; }
.customer-library-heading h1 { margin: 10px 0 16px; font-size: clamp(42px, 7vw, 78px); line-height: .95; }
.customer-library-heading p { color: var(--muted); font-size: 17px; line-height: 1.7; }
.customer-product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.customer-product-card, .customer-library-empty { border: 1px solid var(--line); border-radius: 24px; background: var(--surface); padding: 28px; box-shadow: var(--shadow-sm); }
.customer-product-type { color: var(--accent); font-size: 11px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.customer-product-card h2 { margin: 12px 0 7px; font-size: 26px; }
.customer-product-version, .customer-product-card small { color: var(--muted); font-size: 12px; }
.customer-product-card > p { min-height: 70px; color: var(--muted); line-height: 1.65; }
.customer-product-card footer { display: grid; gap: 12px; align-items: start; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.customer-product-card footer .button { justify-self: start; }
.customer-library-empty { grid-column: 1 / -1; text-align: center; padding: 60px 24px; }
.customer-library-empty p { color: var(--muted); }
.customer-library-empty > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
@media (max-width: 720px) { .customer-product-grid { grid-template-columns: 1fr; } }
