:root {
  --claret: #9c2f5c;
  --claret-dark: #3a0820;
  --sky-blue: #95BFE5;
  --villa-blue: #0d1526;
  --gold: #FDB913;
  --bg: #0f0a10;
  --card-bg: #1c1319;
  --card-border: #331624;
  --text: #f2ece9;
  --text-muted: #a9a0a4;
  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, var(--claret-dark), #1a0710);
  border-bottom: 1px solid var(--card-border);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

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

.brand-refresh:active {
  opacity: 0.7;
}

.brand-refresh:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

.topbar .crest {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.search-wrap {
  flex: 1;
  min-width: 0;
}

.search-input {
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 0.9rem;
  min-height: 38px;
}

.search-input::placeholder {
  color: rgba(242,236,233,0.5);
}

.search-input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255,255,255,0.12);
}

.search-input::-webkit-search-cancel-button {
  filter: invert(1) brightness(2);
}

@media (min-width: 700px) {
  .search-wrap {
    flex: none;
    width: 2in;
    margin-left: auto;
  }
}

@media (max-width: 400px) {
  .topbar h1 { display: none; }
}

.feed {
  padding: 12px 12px 8px;
  max-width: 640px;
  margin: 0 auto;
}

.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 12px calc(var(--nav-height) + 24px);
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--gold);
  text-decoration: underline;
}

@media (min-width: 700px) {
  .feed {
    max-width: none;
    padding: 20px 48px 8px;
  }

  .site-footer {
    max-width: none;
    padding: 8px 48px calc(var(--nav-height) + 32px);
  }
}

.loading, .empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border-left: 4px solid var(--claret);
  cursor: pointer;
}

.card:active { background: #251720; }

.card .badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  background: rgba(253, 185, 19, 0.1);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .meta {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  background: var(--villa-blue);
  border-top: 1px solid var(--card-border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.5);
  z-index: 10;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 44px;
}

.nav-btn.active {
  color: var(--gold);
}

.detail {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.detail.hidden { display: none; }

.detail-inner {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-bottom: none;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  position: relative;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--text-muted);
  min-width: 44px;
  min-height: 44px;
}

.detail .badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(253, 185, 19, 0.1);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.detail h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
  line-height: 1.35;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}

.detail-title-row h2 {
  margin: 0;
}

.detail-share {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.detail-share:hover,
.detail-share:focus-visible {
  background: rgba(255,255,255,0.12);
  color: var(--gold);
}

.share-feedback {
  display: block;
  height: 0;
  overflow: hidden;
  font-size: 0.75rem;
  color: var(--gold);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.share-feedback.visible {
  height: auto;
  opacity: 1;
  margin-bottom: 8px;
}

.detail-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.detail-summary p {
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 14px;
  font-size: 1rem;
}

.detail-summary p:last-child {
  margin-bottom: 0;
}

.detail a {
  display: inline-block;
  margin-top: 12px;
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
}

@media (min-width: 640px) {
  .detail { align-items: center; justify-content: center; }
  .detail-inner {
    max-width: 480px;
    border-radius: 18px;
    max-height: 80vh;
  }
}

@media (min-width: 900px) {
  .detail-inner {
    max-width: 720px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .card, .detail-inner { transition: transform 0.15s ease; }
}
