/* ===== Damascus Trip Guide — Mobile-First Styles ===== */

/* --- Design tokens: Stone & Cypress --- */
:root {
  color-scheme: light;
  --bg: #eef2ef;
  --surface: #f7faf8;
  --surface-2: #e4ebe6;
  --surface-3: #d7e0da;
  --text: #15201c;
  --text-2: #31433c;
  --muted: #5f7269;
  --border: #c9d4cd;
  --accent: #1f6b5a;
  --accent-light: rgba(31,107,90,.12);
  --copper: #c45c26;
  --copper-light: rgba(196,92,38,.12);
  --green: #1f6b5a;
  --green-light: rgba(31,107,90,.12);
  --warn: #9a6a12;
  --warn-bg: #f7efd8;
  --warn-border: #e2cfa0;
  --shadow-sm: 0 1px 3px rgba(21,32,28,.06);
  --shadow-md: 0 8px 22px rgba(21,32,28,.1);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --header-h: 0px;
  --nav-h: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --geo: rgba(31,107,90,.045);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101816;
  --surface: #17221e;
  --surface-2: #203029;
  --surface-3: #2a3b33;
  --text: #e9f2ed;
  --text-2: #c5d5cd;
  --muted: #8ea49a;
  --border: #31443b;
  --accent: #5fbfa5;
  --accent-light: rgba(95,191,165,.14);
  --copper: #e08956;
  --copper-light: rgba(224,137,86,.14);
  --green: #5fbfa5;
  --green-light: rgba(95,191,165,.14);
  --warn: #e0bb4a;
  --warn-bg: #2b2510;
  --warn-border: #584f28;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 8px 22px rgba(0,0,0,.28);
  --geo: rgba(95,191,165,.05);
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--nav-h) + 12px);
}
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 60% at 100% -10%, rgba(31,107,90,.08), transparent 55%),
    radial-gradient(ellipse 90% 50% at -10% 20%, rgba(196,92,38,.05), transparent 50%),
    linear-gradient(135deg, var(--geo) 25%, transparent 25%),
    linear-gradient(225deg, var(--geo) 25%, transparent 25%);
  background-size: auto, auto, 18px 18px, 18px 18px;
  /* fixed backgrounds jank/scroll-lock on many phones */
  background-attachment: scroll;
  color: var(--text);
  font: 15px/1.5 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  overflow-x: hidden;
  min-height: 100dvh;
  max-width: 100vw;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button, a, .chip, .nav-tab, .card-action, .icon-btn, .header-btn, .filter-btn, .random-btn {
  -webkit-user-select: none;
  user-select: none;
}
html[dir="rtl"] body {
  font-family: "Noto Sans Arabic", "Noto Naskh Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}
html[dir="rtl"] .header-title,
html[dir="rtl"] .card-name {
  font-family: "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", serif;
  letter-spacing: 0;
  font-weight: 700;
}
html[dir="rtl"] .card-arabic {
  direction: ltr;
  text-align: start;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
html[lang="ar"] .card-arabic {
  /* Secondary English name under Arabic title */
  unicode-bidi: isolate;
}
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
a { color: var(--accent); }

/* Noscript */
.noscript {
  background: var(--warn-bg);
  color: var(--text);
  text-align: center;
  padding: 16px;
  font-weight: 600;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: calc(var(--safe-top) + 6px) calc(var(--safe-right) + 10px) 6px calc(var(--safe-left) + 10px);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .header { background: var(--bg); }
}

.header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #e8efe9, #d5e2d9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  animation: mark-in .5s ease both;
}
.brand-mark svg { width: 20px; height: 20px; display: block; }
[data-theme="dark"] .brand-mark {
  background: linear-gradient(145deg, #203029, #17221e);
}
@keyframes mark-in {
  from { opacity: 0; transform: scale(.85) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
.header-brand {
  flex: 1;
  min-width: 0;
}
.header-title {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.header-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.lang-btn {
  font-size: 0.92rem;
  font-weight: 800;
}
.header-btn:hover, .header-btn:focus-visible {
  border-color: var(--accent);
  background: var(--accent-light);
}
.header-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
[data-theme="dark"] .header-btn.active { color: #101816; }

/* Search bar */
.search-wrap {
  position: relative;
  margin-top: 6px;
}
.search-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding-block: 0;
  padding-inline: 38px 40px;
  font-size: 16px; /* prevents iOS zoom */
  outline: none;
  transition: border-color .15s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); }
.search-clear {
  position: absolute;
  inset-inline-end: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.search-clear.visible { display: flex; }

/* --- Navigation --- */
.nav {
  position: sticky;
  top: var(--header-h);
  z-index: 35;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 6px calc(var(--safe-right) + 10px) 8px calc(var(--safe-left) + 10px);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .nav { background: var(--bg); }
}

.nav-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 5px;
  scroll-snap-align: start;
}
.nav-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
[data-theme="dark"] .nav-tab.active { color: #101816; }

.tab-count {
  font-size: 0.75rem;
  opacity: 0.75;
  font-weight: 600;
}

/* Controls row — full-width thumb-friendly */
.nav-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.filter-btn, .random-btn {
  flex: 1;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.filter-btn:hover, .random-btn:hover {
  border-color: var(--accent);
}
.filter-btn svg { width: 15px; height: 15px; }
.filter-count {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-theme="dark"] .filter-count { color: #101816; }
.filter-btn.has-filters {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.random-btn {
  margin-inline-start: 0;
}

/* Quick chips */
.quick-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  padding-bottom: 2px;
  overscroll-behavior-x: contain;
}
.quick-chips::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0 14px;
  min-height: 40px;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.chip.active {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}
[data-theme="dark"] .chip.active { color: var(--green); }

/* --- Status bar --- */
.status {
  padding: 8px calc(var(--safe-right) + 10px) 4px calc(var(--safe-left) + 10px);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.status .muted {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Density switch: 1×n vs 2×n */
.density-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  flex-shrink: 0;
}
.density-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}
.density-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.density-btn[aria-pressed="true"] {
  background: var(--green);
  color: #fff;
}
[data-theme="dark"] .density-btn[aria-pressed="true"] { color: #101816; }

/* --- Card list --- */
.card-list {
  padding: 6px calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 28px) calc(var(--safe-left) + 10px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* 1 × n — full cards */
.card-list.density-1 {
  display: flex;
  flex-direction: column;
}

/* 2 × n — compact cards */
.card-list.density-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}
.card-list.density-2 .empty-state {
  grid-column: 1 / -1;
}
.card-list.density-2 .card {
  padding: 10px;
  gap: 6px;
  border-radius: 14px;
}
.card-list.density-2 .card-name {
  font-size: 0.88rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-list.density-2 .card-arabic {
  font-size: 0.72rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-list.density-2 .icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
}
.card-list.density-2 .card-badges { gap: 3px; }
.card-list.density-2 .badge {
  padding: 2px 6px;
  font-size: 0.62rem;
}
.card-list.density-2 .card-area {
  font-size: 0.74rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-list.density-2 .card-loc,
.card-list.density-2 .card-category,
.card-list.density-2 .card-desc,
.card-list.density-2 .card-bestfor,
.card-list.density-2 .card-tags,
.card-list.density-2 .card-warning,
.card-list.density-2 .card-actions-row {
  display: none !important;
}
.card-list.density-2 .card-actions {
  grid-template-columns: 1fr;
  gap: 5px;
  padding-top: 2px;
}
.card-list.density-2 .card-action {
  min-height: 40px;
  padding: 6px 4px;
  font-size: 0.72rem;
}
.card-list.density-2 .card-action.maps-btn {
  min-height: 42px;
  font-size: 0.78rem;
}
.card-list.density-2 .visited-btn {
  min-height: 38px;
}

/* --- Card --- */
.card {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  min-width: 0;
  animation: card-in .38s ease both;
  animation-delay: calc(min(var(--i, 0), 12) * 28ms);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .card { background: var(--surface); }
}
.card:active { transform: translateY(1px); }
.card.highlight {
  outline: 2.5px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light), var(--shadow-md);
  animation: pulse-card .8s ease;
  border-color: var(--accent);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-card {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.008); }
}

/* Card header */
.card-header {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.card-titles {
  flex: 1;
  min-width: 0;
}
.card-name {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.card-arabic {
  font-family: "Noto Naskh Arabic", "Geeza Pro", Tahoma, sans-serif;
  font-size: 0.92rem;
  color: var(--muted);
  direction: rtl;
  margin-top: 2px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Icon buttons (fav/visited) */
.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.fav-active {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}
.icon-btn.vis-active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
[data-theme="dark"] .icon-btn.vis-active { color: #101816; }

/* Badges */
.card-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.71rem;
  font-weight: 750;
  white-space: nowrap;
}
.badge-food {
  background: var(--copper-light);
  color: var(--copper);
}
.badge-place {
  background: var(--green-light);
  color: var(--green);
}
.badge-medium {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge-high {
  background: var(--green-light);
  color: var(--green);
}
.badge-sameday {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

/* Card body */
.card-area {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}
.card-loc {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}
.card-category {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}
.card-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.5;
}
.card-bestfor {
  font-size: 0.82rem;
  color: var(--muted);
}
.card-bestfor strong { color: var(--text-2); font-weight: 650; }

/* Tags */
.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--muted);
}

/* Warning */
.card-warning {
  border-inline-start: 3px solid var(--warn);
  background: var(--warn-bg);
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.45;
}
.phone-link {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 2px;
}

/* Card details (expandable) */
.card-details {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.card-details.open { display: flex; }
.card-toggle {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
  text-align: start;
}

/* Card actions */
.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}
.card-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all .12s;
  word-break: break-word;
}
.card-action:active { transform: scale(0.97); }
.card-action.maps-btn {
  background: linear-gradient(135deg, #1f6b5a, #2a8f78);
  border-color: transparent;
  color: #fff;
  grid-column: 1 / -1;
  min-height: 52px;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}
[data-theme="dark"] .card-action.maps-btn {
  background: linear-gradient(135deg, #2f8f78, #5fbfa5);
  color: #101816;
}
.card-action.maps-btn:active { filter: brightness(.95); }

.card-action.phone-btn {
  background: var(--surface);
  border-color: var(--green);
  color: var(--green);
}
.visited-btn {
  grid-column: 1 / -1;
}
.visited-btn.vis-active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
[data-theme="dark"] .visited-btn.vis-active { color: #101816; }

/* Span full width for single remaining actions */
.card-actions-row {
  display: flex;
  gap: 6px;
  grid-column: 1 / -1;
}
.card-actions-row .card-action { flex: 1; min-width: 0; }

/* --- Filter bottom sheet --- */
.sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 90;
  opacity: 0;
  transition: opacity .2s;
}
.sheet-backdrop.visible {
  display: block;
  opacity: 1;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 95;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.15);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22,.68,0,1.0);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 10px auto 0;
  flex-shrink: 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.sheet-head h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
}
.sheet-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-body {
  padding: 4px 16px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7370' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 5h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
html[dir="rtl"] .filter-select {
  background-position: left 12px center;
}
.filter-select:focus { border-color: var(--accent); }

.sheet-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.btn-reset-filters {
  flex: 1;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 750;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-apply-filters {
  flex: 1;
  height: 48px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 750;
  font-size: 0.9rem;
  cursor: pointer;
}
[data-theme="dark"] .btn-apply-filters { color: #101816; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: transform .3s, opacity .3s;
  white-space: normal;
  text-align: center;
  max-width: min(92vw, 360px);
  line-height: 1.35;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  margin: 10px 0;
}
.empty-state h2 {
  font-size: 1.1rem;
  margin: 0 0 6px;
}
.empty-state p {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}
.empty-state button {
  height: 44px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 0 24px;
  font-weight: 750;
  font-size: 0.9rem;
  cursor: pointer;
}
[data-theme="dark"] .empty-state button { color: #101816; }

/* --- Dialog --- */
dialog {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  max-width: min(420px, calc(100% - 32px));
  padding: 24px;
  box-shadow: var(--shadow-md);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font-size: 1.1rem; margin: 0 0 8px; }
dialog p { color: var(--muted); margin: 0 0 20px; font-size: 0.9rem; }
.dialog-btns {
  display: flex;
  gap: 8px;
}
.dialog-btns button {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  font-weight: 750;
  cursor: pointer;
  font-size: 0.88rem;
}
.btn-danger {
  background: #e74c3c;
  border: 1px solid #e74c3c;
  color: #fff;
}
.btn-cancel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* --- Footer --- */
.footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px calc(var(--safe-right) + 14px) calc(var(--safe-bottom) + 30px) calc(var(--safe-left) + 14px);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}
.footer p { margin: 0 0 6px; }
.footer-reset {
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 18px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

/* --- Phone-first: keep single column at all widths --- */
@media (min-width: 400px) {
  .card-list { padding-inline: 12px; }
  .card { padding: 15px; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* --- Print --- */
@media print {
  .header, .nav, .toast, .sheet, .sheet-backdrop, .footer-reset { display: none; }
  .card-list { padding: 0; display: block; }
  .card { break-inside: avoid; border: 1px solid #ccc; margin-bottom: 8px; box-shadow: none; }
}
