:root {
  --bg: #ffffff;
  --bg-alt: #f7f7f7;
  --text: #1a1a1a;
  --text-muted: #888;
  --open: #2a8a2a;
  --closed: #a05040;
  --filter-bg: #ffffff;
  --filter-border: #ccc;
  --filter-active-bg: #1a1a1a;
  --filter-active-text: #ffffff;
  --separator: #e8e8e8;
  --bar-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-alt: #222;
    --text: #e8e8e8;
    --text-muted: #666;
    --open: #4caf50;
    --closed: #c07060;
    --filter-bg: #1a1a1a;
    --filter-border: #444;
    --filter-active-bg: #e8e8e8;
    --filter-active-text: #1a1a1a;
    --separator: #2e2e2e;
    --bar-bg: #1a1a1a;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

/* Filter bar */
#filter-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding-top: env(safe-area-inset-top);
  background: var(--bar-bg);
  border-bottom: 1px solid var(--separator);
  overscroll-behavior: none;
}

#filter-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

#filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--filter-border);
  background: var(--filter-bg);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.filter-btn.active {
  background: var(--filter-active-bg);
  color: var(--filter-active-text);
  border-color: var(--filter-active-bg);
}

#clear-btn {
  display: none;
  flex-shrink: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border: none;
  border-left: 1px solid var(--separator);
  border-radius: 0;
  background: var(--bar-bg);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  align-self: stretch;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#clear-btn.visible {
  display: block;
}

/* Business list */
#business-list {
  position: fixed;
  top: calc(41px + env(safe-area-inset-top));
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  list-style: none;
  overscroll-behavior-y: contain;
}

#business-list::-webkit-scrollbar {
  display: none;
}

/* Category header */
.category-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
}

/* Each row */
.biz-row {
  position: relative;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.biz-main {
  padding: 10px 16px;
  background: var(--bg);
}

.biz-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.biz-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.biz-status {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  flex-shrink: 0;
}

.biz-accordion {
  display: none;
  padding-top: 6px;
}

.biz-row.expanded .biz-accordion {
  display: block;
}

.biz-status .open {
  color: var(--open);
  font-weight: 600;
}

.biz-status .closed {
  font-weight: 600;
  color: var(--closed);
}

/* Weekly schedule */
.biz-schedule {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 10px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

.schedule-override-rule {
  grid-column: 1 / -1;
  border-top: 1px solid var(--separator);
  margin: 2px 0;
}

.schedule-override {
  font-style: italic;
}

/* Contact links (phone + maps) */
.biz-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.biz-call,
.biz-maps {
  display: inline-block;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #999;
  text-decoration: none;
  padding: 2px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

@media (prefers-color-scheme: dark) {
  .biz-call,
  .biz-maps {
    color: #777;
    border-color: #444;
  }
}

/* Updated label */
#updated-label {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 16px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  background: var(--bar-bg);
  border-top: 1px solid var(--separator);
}
