/* ============================================================
   SpaceAPK — New Theme (Clean Light, Green Accent)
   ============================================================ */

/* --- Variables --- */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-light: #dcfce7;
  --radius-card: 12px;
  --radius-btn: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-hover: 0 8px 25px rgba(0,0,0,.10);
  --header-h: 64px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- Reset / Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
ul, ol { list-style: none; padding: 0; margin: 0; }

/* ============================================================
   HEADER
   ============================================================ */
.tn-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  height: var(--header-h);
}
.tn-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}
.tn-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  flex-shrink: 0;
}
.tn-logo img { height: 32px; width: auto; }

/* Search */
.tn-search {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.tn-search form { display: flex; }
.tn-search input {
  width: 100%;
  height: 40px;
  border: 1.5px solid var(--border);
  border-radius: 20px 0 0 20px;
  padding: 0 16px;
  font-size: .9rem;
  font-family: var(--font);
  outline: none;
  background: var(--bg);
  transition: border-color .2s;
}
.tn-search input:focus { border-color: var(--accent); background: #fff; }
.tn-search button {
  height: 40px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0 20px 20px 0;
  cursor: pointer;
  font-size: .85rem;
  font-family: var(--font);
  font-weight: 600;
  transition: background .2s;
}
.tn-search button:hover { background: var(--accent-hover); }

/* Nav */
.tn-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tn-nav a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .2s, background .2s;
}
.tn-nav a:hover { color: var(--accent); background: var(--accent-light); }
.tn-nav a.active { color: var(--accent); background: var(--accent-light); }

/* Burger */
.tn-burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
}
.tn-burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .25s;
}

/* Mobile Drawer */
.tn-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}
.tn-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .25s;
}
.tn-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--surface);
  transform: translateX(100%);
  transition: transform .25s ease;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.tn-drawer.open { pointer-events: auto; }
.tn-drawer.open .tn-drawer-overlay { opacity: 1; }
.tn-drawer.open .tn-drawer-panel { transform: translateX(0); }
.tn-drawer-close {
  align-self: flex-end;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.tn-drawer-panel a {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  transition: background .2s;
}
.tn-drawer-panel a:hover { background: var(--bg); color: var(--accent); }

/* Search hint dropdown */
.search_hint {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  z-index: 50;
  overflow: hidden;
  display: none;
}
.search_hint:not(:empty) { display: block; }

/* ============================================================
   LAYOUT WRAPPER
   ============================================================ */
.tn-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.tn-breadcrumbs {
  padding: 12px 0;
}
.tn-breadcrumbs .over {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: .825rem;
  color: var(--muted);
}
.tn-breadcrumbs .over span::after {
  content: '/';
  margin: 0 6px;
  opacity: .4;
}
.tn-breadcrumbs .over span:last-child::after { display: none; }
.tn-breadcrumbs a { color: var(--muted); transition: color .15s; }
.tn-breadcrumbs a:hover { color: var(--accent); }

/* ============================================================
   CATEGORY FILTER CHIPS
   ============================================================ */
.tn-cats {
  padding: 16px 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tn-cats::-webkit-scrollbar { display: none; }
.tn-cats-inner {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}
.tn-cat-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.tn-cat-chip:hover,
.tn-cat-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   APP GRID — MAIN / CATEGORY PAGES
   ============================================================ */
.tn-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 20px 0 16px;
  color: var(--text);
}
.tn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding-bottom: 32px;
}
@media (min-width: 640px)  { .tn-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); } }
@media (min-width: 1024px) { .tn-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }

/* App Card */
.tn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  box-shadow: var(--shadow-card);
}
.tn-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.tn-card a { display: flex; flex-direction: column; height: 100%; }
.tn-card-img {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg);
}
.tn-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.tn-card:hover .tn-card-img img { transform: scale(1.04); }
.tn-card-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tn-card-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tn-card-cat {
  font-size: .75rem;
  color: var(--muted);
}
.tn-card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: var(--muted);
}
.tn-card-views::before { content: '👁 '; }

/* ============================================================
   PAGINATION
   ============================================================ */
.tn-pagination {
  display: flex;
  justify-content: center;
  padding: 24px 0 40px;
}
.tn-pagination .pagination {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.tn-pagination .page-item { display: block; }
.tn-pagination .page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
}
.tn-pagination .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tn-pagination .page-item.disabled .page-link {
  opacity: .4;
  cursor: default;
  pointer-events: none;
}
.tn-pagination .page-item .page-link:hover:not(.disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   POST PAGE — HERO
   ============================================================ */
.tn-post-hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 0;
}
.tn-post-hero-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
}
.tn-post-icon {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.tn-post-icon img { width: 100%; height: 100%; object-fit: cover; }
.tn-post-info { flex: 1; }
.tn-post-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
}
.tn-post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  font-size: .85rem;
  color: var(--muted);
}
.tn-post-meta a { color: var(--accent); font-weight: 500; }
.tn-post-meta span { display: flex; align-items: center; gap: 4px; }
.tn-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: 1rem;
  transition: background .2s, transform .15s;
  box-shadow: 0 4px 14px rgba(22,163,74,.35);
}
.tn-dl-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.tn-dl-btn::before { content: '⬇️'; font-size: 1.1rem; }

/* ============================================================
   POST PAGE — TABS
   ============================================================ */
