:root {
  --ag-bg: #f5f5f5;
  --ag-surface: #ffffff;
  --ag-text: #111111;
  --ag-muted: #6b6b6b;
  --ag-border: #e5e5e5;
  --ag-accent: #111111;
  --ag-accent-soft: #f0f0f0;
  --ag-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --ag-radius: 12px;
  --ag-font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--ag-font);
  color: var(--ag-text);
  background: var(--ag-bg);
  min-height: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input {
  font: inherit;
}

.ag-skip {
  position: absolute;
  left: -9999px;
}

.ag-header {
  background: var(--ag-surface);
  border-bottom: 1px solid var(--ag-border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.ag-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

.ag-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ag-logo img {
  height: 42px;
  width: auto;
}

.ag-logo__title {
  font-size: 0.95rem;
  color: var(--ag-muted);
  font-weight: 500;
}

.ag-lang-chip {
  border: 1px solid var(--ag-border);
  background: var(--ag-surface);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ag-lang-chip:hover {
  border-color: #bbb;
}

.ag-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.ag-hero {
  margin-bottom: 1.25rem;
}

.ag-hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
}

.ag-hero p {
  margin: 0;
  color: var(--ag-muted);
}

.ag-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.ag-families {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ag-chip {
  border: 1px solid var(--ag-border);
  background: var(--ag-surface);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  color: var(--ag-text);
}

.ag-chip.is-active {
  background: var(--ag-accent);
  color: #fff;
  border-color: var(--ag-accent);
}

.ag-search {
  position: relative;
}

.ag-search__icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ag-muted);
  font-size: 0.9rem;
  pointer-events: none;
  --fa-primary-color: var(--ag-text);
  --fa-secondary-color: var(--ag-muted);
  --fa-secondary-opacity: 0.35;
}

.ag-search input {
  width: 100%;
  border: 1px solid var(--ag-border);
  border-radius: 10px;
  padding: 0.85rem 1rem 0.85rem 2.6rem;
  background: var(--ag-surface);
  outline: none;
}

.ag-search input:focus {
  border-color: #999;
}

.ag-count {
  color: var(--ag-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.ag-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ag-card {
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  cursor: default;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.ag-card:hover,
.ag-card:focus-within {
  border-color: #ccc;
  box-shadow: var(--ag-shadow);
}

.ag-card__top {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.65rem;
  align-items: center;
}

.ag-card__thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: transparent;
  border-radius: 6px;
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ag-thumb.is-loaded .ag-card__thumb,
.ag-thumb.is-loaded .ag-product-hero__img {
  opacity: 1;
}

.ag-card__meta {
  min-width: 0;
}

.ag-card__code {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
  line-height: 1.2;
}

.ag-card__name {
  color: var(--ag-muted);
  margin-top: 0.1rem;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-card__family {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--ag-muted);
  background: var(--ag-accent-soft);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.ag-card__detail {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.4rem;
  font-size: 0.72rem;
  color: var(--ag-muted);
  text-decoration: underline;
}

.ag-card__detail:hover {
  color: var(--ag-text);
}

.ag-card__docs {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-top: 1px solid var(--ag-border);
  padding-top: 0.5rem;
}

.ag-card-doc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.ag-card-doc__label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ag-text);
  min-width: 0;
  flex: 1 1 auto;
}

.ag-card-doc__label > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-card-doc__label .fa-duotone {
  flex-shrink: 0;
  font-size: 0.9rem;
  --fa-primary-color: var(--ag-text);
  --fa-secondary-color: var(--ag-muted);
  --fa-secondary-opacity: 0.35;
}

.ag-card-doc__actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.ag-doc-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2.4rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--ag-border);
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #fff;
  color: var(--ag-text);
  line-height: 1.2;
}

.ag-doc-chip .fa-duotone {
  font-size: 0.85rem;
  --fa-primary-color: var(--ag-text);
  --fa-secondary-color: var(--ag-muted);
  --fa-secondary-opacity: 0.4;
}

.ag-doc-chip:hover {
  background: var(--ag-accent-soft);
  border-color: #bbb;
}

.ag-doc-chip--pdf .fa-duotone {
  --fa-primary-color: #b42318;
  --fa-secondary-color: #b42318;
  --fa-secondary-opacity: 0.28;
}

.ag-doc-chip--zip .fa-duotone {
  --fa-primary-color: #175cd3;
  --fa-secondary-color: #175cd3;
  --fa-secondary-opacity: 0.28;
}

.ag-doc-chip--view {
  color: var(--ag-muted);
}

.ag-doc-chip--view .fa-duotone {
  --fa-primary-color: var(--ag-muted);
  --fa-secondary-color: var(--ag-text);
  --fa-secondary-opacity: 0.2;
}

.ag-card-doc--pack {
  margin-top: 0.1rem;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--ag-border);
  justify-content: flex-start;
}

