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

  :root {
    --bg:        #0c0e12;
    --surface:   #111418;
    --line:      #1e2330;
    --line-mid:  #2a3040;
    --text-dim:  #4a5568;
    --text-mid:  #7a8899;
    --text:      #b8c4d0;
    --text-hi:   #dde6ef;
    --accent:    #2F3B4F;
    --accent-lo: rgba(61,140,255,.12);
    --white:     #eef2f7;
    --danger:    #ff4d4d;
  }

  /* ========== GALLERY SECTION ========== */
  .tg-section {
    padding: 56px 40px;
    font-family: 'IBM Plex Sans', sans-serif;
    color: var(--text);
  }

  /* header */
  .tg-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
  }
  .tg-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .tg-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--accent);
    background: white;
    border: 1px solid rgba(61,140,255,.25);
    padding: 3px 8px;
  }
  .tg-title {
    font-size: 22px;
    font-weight: 300;
    color: var(--text-hi);
    letter-spacing: .04em;
  }
  .tg-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: .06em;
  }

  /* ========== CAROUSEL WRAPPER ========== */
  .tg-carousel-outer {
    position: relative;
  }

  /* стрелки */
  .tg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line-mid);
    background: rgba(8, 10, 15, 0.75);
    backdrop-filter: blur(6px);
    color: var(--text-mid);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .2s, color .2s, background .2s, opacity .2s;
    pointer-events: all;
  }
  .tg-arrow svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .tg-arrow:hover {
    border-color: rgba(202,206,255,.5);
    color: var(--text-hi);
    background: rgba(61,140,255,.08);
  }
  .tg-arrow.disabled {
    opacity: 0.2;
    pointer-events: none;
  }
  .tg-arrow-left  { left: -22px; }
  .tg-arrow-right { right: -22px; }

  /* уголки на стрелках */
  .tg-arrow::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px;
    width: 8px; height: 8px;
    border-top: 1px solid rgba(202,206,255,.35);
    border-left: 1px solid rgba(202,206,255,.35);
  }
  .tg-arrow::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px;
    width: 8px; height: 8px;
    border-bottom: 1px solid rgba(202,206,255,.35);
    border-right: 1px solid rgba(202,206,255,.35);
  }

  /* ========== КАРУСЕЛЬ (прокручиваемая полоса) ========== */
  .tg-grid {
    display: flex;
    flex-direction: row;
    gap: 2px;
    overflow-x: auto;
    scroll-behavior: smooth;
    /* скрыть скроллбар */
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    user-select: none;
  }
  .tg-grid:active { cursor: grabbing; }
  .tg-grid::-webkit-scrollbar { display: none; }

  /* карточки */
  .tg-card {
    position: relative;
    flex: 0 0 auto;
    width: 340px;
    aspect-ratio: 4/3;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface);
  }
  /* первая карточка шире */
  .tg-card:first-child {
    width: 520px;
    aspect-ratio: 16/7;
  }

  .tg-card img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s cubic-bezier(.25,.46,.45,.94), filter .5s ease;
    filter: brightness(.85) saturate(.7);
    pointer-events: none;
  }
  .tg-card:hover img {
    transform: scale(1.04);
    filter: brightness(1) saturate(.9);
  }

  /* corner brackets */
  .tg-card::before,
  .tg-card::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border-color: rgba(255,255,255,.5);
    border-style: solid;
    transition: opacity .3s ease, width .3s ease, height .3s ease;
    opacity: 0;
    z-index: 3;
    pointer-events: none;
  }
  .tg-card::before { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
  .tg-card::after  { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }
  .tg-card:hover::before, .tg-card:hover::after { opacity: 1; width: 20px; height: 20px; }

  .tg-corners::before,
  .tg-corners::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border-color: rgba(61,140,255,.5);
    border-style: solid;
    transition: opacity .3s ease, width .3s ease, height .3s ease;
    opacity: 0;
    z-index: 3;
    pointer-events: none;
  }
  .tg-corners::before { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
  .tg-corners::after  { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }
  .tg-card:hover .tg-corners::before,
  .tg-card:hover .tg-corners::after { opacity: 1; width: 20px; height: 20px; }

  /* index badge */
  .tg-index {
    position: absolute;
    top: 12px; right: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    letter-spacing: .12em;
    color: rgba(255,255,255,.35);
    z-index: 4;
    transition: color .3s ease;
    pointer-events: none;
  }
  .tg-card:hover .tg-index { color: var(--accent); }

  /* bottom info bar */
  .tg-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px 14px 12px;
    background: linear-gradient(transparent, rgba(10,12,18,.85));
    transform: translateY(100%);
    transition: transform .35s ease;
    z-index: 4;
    pointer-events: none;
  }
  .tg-card:hover .tg-info { transform: translateY(0); }
  .tg-info-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--text);
    letter-spacing: .06em;
    display: block;
  }
  .tg-info-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: .08em;
    margin-top: 2px;
  }

  /* scan-line overlay */
  .tg-scan {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
      0deg, transparent, transparent 2px,
      rgba(0,0,0,.04) 2px, rgba(0,0,0,.04) 4px
    );
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
  }
  .tg-card:hover .tg-scan { opacity: 1; }

  /* expand icon */
  .tg-expand {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.7);
    width: 36px; height: 36px;
    border: 1px solid rgba(245,245,245,.5);
    background: rgba(10,12,18,.6);
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity .3s ease, transform .3s ease;
    z-index: 5;
    pointer-events: none;
  }
  .tg-expand svg { width: 14px; height: 14px; }
  .tg-card:hover .tg-expand {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  /* ========== ПРОГРЕСС-БАР ========== */
  .tg-progress {
    margin-top: 16px;
    height: 1px;
    background: var(--line);
    position: relative;
    overflow: hidden;
  }
  .tg-progress-bar {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    background: rgba(61,140,255,.5);
    transition: width .15s ease;
  }

  /* ========== LIGHTBOX ========== */
  .tg-lb {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity .3s ease;
  }
  .tg-lb.active { opacity: 1; pointer-events: all; }
  .tg-lb-backdrop {
    position: absolute; inset: 0;
    background: rgba(8,10,15,.94);
    cursor: pointer;
  }
  .tg-lb-backdrop::before, .tg-lb-backdrop::after {
    content: '';
    position: absolute;
    width: 32px; height: 32px;
    border-color: rgba(61,140,255,.2);
    border-style: solid;
  }
  .tg-lb-backdrop::before { top: 20px; left: 20px; border-width: 1px 0 0 1px; }
  .tg-lb-backdrop::after  { bottom: 20px; right: 20px; border-width: 0 1px 1px 0; }

  .tg-lb-wrap {
    position: relative; z-index: 1;
    max-width: 90vw; max-height: 90vh;
    display: flex; flex-direction: column;
  }
  .tg-lb-img-wrap {
    position: relative;
    border: 1px solid var(--line-mid);
  }
  .tg-lb-img-wrap::before, .tg-lb-img-wrap::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    border-color: var(--accent);
    border-style: solid;
    z-index: 2;
  }
  .tg-lb-img-wrap::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
  .tg-lb-img-wrap::after  { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

  .tg-lb-img {
    display: block;
    max-width: 90vw; max-height: 82vh;
    object-fit: contain;
    transform: scale(.96);
    filter: brightness(.88) saturate(.8);
    transition: transform .35s ease, filter .35s ease;
  }
  .tg-lb.active .tg-lb-img {
    transform: scale(1);
    filter: brightness(1) saturate(1);
  }

  .tg-lb-bar {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 10px 0 0;
  }
  .tg-lb-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--text-mid);
    letter-spacing: .1em;
  }
  .tg-lb-nav { display: flex; gap: 8px; }
  .tg-lb-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--line-mid);
    background: transparent;
    color: var(--text-mid);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .2s, color .2s, background .2s;
    font-size: 14px;
  }
  .tg-lb-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-lo);
  }
  .tg-lb-close {
    position: absolute; top: -42px; right: 0;
    width: 32px; height: 32px;
    border: 1px solid var(--line-mid);
    background: transparent;
    color: var(--text-mid);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .2s, color .2s;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
  }
  .tg-lb-close:hover { border-color: var(--danger); color: var(--danger); }
  .tg-lb-counter {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px; color: var(--text-dim);
    letter-spacing: .1em; min-width: 50px; text-align: center;
  }

  /* ========== RESPONSIVE ========== */
  @media (max-width: 768px) {
    .tg-section { padding: 32px 16px; }
    .tg-card { width: 260px; }
    .tg-card:first-child { width: 320px; }
    .tg-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .tg-arrow-left  { left: -10px; }
    .tg-arrow-right { right: -10px; }
  }
  @media (max-width: 480px) {
    .tg-card { width: calc(100vw - 80px); }
    .tg-card:first-child { width: calc(100vw - 80px); aspect-ratio: 4/3; }
  }