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

:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --text:      #111827;
  --muted:     #6b7280;
  --border:    #e5e7eb;
  --shadow:    rgba(0,0,0,.07);
  --shadow-hov:rgba(0,0,0,.13);
  --blue:      #1a73e8;
  --blue-dim:  #dbeafe;
  --orange:    #e37400;
  --orange-dim:#fff3e0;
  --teal:      #0f8f84;
  --teal-dim:  #d3f3ef;
  --badge-bg:  #f0f2f5;
  --logo-main: #227584;
  --logo-accent:#f79520;
}

/* Тъмна тема: по системната настройка, освен ако не е избрана ръчно с бутона */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #0f1117;
    --surface:   #1c1f26;
    --text:      #f1f5f9;
    --muted:     #8b95a5;
    --border:    #2d3140;
    --shadow:    rgba(0,0,0,.3);
    --shadow-hov:rgba(0,0,0,.5);
    --blue:      #4da3ff;
    --blue-dim:  #1a3a5c;
    --orange:    #ff9d2e;
    --orange-dim:#3d2200;
    --teal:      #2fd4c0;
    --teal-dim:  #10393a;
    --badge-bg:  #343949;
    --logo-main: #ffffff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0f1117;
  --surface:   #1c1f26;
  --text:      #f1f5f9;
  --muted:     #8b95a5;
  --border:    #2d3140;
  --shadow:    rgba(0,0,0,.3);
  --shadow-hov:rgba(0,0,0,.5);
  --blue:      #4da3ff;
  --blue-dim:  #1a3a5c;
  --orange:    #ff9d2e;
  --orange-dim:#3d2200;
  --teal:      #2fd4c0;
  --teal-dim:  #10393a;
  --badge-bg:  #343949;
  --logo-main: #ffffff;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 36px 16px;
}

.page-wrapper {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
}

/* ── Бутони за език и тема ── */
.page-tools {
  display: flex;
  gap: 8px;
}
.theme-toggle,
.lang-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, box-shadow .18s;
}
.theme-toggle:hover,
.lang-toggle:hover { color: var(--text); box-shadow: 0 2px 8px var(--shadow-hov); }
.lang-toggle {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-decoration: none;
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* В светла тема бутонът показва луна, в тъмна - слънце */
.theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: none; }
}

/* ── Header ── */
.page-header {
  margin-bottom: 36px;
}
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-logo {
  display: block;
  width: 44px;
  height: 44px;
}

/* ── Section ── */
.section { margin-bottom: 32px; }

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Cards grid ── */
.cards {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

/* ── Card ── */
.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-radius: 10px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--shadow-hov);
  border-color: transparent;
}

/* Липсващ файл: картата не е линк */
.card[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.card[aria-disabled="true"]:hover { transform: none; box-shadow: 0 1px 4px var(--shadow); border-color: var(--border); }

/* ── Икона на устройството ── */
.card-icon {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon svg {
  width: 30px;
  height: 30px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.card.blue   .card-icon { background: var(--blue-dim);   color: var(--blue); }
.card.teal   .card-icon { background: var(--teal-dim);   color: var(--teal); }
.card.orange .card-icon { background: var(--orange-dim); color: var(--orange); }

.card-body { flex: 1; min-width: 0; }

.card-name {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: .85rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 400;
  letter-spacing: .3px;
}
/* Версиите са неутрални, за да не се сливат с цвета на иконата */
.card.blue   .card-badge,
.card.teal   .card-badge,
.card.orange .card-badge { background: var(--badge-bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

.card-badges {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.card-badges .card-badge { text-align: center; }
.card-badge.beta {
  font-size: .66rem;
  letter-spacing: .7px;
}
/* BETA е винаги червено, независимо от картата и темата */
.card.blue .card-badge.beta,
.card.teal .card-badge.beta { background: #EA4335; color: #ffffff; }

.card.small { padding: 8px 12px; }
.card.small .card-name { font-size: .78rem; }
.card.small .card-sub  { font-size: .68rem; }
.card.small .card-badge { font-size: .62rem; padding: 1px 6px; }

.card-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 4px var(--shadow);
}

/* ── Други версии ── */
.more { margin-top: 12px; }
.more > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: color .18s, box-shadow .18s;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover { color: var(--text); box-shadow: 0 2px 8px var(--shadow-hov); }
.more > summary::after {
  content: '';
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.6px 1.6px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .18s;
}
.more[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.more .label-open, .more[open] .label-closed { display: none; }
.more[open] .label-open { display: inline; }
.more > .section-title { margin-top: 20px; }

/* Версиите са една под друга на цяла ширина, а не в колони */
.cards.stacked { grid-template-columns: 1fr; }

/* Група с по 2 карти на ред (на мобилен - по 1) */
.card-group.two-cols { display: grid; grid-template-columns: 1fr 1fr; }

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .card-group.two-cols { grid-template-columns: 1fr; }

  /* На тесен екран бутонът за тема е над заглавието, за да не го застъпва */
  body { padding-top: 16px; }
  .theme-toggle { position: static; margin: 0 0 6px auto; }
}
