:root {
  --bg: #0b0f14;
  --panel: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --text: #e9eef5;
  --muted: #9fb0c5;
  --primary: #7c5cff;
  --accent: #00e0b8;
  --danger: #ff5c8a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% 0%, rgba(124, 92, 255, .25), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(0, 224, 184, .2), transparent 60%),
    var(--bg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(15, 18, 24, .9), rgba(15, 18, 24, .6));
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 26px; }
.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2px;
}
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 12px;
}
.search input {
  all: unset; color: var(--text); min-width: 240px;
}
.search-emoji { opacity: .9; }

.btn {
  appearance: none; border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px; border-radius: 12px;
  font-weight: 600; letter-spacing: .2px;
  background: var(--panel);
  transition: transform .08s ease, background .2s ease, border-color .2s ease;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.2); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(180deg, rgba(124,92,255,.9), rgba(124,92,255,.7)); }
.btn.accent { background: linear-gradient(180deg, rgba(0,224,184,.9), rgba(0,224,184,.7)); color: #0b0f14; }
.btn.ghost { background: transparent; }
.icon-btn { all: unset; cursor: pointer; font-size: 18px; }

.app-main { max-width: 1100px; margin: 0 auto; padding: 18px; }
.hero {
  position: relative;
  min-height: 340px;
  display: grid; grid-template-columns: 1fr; gap: 0;
  align-items: stretch;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-text { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.hero-text h2 { margin: 0; font-size: 26px; }
.hero-text p { margin: 0; color: var(--muted); }
.hero-cta { margin-top: 8px; }
.hero-text { position: relative; z-index: 1; margin-left: auto; max-width: 48%; }
.hero-art { position: absolute; inset: 0; z-index: 0; background-repeat: no-repeat; background-position: left center; }
.banner-tv { background-image: url("tv.jpg"); background-size: contain; filter: saturate(1.05) contrast(1.05); }

.apps-toolbar {
  margin: 18px 2px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.counter { color: var(--muted); }
.sort { display: flex; align-items: center; gap: 8px; }
.sort select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 10px;
}

.tv-hero {
  position: relative;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(600px 160px at 70% 90%, rgba(124,92,255,.25), transparent 60%),
    radial-gradient(500px 160px at 30% 90%, rgba(0,224,184,.18), transparent 60%);
}
.tv {
  position: relative;
  width: 92%;
  aspect-ratio: 16/9;
  background: #0d0f14;
  border: 8px solid #1b1f29;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,.45), inset 0 0 0 2px rgba(255,255,255,.04);
  overflow: hidden;
}
.tv-screen {
  position: absolute;
  inset: 10px 12px 16px 12px;
  border-radius: 12px;
  background: #000;
  overflow: hidden;
}
.poster-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 1fr;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 6px;
}
.poster {
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 -20px 40px rgba(0,0,0,.35);
}
.tv-stand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -10px;
  width: 32%;
  height: 18px;
  background: linear-gradient(180deg, #1c222d, #0b0f14);
  border-radius: 0 0 14px 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,.5);
}
.tv-box {
  position: absolute;
  right: 22px;
  bottom: 14px;
  width: 92px;
  height: 56px;
  background: linear-gradient(180deg, #161c24, #0e141b);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.03);
  display: grid;
  place-items: center;
}
.tv-box-led {
  width: 8px; height: 8px; border-radius: 50%;
  background: #00e0b8; box-shadow: 0 0 10px #00e0b8;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.app-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow);
}
.app-media {
  position: relative; aspect-ratio: 16/9; background: rgba(255,255,255,.04);
  display: grid; place-items: center;
}
.app-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s ease; }
.app-media.loaded img { opacity: 1; }
.app-emoji { font-size: 44px; opacity: .9; }
.app-body { padding: 12px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.app-name { margin: 0; font-size: 16px; }
.app-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.chip { background: rgba(255,255,255,.06); border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.app-actions { padding: 0 12px 12px; }
.app-download { display: inline-flex; width: 100%; justify-content: center; }

.app-footer { margin-top: 24px; padding: 18px; color: var(--muted); text-align: center; }
.app-footer .footer-inner {
  border-top: 1px solid var(--border); padding-top: 14px;
}

.modal {
  border: none; padding: 0; background: transparent;
}
.modal::backdrop { background: rgba(0,0,0,.6); }
.modal-content {
  width: min(720px, 92vw); background: #0f141b; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.form-grid {
  padding: 14px 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.form-grid label { display: grid; gap: 8px; font-size: 14px; }
.form-grid input {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 10px 12px;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border);
}

@media (max-width: 840px) {
  .hero { grid-template-columns: 1fr; min-height: 240px; }
  .hero-art { min-height: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .search input { min-width: 160px; }
}

.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table thead { background: rgba(255,255,255,.06); }
.muted { color: var(--muted); }
