:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-muted: #f2f0ea;
  --ink: #141413;
  --ink-muted: #5c5b57;
  --border: #e5e2d9;
  --accent: #d97757;
  --accent-dark: #b85d3f;
  --green-bg: #e8f5ec;
  --green-ink: #1d6b3a;
  --amber-bg: #fef3dc;
  --amber-ink: #945800;
  --red-bg: #fdeae6;
  --red-ink: #a6321c;
  --radius: 12px;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 20px;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav a, .nav-link-btn {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.nav a:hover, .nav-link-btn:hover { color: var(--ink); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2c2b29; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-muted); }

/* Hero */
.hero {
  padding: 64px 0 44px;
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  max-width: 740px;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent-dark);
  font-weight: 500;
  margin: 0 0 14px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 5.5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 18px;
}

.hero h1 em {
  color: var(--accent);
  font-style: italic;
}

.hero-sub {
  font-size: 17px;
  color: var(--ink-muted);
  margin: 0 auto 28px;
  max-width: 600px;
}

.newsletter-form {
  display: flex;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto 10px;
}

.newsletter-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
}

.newsletter-form input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.newsletter-note {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0;
}

/* Controls */
.library-section { padding: 36px 0 64px; }

.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
}

#search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
}

#search-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.filter-group, .category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill, .cat-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.pill.active, .cat-pill.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.select-input {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 16px;
}

.text-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.text-link:hover { text-decoration: underline; }

/* Grid & Cards */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.app-card:hover {
  transform: translateY(-2px);
  border-color: #cfc9bc;
  box-shadow: 0 8px 24px rgba(20, 20, 19, 0.06);
}

.app-card.sponsored {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fffaf8 0%, #ffffff 45%);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.app-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-muted);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

.badge-sponsored { background: var(--accent); color: #fff; }
.badge-type { background: var(--surface-muted); color: var(--ink); }
.badge-default { background: var(--green-bg); color: var(--green-ink); }
.badge-app { background: var(--amber-bg); color: var(--amber-ink); }
.badge-full { background: var(--red-bg); color: var(--red-ink); }

.app-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-desc {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--surface-muted);
  font-size: 12px;
  color: var(--ink-muted);
}

.read-more {
  color: var(--ink);
  font-weight: 600;
}

/* Permissions Guide */
.permissions-section {
  padding: 56px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.section-head {
  max-width: 600px;
  margin-bottom: 28px;
}

.section-head h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 34px;
  margin: 0 0 8px;
}

.section-head p {
  margin: 0;
  color: var(--ink-muted);
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.perm-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg);
}

.perm-card h3 { margin: 12px 0 6px; font-size: 16px; }
.perm-card p { margin: 0; font-size: 14px; color: var(--ink-muted); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand { margin: 0 0 6px; color: var(--ink); }
.footer-disclaimer { margin: 0; max-width: 560px; font-size: 12px; }
.footer-links { display: flex; gap: 16px; }

/* Modals */
.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 620px;
  width: calc(100% - 24px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
}

.modal::backdrop {
  background: rgba(20, 20, 19, 0.55);
  backdrop-filter: blur(4px);
}

.modal-box {
  padding: 28px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.teardown-block {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.teardown-block h4 {
  margin: 0 0 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--ink-muted);
}

.teardown-block p { margin: 0; font-size: 14px; }

.prompt-pre {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #1c1b1a;
  color: #f4f2ec;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.hidden { display: none; }

.modal-sub { color: var(--ink-muted); font-size: 14px; margin: 0 0 18px; }

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
}

.stack-form input, .stack-form select, .stack-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.price-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--bg);
}

.featured-price { border-color: var(--accent); }
.price-tag { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--accent-dark); }
.price-card h3 { margin: 6px 0 4px; font-size: 15px; }
.price-card p { margin: 0; font-size: 13px; color: var(--ink-muted); }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 680px) {
  .nav a { display: none; }
  .newsletter-form { flex-direction: column; }
  .pricing-grid { grid-template-columns: 1fr; }
}