.ag-btn--pack {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
}

.ag-btn--pack .fa-duotone {
  --fa-primary-color: var(--ag-text);
  --fa-secondary-color: var(--ag-muted);
  --fa-secondary-opacity: 0.35;
}

.ag-card__actions {
  display: none;
}

/* Desktop: meta + docs side by side, docs in 2 columns */
@media (min-width: 721px) {
  .ag-card {
    display: grid;
    grid-template-columns: minmax(150px, 210px) 1fr;
    gap: 0.5rem 1.1rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
  }

  .ag-card__top {
    grid-template-columns: 48px 1fr;
    gap: 0.55rem;
  }

  .ag-thumb--sm,
  .ag-card__thumb {
    width: 48px;
    height: 48px;
  }

  .ag-card__docs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1rem;
    row-gap: 0.25rem;
    border-top: none;
    padding-top: 0;
    align-items: center;
  }

  .ag-card-doc--pack {
    grid-column: 1 / -1;
    margin-top: 0.05rem;
    padding-top: 0.3rem;
  }

  .ag-card-doc__label {
    font-size: 0.78rem;
    flex: 1 1 0;
  }
}

.ag-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border-radius: 8px;
  overflow: hidden;
}

.ag-thumb--sm {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.ag-thumb--lg {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--ag-border);
  border-radius: 10px;
}

.ag-thumb__spinner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid #ddd;
  border-top-color: #111;
  border-radius: 50%;
  animation: ag-spin 0.7s linear infinite;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
}

.ag-thumb img {
  pointer-events: none;
}

.ag-card {
  -webkit-tap-highlight-color: transparent;
}

.ag-drawer__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: 220px;
  color: var(--ag-muted);
  font-size: 0.95rem;
}

.ag-drawer__loading .ag-thumb__spinner {
  position: static;
  opacity: 1;
  width: 28px;
  height: 28px;
}

.ag-thumb.is-loading .ag-thumb__spinner {
  opacity: 1;
}

@keyframes ag-spin {
  to {
    transform: rotate(360deg);
  }
}

.ag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.ag-btn--primary {
  background: var(--ag-accent);
  color: #fff;
}

.ag-btn--primary:hover {
  background: #000;
}

.ag-btn--ghost {
  background: var(--ag-surface);
  border-color: var(--ag-border);
  color: var(--ag-text);
}

.ag-btn--ghost:hover {
  background: var(--ag-accent-soft);
}

.ag-btn--block {
  width: 100%;
}

.ag-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ag-muted);
  background: var(--ag-surface);
  border-radius: var(--ag-radius);
  border: 1px dashed var(--ag-border);
}

/* Splash */
.ag-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #fafafa;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.ag-splash.is-open {
  display: flex;
}

.ag-splash__panel {
  width: min(820px, 100%);
  text-align: center;
}

.ag-splash__logo {
  height: 72px;
  width: auto;
  margin: 0 auto 1.25rem;
}

.ag-splash h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
}

.ag-splash__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}

.ag-splash__lang {
  border: 1px solid var(--ag-border);
  background: #fff;
  border-radius: 10px;
  padding: 0.85rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ag-splash__lang:hover,
.ag-splash__lang:focus {
  border-color: #111;
  box-shadow: var(--ag-shadow);
}

.ag-splash__hint {
  margin-top: 1.25rem;
  color: var(--ag-muted);
  font-size: 0.9rem;
}

/* Drawer */
.ag-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.ag-drawer-root.is-open {
  pointer-events: auto;
}

.ag-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ag-drawer-root.is-open .ag-drawer__backdrop {
  opacity: 1;
}

.ag-drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--ag-surface);
  box-shadow: var(--ag-shadow);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.ag-drawer-root.is-open .ag-drawer {
  transform: translateX(0);
}

