/* ── Variables ─────────────────────────────────────── */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-raised: #f0ede7;
  --border: #e4e0d8;
  --text: #1a1814;
  --text-muted: #6b6560;
  --accent: #e85d04;
  --accent-light: #fff0e8;
  --accent-dark: #c24d00;
  --badge-bg: #f0ede7;
  --badge-text: #5a5652;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #221f1c;
    --surface-raised: #2c2825;
    --border: #342f2b;
    --text: #ede9e3;
    --text-muted: #9a948d;
    --accent: #ff7c2a;
    --accent-light: #2d1a0a;
    --accent-dark: #ffaa6e;
    --badge-bg: #2c2825;
    --badge-text: #b0a99f;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
  }
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

/* ── App Layout ────────────────────────────────────── */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

/* ── Header ────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding-top: 28px;
  padding-bottom: 16px;
}

@supports (backdrop-filter: blur(12px)) {
  .header {
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.brand-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Unit Toggle */
.unit-toggle {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1.5px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}

.unit-toggle:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.unit-toggle:active { transform: scale(0.96); }
.unit-toggle.active-f { background: var(--accent); color: #fff; border-color: var(--accent-dark); }

/* ── Search ────────────────────────────────────────── */
.search-bar { display: flex; flex-direction: column; gap: 12px; }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

#searchInput {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 40px 12px 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

#searchInput::placeholder { color: var(--text-muted); }

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 6px;
  display: none;
  transition: color 0.15s;
}

.search-clear:hover { color: var(--text); }
.search-clear.visible { display: block; }

/* ── Filter Chips ──────────────────────────────────── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Main ──────────────────────────────────────────── */
.main { padding-top: 8px; }

.result-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
}

/* ── Grid ──────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Card ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.card.hidden { display: none; }

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.3;
}

.category-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--badge-text);
  background: var(--badge-bg);
  border-radius: 6px;
  padding: 3px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-stats {
  display: flex;
  gap: 20px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
}

.stat svg { flex-shrink: 0; }

.stat:first-child svg { color: var(--accent); }

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.stat:first-child .stat-value { color: var(--accent); }

.card-notes {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.55;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

/* ── No Results ────────────────────────────────────── */
.no-results {
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 60px 0;
}

/* ── Footer ────────────────────────────────────────── */
.footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer code {
  font-size: 0.8rem;
  background: var(--badge-bg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 520px) {
  .brand-title { font-size: 1.3rem; }
  .brand-icon { font-size: 1.8rem; }
  .grid { grid-template-columns: 1fr; }
}
