/* Tank catalog and vehicle pages. Self-contained: no shared app styles. */
:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #161a21;
  --surface-2: #1b2029;
  --surface-3: #232a35;
  --line: #262c37;
  --line-strong: #364052;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --dim: #737d8e;
  --accent: #6c8cff;
  --accent-strong: #93abff;
  --accent-soft: rgba(108, 140, 255, .16);
  --better: #7bd8a0;
  --worse: #f0959a;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body.tk {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
.tk h1, .tk h2, .tk h3, .tk p, .tk dl, .tk dd, .tk fieldset { margin: 0; }
.tk a { color: inherit; }
.tk button, .tk input, .tk select { font: inherit; color: inherit; }
.tk :focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.tk-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.tk-skip { position: absolute; inset-inline-start: 8px; top: -48px; z-index: 20; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent); color: #0f1115; font-weight: 600; }
.tk-skip:focus { top: 8px; }
.tk-wrap { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: var(--gutter); }
@media (min-width: 720px) { :root { --gutter: 24px; } }
@media (min-width: 1400px) { :root { --gutter: 40px; } }

/* Site chrome */
.tk-top { border-bottom: 1px solid var(--line); }
.tk-top__inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; min-height: 56px; padding-block: 10px; }
.tk-brand { font-weight: 800; font-size: 17px; letter-spacing: .04em; text-decoration: none; }
.tk-brand span { color: var(--accent); }
.tk-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.tk-auth { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; max-width: 100%; }
.tk-auth a:not(.tk-btn) { color: var(--muted); text-decoration: none; }
.tk-session-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tk-session-name { max-width: min(200px, 40vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-session-message { max-width: 260px; color: var(--muted); font-size: 13px; }
.tk-session-message:empty { display: none; }
@media (max-width: 720px) { .tk-top__inner { justify-content: flex-start; } .tk-nav { order: 3; width: 100%; } .tk-auth { margin-left: auto; } }
.tk-nav a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; }
.tk-nav a:hover { color: var(--text); background: var(--surface); }
.tk-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.tk-main { flex: 1; padding-block: 24px 48px; }
.tk-foot { border-top: 1px solid var(--line); padding-block: 20px; color: var(--dim); font-size: 13px; }

/* Shared atoms */
.tk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.tk-btn:hover { background: var(--surface-3); }
.tk-btn:disabled { opacity: .6; cursor: wait; }
.tk-link { padding: 4px 0; border: 0; background: none; color: var(--accent-strong); cursor: pointer; text-decoration: none; font-size: 14px; }
.tk-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.tk-muted { color: var(--dim); }
.tk-empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.tk-empty h1, .tk-empty h2 { color: var(--text); font-size: 20px; margin-bottom: 8px; }
.tk-empty .tk-btn { margin-top: 16px; }
.tk-error p { color: var(--worse); }
.tk-glyph { width: 12px; height: 12px; flex: none; }
.tk-class-icon { width: 20px; height: 24px; object-fit: contain; }
.tk-class-icon--researchable { filter: grayscale(1); opacity: .8; }
.tk-flag { width: 24px; height: 16px; object-fit: contain; flex: none; }
.tk-flag--filter { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Account */
.tk-account { max-width: 640px; margin: 24px auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tk-account h1 { margin-block: 16px; font-size: 28px; }
.tk-account h2 { margin-block: 20px; font-size: 20px; overflow-wrap: anywhere; }
.tk-account-status, .tk-account-note { color: var(--muted); line-height: 1.6; }
.tk-account-status:empty { display: none; }
.tk-account-status:not(:empty) { margin-bottom: 16px; }
.tk-account-facts { display: grid; gap: 16px; margin-bottom: 24px !important; }
.tk-account-facts div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; }
.tk-account-facts dt { color: var(--muted); }
.tk-account-facts dd { overflow-wrap: anywhere; }
.tk-account-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 20px; }
@media (max-width: 480px) { .tk-account { padding: 16px; margin-block: 8px; } .tk-account-facts div { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.tk-nation { display: inline-flex; align-items: center; gap: 6px; }
.tk-class { display: inline-flex; align-items: center; gap: 6px; }
.tk-tier { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Tank renders: the frame is fixed, the trimmed render is contained in it. */
.tank-image { display: flex; align-items: center; justify-content: center; min-width: 0; }
.tank-image img, .tank-image .sprite-icon { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.tank-card__stage, .tk-hero__stage { position: relative; }
.tank-card__stage::before, .tk-hero__stage::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: linear-gradient(180deg, rgba(15, 17, 21, .08), rgba(15, 17, 21, .5)), var(--tank-flag, none);
  background-size: cover; background-position: center;
}
.tank-image--big { position: absolute; inset: 14% 9%; }
.tank-image--small { width: 64px; height: 28px; flex: none; }
/* Small client icons are black silhouettes that the game tints; tint them light here. */
.tank-image--small img, .tank-image--small .sprite-icon { filter: invert(1); opacity: .78; }
.tank-table__name:hover .tank-image--small img, .tank-table__name:hover .tank-image--small .sprite-icon { opacity: 1; }
.image-fallback { display: block; width: 40%; aspect-ratio: 2 / 1; border-radius: 6px; background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, transparent 6px 12px); opacity: .6; }
.tank-image--small .image-fallback { width: 100%; height: 100%; }

/* Catalog header and controls */
.tk-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.tk-head h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.01em; }
.tk-head__count { color: var(--muted); font-variant-numeric: tabular-nums; }
.tk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tk-search { position: relative; flex: 1 1 100%; }
.tk-search svg { position: absolute; inset-inline-start: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.tk-search input {
  width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline-offset: 0;
}
.tk-search input { padding: 0 12px 0 40px; }
.tk-search input::placeholder { color: var(--dim); }
.tk-search input:focus { border-color: var(--accent); }
.tk-filters-toggle { flex: 0 0 auto; }
@media (max-width: 719px) { .tk-filters-toggle { padding: 0 12px; } }
.tk-filters-toggle { min-height: 44px; }
.tk-badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #0f1115; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.tk-seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.tk-seg button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer;
}
.tk-seg button svg { width: 16px; height: 16px; }
.tk-seg button span { display: none; }
.tk-seg button:hover { color: var(--text); }
.tk-seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.tk-filters { --filter-control-size: 44px; display: none; margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); gap: 16px; flex-direction: column; align-items: stretch; }
.tk-filters.is-open { display: flex; }
.tk-facet { min-width: 0; padding: 0; border: 0; }
.tk-facet legend { padding: 0; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
#nation { display: contents; --filter-chip-width: calc(var(--filter-control-size) * 9 / 7); }
.tk-chip { position: relative; display: flex; flex: 0 0 var(--filter-chip-width, var(--filter-control-size)); width: var(--filter-chip-width, var(--filter-control-size)); height: var(--filter-control-size); }
.tk-chip input { position: absolute; z-index: 1; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tk-chip span {
  display: inline-flex; flex: 1; align-items: center; justify-content: center; gap: 6px;
  position: relative; width: 100%; height: 100%; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 14px; white-space: nowrap; user-select: none;
  transition: background-color .12s, border-color .12s;
}
#nation .tk-chip span { padding: 0; overflow: hidden; }
.tk-chip:hover span { border-color: var(--dim); }
.tk-chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px var(--accent); }
.tk-chip input:checked + span::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--accent); pointer-events: none; }
.tk-chip input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.tk-chips--tiers .tk-chip span { padding: 0 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tk-filter-reset { align-self: flex-start; flex: 0 0 var(--filter-control-size); width: var(--filter-control-size); height: var(--filter-control-size); min-height: var(--filter-control-size); padding: 0; }
.tk-filter-reset:disabled { opacity: .45; cursor: default; }

@media (min-width: 720px) {
  .tk-search { flex: 1 1 320px; max-width: 520px; }
  .tk-filters-toggle { display: none; }
  .tk-filters, .tk-filters.is-open { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; column-gap: 32px; row-gap: 16px; padding: 0; border: 0; background: none; margin-top: 16px; }
  .tk-filter-reset { align-self: flex-end; }
}
@media (min-width: 900px) { .tk-seg button span { display: inline; } .tk-toolbar .tk-seg { margin-inline-start: auto; } }

/* Grid */
.tk-results { margin-top: 24px; }
.tk-results[aria-busy="true"] { opacity: .6; transition: opacity .2s .15s; }
.tank-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .tank-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 840px) { .tank-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1040px) { .tank-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .tank-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tank-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; transition: border-color .15s, background-color .15s;
}
.tank-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.tank-card:focus-visible { outline-offset: 2px; border-color: var(--accent); }
.tank-card__stage {
  display: block; width: 100%; aspect-ratio: 16 / 10;
  background: radial-gradient(70% 55% at 50% 72%, #262d39 0%, transparent 72%);
}
.tank-card:hover .tank-image img { transform: scale(1.03); }
.tank-card .tank-image img { transition: transform .2s; }
.tank-card__body { display: flex; align-items: center; gap: 9px; flex: 0 0 42px; height: 42px; padding: 0 12px; border-top: 1px solid var(--line); }
.tank-card__name { display: block; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; font-weight: 600; line-height: 20px; }
.tank-card__meta { display: inline-flex; flex: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.tank-card__meta .tk-class-icon { width: 13px; height: 20px; }

/* Table */
.tank-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tank-table th { position: sticky; top: 0; padding: 10px 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; text-align: start; white-space: nowrap; }
.tank-table__sort { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.tank-table__sort:hover, .tank-table th[aria-sort="ascending"], .tank-table th[aria-sort="descending"] { color: var(--text); }
.tank-table__sort span { font-size: 16px; }
.tank-table td { padding: 6px 12px; border-top: 1px solid var(--line); white-space: nowrap; color: var(--muted); }
.tank-table td:first-child { width: 100%; color: var(--text); }
.tank-table tbody tr:hover { background: var(--surface-2); }
.tank-table__name { display: flex; align-items: center; gap: 12px; min-height: 40px; font-weight: 600; text-decoration: none; }
.tank-table__name:hover span { color: var(--accent-strong); }
.tank-table__tier { color: var(--text) !important; font-weight: 600; font-variant-numeric: tabular-nums; }
.tank-table__short { display: none; }
@media (max-width: 559px) {
  .tank-table th:nth-child(4), .tank-table td:nth-child(4) { display: none; }
  .tank-table td, .tank-table th { padding-inline: 8px; }
  .tank-table td:first-child { white-space: normal; }
  .tank-table__name { gap: 8px; }
  .tank-table .tank-image--small { width: 48px; height: 22px; }
  .tank-table__long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tank-table__short { display: inline; }
}

/* Vehicle page */
.tk-crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; color: var(--dim); font-size: 14px; }
.tk-crumbs a { color: var(--muted); text-decoration: none; }
.tk-crumbs a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.tk-crumbs [aria-current] { color: var(--text); }
/* Vehicle page: image and headline share a row above the configurator and TTX. */
.tk-hero { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) {
  .tk-hero {
    grid-template-columns: minmax(0, 405px) minmax(0, 1fr);
    grid-template-areas: "stage intro" "config specs";
    gap: 14px 32px;
  }
  .tk-hero :is(.tk-hero__aside, .tk-hero__main) { display: contents; }
  .tk-hero .tk-hero__stage { grid-area: stage; align-self: end; }
  .tk-hero .tk-hero__intro { display: flex; flex-direction: column; gap: 14px; grid-area: intro; align-self: end; min-width: 0; }
  .tk-hero .tk-loadout { grid-area: config; position: sticky; top: 16px; align-self: start; }
  .tk-hero .tk-specs { grid-area: specs; }
  .tk-hero .tk-about { grid-column: 2; }
  .tk-hero--empty { grid-template-areas: "stage intro"; }
}
.tk-hero__aside { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tk-hero__main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tk-hero__intro { display: contents; }
.tk-hero--empty .tk-empty { order: 3; padding: 16px 0; }
.tk-hero__stage {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: radial-gradient(60% 50% at 50% 70%, #283040 0%, rgba(22, 26, 33, .6) 60%, transparent 80%), var(--surface);
}
.tk-hero__stage .tank-image--big { inset: 12% 8%; }
/* Source renders are at most 256×128, so the stage stays small enough to keep them crisp. */
.tk-hero__stage { max-width: 520px; }
.tk-hero__head { display: flex; flex-direction: column; gap: 6px; }
.tk-hero__kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font-size: 14px; }
.tk-hero h1 { display: flex; align-items: baseline; gap: 12px; font-size: clamp(26px, 5vw, 36px); line-height: 1.1; letter-spacing: -.015em; overflow-wrap: anywhere; }
.tk-hero__tier { color: var(--dim); font-weight: 600; font-size: .7em; font-variant-numeric: tabular-nums; }
.tk-about { color: var(--muted); font-size: 13px; }
.tk-about summary { width: max-content; color: var(--dim); cursor: pointer; }
.tk-about summary:hover { color: var(--text); }
.tk-about p { margin-top: 6px; max-width: 62ch; }

@media (max-width: 899px) {
  .tk-hero { display: flex; flex-direction: column; gap: 14px; }
  .tk-hero__aside, .tk-hero__main { display: contents; }
  .tk-hero__head { order: 1; }
  .tk-hero__stage { order: 2; }
  .tk-config__state { order: 4; }
  .tk-specs { order: 5; }
  .tk-loadout { order: 7; }
}

/* Configuration & Loadout */
.tk-config__state { color: var(--muted); font-size: 13px; }
.tk-config__state:not(:has(> :not([hidden]))) { display: none; }
.tk-config__status.is-error { color: var(--worse); }

.tk-loadout { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.tk-loadout__summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface-2); }
.tk-reset { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; min-width: 32px; min-height: 32px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: none; color: var(--text); cursor: pointer; flex-shrink: 0; transition: all .12s ease; }
.tk-reset:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tk-reset:disabled { color: var(--dim); border-color: var(--line); cursor: default; opacity: .45; }

/* A local indicator leaves every control available for the next selection. */
.is-recalculating { position: relative; }
.is-recalculating::before {
  content: ""; position: absolute; z-index: 2; top: 50%; left: 50%;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent-strong); border-radius: 50%;
  background: var(--surface); box-shadow: 0 0 0 3px var(--surface);
  pointer-events: none; animation: tk-recalculate .65s linear infinite;
}
.is-recalculating > :is(.item-icon-frame, svg, .tk-option__name, .tk-option__sub) { opacity: .3; }
@keyframes tk-recalculate { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .is-recalculating::before { animation: none; }
}

/* Loadout tabs & panes */
.tk-loadout__tabs { display: inline-flex; align-items: center; gap: 4px; padding: 3px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tk-loadout__tab {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; min-width: 34px; min-height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--muted); cursor: pointer; transition: background-color .12s, color .12s, border-color .12s;
}
.tk-loadout__tab:hover:not(.is-active) { color: var(--text); background: rgba(255, 255, 255, .08); }
.tk-loadout__tab.is-active, .tk-loadout__tab[aria-selected="true"] { color: var(--accent); background: var(--surface-3); border-color: var(--line-strong); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.tk-loadout__tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

.tk-hero .tk-loadout__tabs { display: flex; }
.tk-hero .tk-loadout__pane { display: none; }
.tk-hero .tk-loadout__pane.is-active { display: block; }
.tk-loadout__body { display: flex; flex-direction: column; gap: 14px; padding: 14px; }

.tk-group__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 10px; font-size: 15px; font-weight: 600; }
.tk-group__hint, .tk-group__count, .tk-group__value { color: var(--muted); font-size: 13px; font-weight: 400; font-variant-numeric: tabular-nums; }
.tk-group__count b { color: var(--text); font-weight: 600; }
.tk-group__value { color: var(--text); }

.tk-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.tk-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 44px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2);
  text-align: start; cursor: pointer; transition: border-color .12s, background-color .12s;
}
.tk-option:hover { border-color: var(--dim); }
.tk-option__name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.tk-option__sub { color: var(--muted); font-size: 12px; }
.tk-option[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

/* Icon buttons: shells, equipment, provisions */
.tk-icons { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 48px; height: 48px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface-2); cursor: pointer; transition: border-color .12s, background-color .12s, opacity .12s;
}
.tk-icon:hover { border-color: var(--dim); background: var(--surface-3); }
.tk-icon[aria-pressed="true"], .tk-icon[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tk-icon[aria-pressed="true"]::after, .tk-icon[aria-checked="true"]::after {
  content: ""; position: absolute; top: -5px; inset-inline-end: -5px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 8.2 2.3 2.3 4.7-5' fill='none' stroke='%230f1115' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
  box-shadow: 0 0 0 2px var(--surface);
}
.tk-icon[aria-disabled="true"] { opacity: .38; cursor: not-allowed; }
.tk-icon[aria-disabled="true"]:hover { border-color: var(--line-strong); background: var(--surface-2); }
.tk-icon--none { cursor: default; border-style: dashed; background: none; }
.tk-icon--none:hover { border-color: var(--line-strong); background: none; }
.item-icon-frame { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.item-icon { display: block; width: 100%; height: 100%; object-fit: contain; }
.item-icon-fallback { color: var(--muted); font-size: 13px; font-weight: 700; }

.tk-equipment { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, max-content)); gap: 8px 20px; }
.tk-equipment__col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tk-equipment__label { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.tk-slot { display: flex; gap: 6px; padding: 5px; border-radius: 12px; background: var(--bg); }
@media (max-width: 479px) {
  .tk-equipment { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 8px; }
  .tk-slot { justify-content: center; gap: 4px; padding: 4px; }
  .tk-slot .tk-icon { width: 42px; height: 42px; padding: 3px; border-radius: 8px; }
  .tk-equipment__label { font-size: 12px; }
}

.tk-provisions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.tk-provisions__slots { display: flex; gap: 6px; padding: 5px; border-radius: 12px; background: var(--bg); }
.tk-pslot { width: 48px; height: 48px; padding: 3px; border: 1px dashed var(--line-strong); border-radius: 10px; background: none; }
.tk-pslot.is-filled { border: 1px solid var(--accent); background: var(--accent-soft); cursor: pointer; }
.tk-pslot.is-filled:hover { background: rgba(108, 140, 255, .26); }

/* Tooltip */
.tk-tip {
  position: fixed; z-index: 30; display: flex; flex-direction: column; gap: 4px; max-width: min(320px, calc(100vw - 16px));
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #0b0d11;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: 13px; line-height: 1.4; pointer-events: none; white-space: pre-line;
}
.tk-tip strong { font-size: 14px; }
.tk-tip span { color: var(--muted); }
.tk-tip em { color: var(--worse); font-style: normal; }

/* TTX tab */
.tk-specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.tk-spec { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tk-spec__title { padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.tk-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px 16px; }
.tk-stat { min-width: 0; }
.tk-stat dt { color: var(--muted); font-size: 13px; }
.tk-stat dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font-variant-numeric: tabular-nums; }
.tk-stat b { font-size: 18px; font-weight: 600; }
.tk-stat__unit { color: var(--dim); font-size: 13px; }
.tk-stat__note { flex-basis: 100%; color: var(--dim); font-size: 12px; }
.tk-delta { font-size: 13px; font-weight: 600; }
.tk-delta.is-better { color: var(--better); }
.tk-delta.is-worse { color: var(--worse); }
.tk-armor__title { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.tk-armor__plates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tk-armor__plates span { display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.tk-armor__plates small { color: var(--dim); font-size: 12px; }
.tk-armor__plates b { font-size: 17px; font-variant-numeric: tabular-nums; }


@media (prefers-reduced-motion: reduce) { .tk * { transition: none !important; } }

/* Crew and camouflage: sliders with a visible value and scale. */
.tk-crew { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tk-crew__item { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.tk-crew__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tk-crew__label { font-size: 14px; font-weight: 600; }
.tk-crew__value { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-crew__value b { color: var(--text); font-size: 16px; font-weight: 600; }
.tk-crew__hint { color: var(--dim); font-size: 12px; line-height: 1.35; }
.tk-range { width: 100%; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.tk-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tk-range__scale { display: flex; justify-content: space-between; padding-inline: 4px; color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.tk-segmented { display: flex; padding: 3px; border-radius: var(--radius-sm); background: var(--bg); }
.tk-segmented label { flex: 1 1 0; min-width: 0; }
.tk-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.tk-segmented span { display: block; padding: 6px 8px; border-radius: 6px; color: var(--muted); font-size: 13px; text-align: center; white-space: nowrap; cursor: pointer; }
.tk-segmented span:hover { color: var(--text); }
.tk-segmented input:checked + span { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.tk-segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Narrow tabbed loadout columns. */
.tk-hero .tk-loadout__body { gap: 0; padding: 0 16px; }
.tk-hero .tk-group { min-width: 0; padding-block: 16px; }
.tk-hero .tk-group + .tk-group { border-top: 1px solid var(--line); }
.tk-hero .tk-group__title { align-items: center; gap: 6px 10px; margin-bottom: 12px; font-size: 14px; line-height: 1.4; }
.tk-hero .tk-group__count { margin-inline-start: auto; padding: 1px 8px; border: 1px solid var(--line); border-radius: 20px; font-size: 12px; white-space: nowrap; }
.tk-hero .tk-group__value { flex-basis: 100%; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.tk-hero .tk-icon { width: 44px; height: 44px; padding: 4px; border-radius: 8px; }
.tk-hero .tk-icons { gap: 10px; }
.tk-hero .tk-provisions { flex-direction: column; align-items: flex-start; gap: 12px; }
.tk-hero .tk-slot { display: inline-flex; width: max-content; gap: 4px; padding: 4px; border-radius: 10px; }
.tk-hero .tk-group__help { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.tk-hero .tk-equipment { display: grid; grid-template-columns: repeat(var(--cols, 3), max-content); justify-content: space-between; gap: 10px; }
.tk-hero .tk-equipment__col { display: flex; flex-direction: column; gap: 8px; width: max-content; }
.tk-hero .tk-equipment__label { font-size: 12px; line-height: 1.3; min-height: auto; white-space: nowrap; color: var(--muted); }
.tk-hero .tk-slot .tk-icon { width: 44px; height: 44px; flex: none; padding: 4px; border-radius: 8px; }
.tk-hero .tk-options { grid-template-columns: minmax(0, 1fr); gap: 6px; }
.tk-hero .tk-option { align-items: center; min-height: 44px; padding: 9px 12px; }
.tk-hero .tk-option__name { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.tk-hero .tk-option__sub { font-size: 12px; }
.tk-hero :is(.tk-icon, .tk-option, .tk-reset):active:not(:disabled):not([aria-disabled="true"]) { background: var(--accent-soft); }
.tk-hero .tk-crew { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tk-hero .tk-crew__item { gap: 8px; padding: 10px 12px; }
.tk-hero :is(.tk-crew__item:first-child, [data-camouflage-state]) { grid-column: 1 / -1; }
.tk-hero .tk-crew__head { flex-wrap: wrap; gap: 4px 8px; }
.tk-hero .tk-crew__value { margin-inline-start: auto; }
.tk-hero .tk-crew__item:has([data-crew-skill]) .tk-crew__head { flex-direction: column; align-items: flex-start; }
.tk-hero .tk-crew__item:has([data-crew-skill]) .tk-crew__value { margin-inline-start: 0; }
.tk-hero .tk-range { min-height: 28px; margin: 0; }
.tk-hero .tk-range__scale { display: flex; color: var(--muted); }
.tk-hero .tk-crew__hint { display: block; color: var(--muted); }
.tk-hero .tk-segmented span { display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px; font-size: 12px; white-space: normal; }

/* Side tabs (vertical icon rail on the left of loadout) */
.tk-hero .tk-loadout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}
.tk-hero .tk-loadout__body { flex: 1; min-width: 0; }
.tk-hero .tk-loadout__summary {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 48px;
  min-width: 48px;
  padding: 10px 6px;
  border-inline-end: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface-2);
}
.tk-hero .tk-loadout__tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  align-items: center;
  padding: 0;
  background: none;
  border: 0;
}
.tk-hero .tk-loadout__tab {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
}
.tk-hero .tk-reset {
  margin-top: auto;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
}
@media (max-width: 899px) {
  .tk-hero { align-items: stretch; }
}
@media (max-width: 479px) {
  .tk-hero .tk-loadout__body { padding: 0 8px; }
  .tk-hero .tk-loadout__summary { width: 42px; min-width: 42px; padding: 8px 4px; }
  .tk-hero .tk-loadout__tab { width: 34px; height: 34px; min-width: 34px; min-height: 34px; }
  .tk-hero .tk-equipment { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 12px 8px; }
  .tk-hero .tk-equipment__col { width: auto; min-width: 0; }
  .tk-hero .tk-equipment__label { min-height: 2.6em; white-space: normal; }
}
@media (max-width: 359px) {
  .tk-hero .tk-loadout__body { padding-inline: 12px; }
  .tk-hero .tk-crew { grid-template-columns: minmax(0, 1fr); }
}

.sprite-icon { overflow: hidden; }