.ag-drawer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--ag-border);
  position: sticky;
  top: 0;
  background: var(--ag-surface);
  z-index: 1;
}

.ag-drawer__close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.ag-drawer__body {
  padding: 1.1rem;
}

.ag-product-hero {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.ag-product-hero__img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: transparent;
  border-radius: 10px;
  border: none;
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ag-product-hero h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.ag-product-hero__code {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.ag-badge {
  background: #111;
  color: #fff;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.ag-badge--light {
  background: var(--ag-accent-soft);
  color: var(--ag-text);
}

.ag-docs {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ag-doc {
  border: 1px solid var(--ag-border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ag-doc__label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.92rem;
  min-width: 0;
}

.ag-doc__label .fa-duotone {
  flex-shrink: 0;
  --fa-primary-color: var(--ag-text);
  --fa-secondary-color: var(--ag-muted);
  --fa-secondary-opacity: 0.35;
}

.ag-doc__actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.ag-doc__actions a.ag-doc-chip {
  font-size: 0.78rem;
}

.ag-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ag-product-footer {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ag-link {
  color: var(--ag-muted);
  text-decoration: underline;
  font-size: 0.9rem;
  text-align: center;
}

.ag-link:hover {
  color: var(--ag-text);
}

/* Product page */
.ag-product-page .ag-product-hero {
  grid-template-columns: minmax(0, 280px) 1fr;
  align-items: start;
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius);
  padding: 1.25rem;
}

.ag-breadcrumb {
  margin-bottom: 1rem;
  color: var(--ag-muted);
  font-size: 0.9rem;
}

.ag-breadcrumb a:hover {
  text-decoration: underline;
  color: var(--ag-text);
}

.ag-back {
  display: inline-flex;
  margin-bottom: 0.75rem;
  color: var(--ag-muted);
}

.ag-back:hover {
  color: var(--ag-text);
}

.ag-docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.ag-docs-grid .ag-doc {
  flex-direction: column;
  align-items: stretch;
}

/* Document viewer (Visualiser) */
.ag-viewer-root {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}

.ag-viewer-root.is-open {
  pointer-events: auto;
}

.ag-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ag-viewer-root.is-open .ag-viewer__backdrop {
  opacity: 1;
}

.ag-viewer {
  position: absolute;
  top: 3vh;
  left: 50%;
  transform: translate(-50%, 12px);
  width: min(920px, calc(100% - 1.5rem));
  height: min(92vh, 1100px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ag-viewer-root.is-open .ag-viewer {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ag-viewer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--ag-border);
  background: #fff;
  flex-shrink: 0;
}

.ag-viewer__head-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ag-viewer__external {
  font-size: 0.82rem;
  color: var(--ag-muted);
  text-decoration: underline;
  white-space: nowrap;
}

.ag-viewer__external:hover {
  color: var(--ag-text);
}

.ag-viewer__frame-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #e8e8e8;
}

.ag-viewer__frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.ag-viewer__loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ag-muted);
  z-index: 1;
}

.ag-viewer__loading[hidden] {
  display: none !important;
}

.ag-viewer__loading .ag-thumb__spinner {
  position: static;
  opacity: 1;
  width: 28px;
  height: 28px;
}

.ag-doc__actions a[data-view-doc] {
  cursor: pointer;
}

@media (max-width: 720px) {
  .ag-viewer {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 92vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .ag-viewer-root.is-open .ag-viewer {
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .ag-card {
    padding: 0.75rem;
    gap: 0.65rem;
  }

  .ag-card__docs {
    gap: 0.4rem;
  }

  .ag-card-doc {
    flex-wrap: wrap;
  }

  .ag-card-doc__label {
    flex: 1 1 100%;
    white-space: normal;
  }

  .ag-drawer {
    top: auto;
    bottom: 0;
    height: min(88vh, 100%);
    width: 100%;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .ag-drawer-root.is-open .ag-drawer {
    transform: translateY(0);
  }

  .ag-product-page .ag-product-hero {
    grid-template-columns: 1fr;
  }

  .ag-splash__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.is-hidden {
  display: none !important;
}
