/* ==================== Buttons ==================== */

.btn {
  --btn-bg: var(--bg-surface-2);
  --btn-fg: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out), opacity var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 12px;
}

.btn-install {
  background: linear-gradient(135deg, var(--red-core), var(--red-bright));
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: var(--glow-red);
}
.btn-install:hover {
  filter: brightness(1.08);
}

.btn-update {
  background: linear-gradient(135deg, var(--violet-deep), var(--violet-core));
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: var(--glow-violet);
}
.btn-update:hover {
  filter: brightness(1.1);
}

.btn-open {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-open:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-unavailable {
  background: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-danger {
  background: rgba(179, 28, 43, 0.15);
  border-color: rgba(255, 45, 61, 0.4);
  color: var(--red-glow);
}
.btn-danger:hover {
  background: rgba(179, 28, 43, 0.28);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.icon-btn:hover {
  background: var(--bg-surface-2);
}
.icon-btn:active {
  transform: scale(0.92);
}

/* ==================== App Card ==================== */

.app-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface-2) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  gap: var(--space-3);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.app-card::before {
  content: '';
  position: absolute;
  inset: -40% -40% auto auto;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(255, 45, 61, 0.18), transparent 70%);
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
  pointer-events: none;
}

.app-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md);
}
.app-card:hover::before {
  opacity: 1;
}

.app-card__icon-wrap {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.app-card__icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-card__icon-fallback {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-muted);
}

.app-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app-card__name {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card__meta {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card__footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.app-card__version {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.app-card .btn {
  padding: 7px 14px;
  font-size: 11.5px;
}

/* ==================== Badges ==================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-featured {
  color: var(--red-glow);
  border-color: rgba(255, 45, 61, 0.35);
  background: rgba(255, 45, 61, 0.1);
}

.badge-violet {
  color: var(--violet-bright);
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.12);
}

/* ==================== Featured Hero ==================== */

.hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background:
    radial-gradient(120% 140% at 15% 0%, rgba(179, 28, 43, 0.35), transparent 55%),
    radial-gradient(100% 120% at 100% 100%, rgba(124, 58, 237, 0.25), transparent 60%),
    var(--bg-surface);
  padding: var(--space-6) var(--space-5);
  display: grid;
  gap: var(--space-5);
  cursor: pointer;
}

@media (min-width: 720px) {
  .hero {
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: var(--space-7);
  }
}

.hero__icon {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-3);
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}
.hero__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero__title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.hero__desc {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 46ch;
}

/* ==================== App Detail ==================== */

.detail-header {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding-block: var(--space-6);
}

.detail-icon {
  width: 108px;
  height: 108px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-3);
  box-shadow: var(--shadow-md);
}
.detail-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-title {
  font-size: 24px;
  font-weight: 800;
}

.detail-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

.detail-actions {
  margin-top: var(--space-3);
  display: flex;
  gap: var(--space-2);
}

.detail-actions .btn {
  min-width: 140px;
}

.detail-section {
  padding-block: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.detail-section__title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: var(--space-3);
}

.detail-description {
  color: var(--text-secondary);
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.screenshot-strip {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-2);
  -webkit-overflow-scrolling: touch;
}
.screenshot-strip img {
  scroll-snap-align: start;
  height: 340px;
  width: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.info-table {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-5);
  font-size: 13px;
}
.info-table dt {
  color: var(--text-muted);
}
.info-table dd {
  margin: 0;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.version-row__num {
  font-weight: 700;
  font-family: var(--font-mono);
}

.version-row__notes {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* ==================== Forms ==================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.field .hint {
  font-size: 11.5px;
  color: var(--text-muted);
}

.input,
textarea.input,
select.input {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  width: 100%;
}
.input:focus,
textarea.input:focus,
select.input:focus {
  border-color: var(--border-glow);
  box-shadow: var(--glow-red);
}

textarea.input {
  resize: vertical;
  min-height: 90px;
  font-family: inherit;
}

.form-grid {
  display: grid;
  gap: var(--space-4);
}
@media (min-width: 640px) {
  .form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.file-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.file-drop:hover,
.file-drop.is-dragover {
  border-color: var(--red-glow);
  background: rgba(255, 45, 61, 0.05);
}
.file-drop input {
  display: none;
}

/* ==================== Tables ==================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.table-wrap .table {
  min-width: 640px;
}

.table-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--bg-surface-3);
}

/* ==================== Cards / Panels ==================== */

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.panel-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: var(--space-4);
}

/* ==================== Empty / Error States ==================== */

.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}
.empty-state h3 {
  color: var(--text-primary);
  font-size: 16px;
  margin-bottom: var(--space-2);
}

/* ==================== Toasts ==================== */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 380px);
}

.toast {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
}
.toast.is-error {
  border-color: rgba(255, 45, 61, 0.5);
}
.toast.is-success {
  border-color: rgba(124, 58, 237, 0.5);
}

/* ==================== Login ==================== */

.auth-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.auth-card__title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: var(--space-1);
}
.auth-card__sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: var(--space-5);
}

.form-error {
  color: var(--red-glow);
  font-size: 13px;
  min-height: 18px;
}

/* ==================== Modal ==================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 6, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
  padding: var(--space-4);
}
@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
}

.modal__title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: var(--space-4);
}
