@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@400;500;600;700&display=swap');

:root {
  --bg-base: #e7eaf0;
  --bg-panel: rgba(249, 251, 255, 0.88);
  --text-main: #2d3443;
  --text-muted: #7b8599;
  --line-soft: #d7dce8;
  --ok: #2cbe80;
  --danger-bg: #ffecee;
  --danger-text: #d95163;
  --danger-border: #f6c8cf;
  --tile-size: clamp(108px, 9.2vw, 176px);
  --tile-radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  font-family: 'Exo 2', 'Trebuchet MS', sans-serif;
  color: var(--text-main);
  background: var(--bg-base);
  overflow: hidden;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 10% -8%, #f8fbff 0%, transparent 70%),
    radial-gradient(700px 360px at 100% 0%, #f2f6ff 0%, transparent 72%),
    linear-gradient(180deg, #f3f6fc 0%, #e8edf6 46%, #e6ebf2 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 32px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-panel);
  backdrop-filter: blur(7px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 23px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #6b4cff 0%, #4f71f0 100%);
  box-shadow: 0 10px 24px rgba(74, 95, 186, 0.26);
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(23px, 1.8vw, 30px);
  letter-spacing: 0.2px;
}

.brand-copy p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: clamp(13px, 1.05vw, 17px);
}

.version-pill {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: clamp(12px, 1vw, 14px);
  font-weight: 600;
  color: #4b68d8;
  background: #edf2ff;
  border: 1px solid #d6e0ff;
}

.content-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 32px 16px;
}

.tabs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.tab-button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(13px, 1vw, 16px);
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab-button strong {
  min-width: 24px;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 12px;
  color: #707995;
  background: #e9edf8;
}

.tab-button:hover {
  color: #5b6680;
  background: #eff3fb;
}

.tab-button.is-active {
  color: #4154a5;
  background: #e8edff;
  border-color: #cfd9ff;
}

.tab-button.is-active strong {
  color: #3446a1;
  background: #d5dfff;
}

.apps-grid {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr));
  gap: 20px 14px;
  align-content: center;
}

.app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: card-enter 0.22s ease;
}

.app-card--placeholder {
  animation: none;
  pointer-events: none;
}

.app-tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 1px solid #d5dae4;
  border-radius: var(--tile-radius);
  background-color: #f1f3f9;
  background-size: cover;
  background-position: center;
  position: relative;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(87, 100, 130, 0.11);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.app-tile--placeholder {
  border-style: dashed;
  border-color: #ccd4e4;
  background: linear-gradient(135deg, rgba(219, 226, 238, 0.5), rgba(238, 243, 251, 0.38));
  box-shadow: none;
  opacity: 0.58;
}

.app-tile:hover,
.app-tile:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(78, 96, 141, 0.2);
  border-color: #a7b7ea;
}

.app-tile:focus-visible {
  outline: 2px solid #8fa7ff;
  outline-offset: 2px;
}

.app-name {
  width: 100%;
  text-align: center;
  font-size: clamp(12px, 0.95vw, 15px);
  line-height: 1.28;
  color: #616b81;
  font-weight: 500;
  min-height: 2.5em;
}

.app-name--placeholder {
  position: relative;
  color: transparent;
}

.app-name--placeholder::before {
  content: '';
  display: block;
  width: 64%;
  height: 8px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: rgba(180, 191, 213, 0.52);
}

.install-mark {
  position: absolute;
  right: 8px;
  top: 8px;
  border-radius: 999px;
  background: rgba(44, 190, 128, 0.95);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  padding: 5px 7px;
  box-shadow: 0 6px 14px rgba(25, 112, 75, 0.32);
}

.app-card.installed .app-tile {
  border-color: #95ddb9;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed #cfd6e6;
  border-radius: 16px;
  background: #f3f6fc;
  color: #7e879d;
  padding: 24px;
  text-align: center;
  font-size: clamp(14px, 1.04vw, 17px);
}

.pagination {
  margin-left: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  padding-left: 0;
  flex-shrink: 0;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  border: 1px solid #cfd7ed;
  border-radius: 10px;
  background: #f6f8fd;
  color: #5a6481;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.page-btn:hover {
  border-color: #b7c7f5;
  color: #4058b6;
}

.page-btn.is-active {
  border-color: #8aa1ef;
  background: #dce5ff;
  color: #2f44a2;
}

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

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
}

.app-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 29, 49, 0.42);
  backdrop-filter: blur(2px);
}

.app-modal__dialog {
  position: relative;
  width: min(680px, 96vw);
  border-radius: 18px;
  border: 1px solid #d3dbef;
  background: linear-gradient(180deg, #f8faff 0%, #eff3fc 100%);
  box-shadow: 0 24px 44px rgba(27, 39, 72, 0.28);
  padding: 22px;
}

.app-modal__head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.app-modal__icon {
  width: 78px;
  height: 78px;
  border-radius: 14px;
  border: 1px solid #d8deea;
  background-color: #eef2fb;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.app-modal__title-wrap {
  min-width: 0;
}

.app-modal__title {
  margin: 0;
  color: #2f3a57;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.18;
}

.app-modal__state {
  margin: 5px 0 0;
  color: #627093;
  font-size: clamp(13px, 1vw, 16px);
  font-weight: 600;
}

.app-modal__state.installed {
  color: #2c9a67;
}

.app-modal__desc {
  margin: 0 0 18px;
  color: #4a5776;
  font-size: clamp(14px, 1.05vw, 18px);
  line-height: 1.45;
}

.app-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  min-width: 128px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #cfd7ed;
  background: #f8faff;
  color: #445173;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.modal-btn:hover,
.modal-btn:focus-visible {
  border-color: #aebff1;
  color: #2f458e;
  outline: none;
}

.modal-btn--primary {
  border-color: #90a6ed;
  background: #dce5ff;
  color: #2e44a1;
}

.modal-btn:disabled {
  cursor: not-allowed;
  border-color: #d6dbe9;
  background: #edf0f7;
  color: #8a93aa;
  box-shadow: none;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px 12px;
  }

  .content-wrap {
    padding: 14px 16px 12px;
  }

  .tabs-row {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .pagination {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .app-name {
    min-height: 2.2em;
  }
}