.tn-tabs {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: var(--header-h);
  z-index: 10;
}
.tn-tabs-inner {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tn-tabs-inner::-webkit-scrollbar { display: none; }
.tn-tab {
  padding: 14px 22px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tn-tab:hover { color: var(--text); }
.tn-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tn-tab-panel { display: none; padding: 28px 0; }
.tn-tab-panel.active { display: block; }

/* Description */
.tn-description {
  font-size: .95rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 760px;
}
.tn-description p { margin-bottom: .8em; }

/* Screenshots — horizontal scroll */
.tn-screenshots {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tn-screenshots img {
  height: 320px;
  width: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: cover;
}

/* Download block */
.tn-download-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 620px;
}
.tn-dl-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  transition: border-color .2s, box-shadow .2s;
}
.tn-dl-item:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(22,163,74,.12); }
.tn-dl-item-icon { font-size: 1.5rem; flex-shrink: 0; }
.tn-dl-item-info { flex: 1; }
.tn-dl-item-name { font-weight: 600; font-size: .95rem; }
.tn-dl-item-url { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.tn-dl-item-btn {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s;
}
.tn-dl-item-btn:hover { background: var(--accent-hover); }

/* ============================================================
   POST PAGE — SIDEBAR / SIMILAR APPS
   ============================================================ */
.tn-post-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
  padding: 24px 0 48px;
}
@media (max-width: 900px) {
  .tn-post-layout { grid-template-columns: 1fr; }
}
.tn-similar-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}
.tn-similar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tn-similar-item a {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: box-shadow .2s, border-color .2s;
}
.tn-similar-item a:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(22,163,74,.1); }
.tn-similar-img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}
.tn-similar-img img { width: 100%; height: 100%; object-fit: cover; }
.tn-similar-name { font-size: .83rem; font-weight: 600; line-height: 1.3; color: var(--text); }
.tn-similar-cat { font-size: .74rem; color: var(--muted); margin-top: 2px; }

/* ============================================================
   FOOTER
   ============================================================ */
.tn-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: 40px;
  text-align: center;
  font-size: .83rem;
  color: var(--muted);
}
.tn-footer a { color: var(--muted); }
.tn-footer a:hover { color: var(--accent); }

/* ============================================================
   MAIL MODAL (keep functional)
   ============================================================ */
.mailto-modal {
  display: none;
  position: fixed;
  z-index: 300;
  inset: 0;
  background: rgba(0,0,0,.5);
  align-items: center;
  justify-content: center;
}
.mailto-modal.active { display: flex; }
.mailto-modal-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 480px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.mailto-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
}
.inmail {
  display: block;
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: .9rem;
  margin-top: 6px;
  outline: none;
  transition: border-color .2s;
}
.inmail:focus { border-color: var(--accent); }
.inmail_textarea { height: 100px; resize: vertical; }

/* ============================================================
   ALL CATEGORIES CLOUD
   ============================================================ */
.tn-all-cats {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 36px 0 44px;
  margin-top: 8px;
}
.tn-all-cats-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}
.tn-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tn-cloud-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  color: var(--accent);
  background: var(--surface);
  transition: background .18s, color .18s, border-color .18s;
  white-space: nowrap;
}
.tn-cloud-tag:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Main category — filled accent */
.tn-cloud-tag--main {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}
.tn-cloud-tag--main:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .tn-nav { display: none; }
  .tn-burger { display: flex; }
  .tn-search { max-width: none; flex: 1; min-width: 0; }

  /* Header: logo shrink */
  .tn-logo img { height: 26px; width: auto; }

  /* Search compact on mobile */
  .tn-search input { font-size: .85rem; padding: 0 10px; }
  .tn-search button { padding: 0 12px; font-size: .8rem; }

  /* Breadcrumbs */
  .tn-breadcrumbs .over { font-size: .78rem; }

  /* Post hero */
  .tn-post-hero-inner { grid-template-columns: 72px 1fr; gap: 12px; }
  .tn-post-icon { width: 72px; height: 72px; border-radius: 14px; }
  .tn-post-title { font-size: 1.1rem; }
  .tn-post-meta { font-size: .78rem; gap: 8px; }
  .tn-dl-btn { padding: 10px 20px; font-size: .9rem; }

  /* Tabs */
  .tn-tab { padding: 12px 14px; font-size: .83rem; }

  /* Screenshots */
  .tn-screenshots img { height: 200px; }

  /* Download items */
  .tn-dl-item { padding: 10px 12px; gap: 10px; }
  .tn-dl-item-url { max-width: 160px; }

  /* All cats cloud — wraps naturally, no changes needed */
}

@media (max-width: 480px) {
  .tn-header-inner { gap: 8px; padding: 0 12px; }
  .tn-logo img { height: 22px; }

  /* 2-column grid on small phones */
  .tn-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tn-card-body { padding: 8px; }
  .tn-card-name { font-size: .8rem; }

  /* Post layout: sidebar below content */
  .tn-post-layout { grid-template-columns: 1fr; }
  .tn-post-hero { padding: 16px 0; }
  .tn-post-hero-inner { grid-template-columns: 60px 1fr; gap: 10px; }
  .tn-post-icon { width: 60px; height: 60px; border-radius: 12px; }
  .tn-post-title { font-size: 1rem; }

  /* Download button full width */
  .tn-dl-btn { width: 100%; justify-content: center; }

  /* Download items vertical on tiny screens */
  .tn-dl-item { flex-wrap: wrap; }
  .tn-dl-item-btn { width: 100%; text-align: center; }

  .tn-all-cats { padding: 20px 0 28px; }
  .tn-cloud { gap: 6px; }
  .tn-cloud-tag { font-size: .78rem; padding: 5px 10px; }

  /* Pagination compact */
  .tn-pagination .page-item .page-link { min-width: 32px; height: 32px; font-size: .8rem; padding: 0 8px; }
}
