:root {
  --bg: #f6f7f5;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #0f7b3e;
  --card: #ffffff;
  --border: #e3e3e0;
  --hl: #fff7c2;

  --cat-ippan: #6b6b6b;
  --cat-yugai: #c0392b;
  --cat-shigen: #0f7b3e;
  --cat-kanden: #d68910;
  --cat-sodai: #2874a6;
  --cat-hannyu: #7d3c98;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --fg: #f0f0f0;
    --muted: #a0a0a0;
    --card: #2a2a2a;
    --border: #3a3a3a;
    --hl: #5a4a00;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 12px 16px 8px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.05em;
}

#search-form {
  margin: 0;
}

.search-wrap {
  position: relative;
}

#q {
  width: 100%;
  padding: 12px 40px 12px 14px;
  font-size: 17px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  outline: none;
  -webkit-appearance: none;
}

#q:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 62, 0.15);
}

/* type="search" のブラウザ標準クリアボタンを隠す（自前ボタンを使うため） */
#q::-webkit-search-cancel-button,
#q::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

#clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--muted);
  color: var(--card);
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
}

#clear:active {
  background: var(--fg);
}

#clear[hidden] {
  display: none;
}

main {
  flex: 1;
  padding: 8px 16px 24px;
}

.status {
  color: var(--muted);
  font-size: 14px;
  margin: 12px 0;
  text-align: center;
}

#results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0;
}

.item-name {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 6px;
}

.item-name mark {
  background: var(--hl);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.cat {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  color: white;
  background: var(--muted);
}

.cat--一般ごみ { background: var(--cat-ippan); }
.cat--有害ごみ { background: var(--cat-yugai); }
.cat--資源物 { background: var(--cat-shigen); }
.cat--乾電池 { background: var(--cat-kanden); }
.cat--粗大ごみ { background: var(--cat-sodai); }
.cat--搬入禁止 { background: var(--cat-hannyu); }

.note {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.5;
}

footer {
  padding: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--muted);
  text-decoration: underline;
}

#meta {
  margin: 4px 0 0;
}
