:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --surface2: #1a1a1a;
  --text: #f5f5f7;
  --muted: #9e9ea6;
  --hint: #6e6e76;
  --divider: #2c2c32;
  --accent: #da70d6;
  --accent2: #ff69b4;
  --accent-dark: #ba55d3;
  --danger: #f87171;
  --radius: 16px;
  --nav-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 16px 10px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #070707 72%, rgba(0, 0, 0, 0.45) 100%);
  border-bottom: 1px solid var(--divider);
}
.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.app-header .subtitle {
  margin: 4px 0 0;
  color: var(--hint);
  font-size: 0.78rem;
}

main {
  padding: 12px 16px 88px;
  padding-bottom: calc(88px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
}

.view {
  display: none;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.view.active { display: block; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--divider);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.bottom-nav button.active {
  color: var(--accent);
}
.bottom-nav .ico {
  font-size: 1.25rem;
  line-height: 1;
}

.search-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.search-controls input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--divider);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
}
.search-controls input:focus {
  outline: none;
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(218, 112, 214, 0.2);
}
.icon-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active {
  transform: scale(0.98);
}
#search-btn.icon-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-color: transparent;
}

.hint {
  font-size: 0.85rem;
  color: var(--hint);
  margin: 8px 0 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card-suggestion {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--divider);
}
.card-suggestion img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface2);
}
.card-suggestion .label {
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

.section-title {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.creator-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 4px 0 10px;
  color: var(--muted);
}

.social-links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.banner-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--divider);
  text-decoration: none;
  color: inherit;
}
.banner-card .site-ico {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.banner-card .meta .site { font-size: 0.72rem; color: var(--muted); line-height: 1.15; }
.banner-card .meta .id { font-size: 0.82rem; font-weight: 600; line-height: 1.2; }

.media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.media-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface2);
  cursor: pointer;
  border: 1px solid var(--divider);
}
.media-cell img, .media-cell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-cell .badge-type {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 0.65rem;
  padding: 2px 6px;
  background: rgba(0,0,0,0.65);
  border-radius: 4px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.fav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--divider);
}
.fav-item button.remove {
  border: none;
  background: rgba(248,113,113,0.15);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}
.fav-item .go {
  flex: 1;
  text-align: left;
  border: none;
  background: none;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 8px 0 0;
}

.loading {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}
.error-msg {
  background: rgba(248,113,113,0.12);
  color: #fecaca;
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.search-loading {
  margin-bottom: 12px;
  padding: 14px 12px;
  border-radius: var(--radius);
  background: rgba(218, 112, 214, 0.12);
  border: 1px solid rgba(218, 112, 214, 0.35);
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-loading .spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent2);
  animation: spin 0.85s linear infinite;
  flex-shrink: 0;
}
.search-loading p {
  margin: 0;
  font-size: 0.9rem;
  color: #ffd8f4;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.lightbox .close-lb {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.hidden { display: none !important; }
