/* Telegram passes its theme as --tg-theme-* variables; the --fb-* values are only for previews outside Telegram. */
:root {
  --fb-bg: #efeff4;
  --fb-card: #ffffff;
  --fb-text: #000000;
  --fb-hint: #8e8e93;
  --fb-accent: #2481cc;
  --fb-accent-text: #ffffff;
  --fb-section-title: #6d6d72;
  --fb-danger: #e53935;
  --fb-separator: rgba(60, 60, 67, 0.18);
  --fb-field: #f2f2f7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #000000;
    --fb-card: #1c1c1e;
    --fb-text: #ffffff;
    --fb-hint: #98989e;
    --fb-accent: #3e88f7;
    --fb-accent-text: #ffffff;
    --fb-section-title: #8d8e93;
    --fb-danger: #ff5c5c;
    --fb-separator: rgba(84, 84, 88, 0.6);
    --fb-field: #2c2c2e;
  }
}
:root {
  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --accent: var(--tg-theme-button-color, var(--fb-accent));
  --accent-text: var(--tg-theme-button-text-color, var(--fb-accent-text));
  --link: var(--tg-theme-link-color, var(--accent));
  --section-title: var(--tg-theme-section-header-text-color, var(--fb-section-title));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));
  --separator: var(--tg-theme-section-separator-color, var(--fb-separator));
  --field: var(--fb-field);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }

/* tabs */
.tabs {
  position: sticky; top: 0; z-index: 2;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  margin: 0 -16px 4px; padding: 8px 16px;
  background: var(--bg);
}
.tab {
  border: 0; border-radius: 9px; padding: 8px 6px;
  background: transparent; color: var(--hint); font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab.is-active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.badge {
  min-width: 20px; padding: 1px 6px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 12px; line-height: 18px;
}

/* sections */
.section { margin-top: 18px; }
.section-title {
  margin: 0 0 6px 16px; font-size: 13px; font-weight: 500;
  color: var(--section-title); text-transform: uppercase; letter-spacing: .02em;
}
.section-hint, .section-error { margin: 6px 16px 0; font-size: 13px; color: var(--hint); }
.section-error { color: var(--danger); }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 6px 16px;
}
.row + .row, .budget-body + .row { border-top: 0.5px solid var(--separator); }
.row-label { flex: 1 1 auto; }

/* segmented control */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  margin: 8px; padding: 2px; border-radius: 9px; background: var(--field);
}
.segmented.compact { margin: 0; flex: 0 0 auto; min-width: 128px; }
.seg {
  border: 0; border-radius: 7px; padding: 7px 8px; background: transparent;
  font-size: 15px; font-weight: 500; line-height: 1.15;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.seg small { font-size: 11px; font-weight: 400; color: var(--hint); }
.seg.is-active { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg:disabled { color: var(--hint); cursor: default; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; }
.chip {
  min-height: 38px; padding: 8px 14px; border-radius: 19px;
  border: 1px solid var(--separator); background: transparent;
  font-size: 15px; font-weight: 500; transition: background .12s, color .12s, border-color .12s;
}
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.is-any { color: var(--link); }
.chip.is-any.is-active { color: var(--accent-text); }
#rooms .chip:not(.is-any) { min-width: 52px; }
.presets { padding-top: 0; }
.presets .chip { min-height: 32px; padding: 5px 12px; font-size: 14px; }

/* budget inputs */
.budget-body { border-top: 0.5px solid var(--separator); }
.budget-body.is-disabled { opacity: .4; pointer-events: none; }
.range { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; }
.field {
  flex: 1 1 0; display: flex; align-items: baseline; gap: 6px;
  padding: 9px 12px; border-radius: 10px; background: var(--field); min-width: 0;
}
.field-label { color: var(--hint); font-size: 14px; }
.field input {
  flex: 1 1 auto; width: 100%; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 17px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums;
}
.field input::placeholder { color: var(--hint); font-weight: 400; }
.field:focus-within { box-shadow: 0 0 0 2px var(--accent) inset; }
.range-dash { color: var(--hint); }

/* switch */
.switch {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto;
  width: 51px; height: 31px; border-radius: 16px; margin: 0;
  background: var(--field); position: relative; transition: background .2s; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* select */
.select-row select {
  appearance: none; -webkit-appearance: none; border: 0; outline: 0; background: transparent;
  color: var(--hint); text-align: right; text-align-last: right; padding-right: 18px; max-width: 60%;
  background-image: linear-gradient(45deg, transparent 50%, var(--hint) 50%), linear-gradient(135deg, var(--hint) 50%, transparent 50%);
  background-position: calc(100% - 7px) 55%, calc(100% - 2px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

/* summary */
.summary { padding: 4px 0; }
.summary-line { display: flex; gap: 12px; padding: 9px 16px; align-items: baseline; }
.summary-line + .summary-line { border-top: 0.5px solid var(--separator); }
.summary-key { color: var(--hint); flex: 0 0 76px; font-size: 15px; }
.summary-value { flex: 1 1 auto; font-weight: 500; overflow-wrap: anywhere; }

/* my searches */
.request { margin-top: 12px; }
.request-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 4px; }
.request-title { font-weight: 600; }
.request-date { color: var(--hint); font-size: 13px; }
.request-delete {
  width: 100%; border: 0; border-top: 0.5px solid var(--separator); background: transparent;
  color: var(--danger); padding: 12px 16px; text-align: left; font-size: 16px;
}
/* podborka inside a search card */
.pod { border-top: 0.5px solid var(--separator); padding: 10px 16px 12px; }
.pod-head { display: flex; justify-content: space-between; align-items: baseline; }
.pod-title { font-weight: 600; }
.pod-count { color: var(--hint); font-size: 14px; }
.pod-hint { margin: 6px 0 0; color: var(--hint); font-size: 14px; }
.pod-list { list-style: none; margin: 8px 0 0; padding: 0; }
.pod-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.pod-item + .pod-item { border-top: 0.5px solid var(--separator); }
.pod-thumb { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--field); }
.pod-thumb-empty { display: grid; place-items: center; font-size: 20px; }
.pod-line { flex: 1 1 auto; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.pod-remove {
  flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--field); color: var(--hint); font-size: 20px; line-height: 1;
}
.pod-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.pod-share {
  flex: 1 1 auto; min-height: 42px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 15px;
}
.pod-view { flex: 0 0 auto; }

.loading, .empty { text-align: center; color: var(--hint); padding: 48px 16px; }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.empty p { margin: 0 0 12px; }

/* done */
.done { text-align: center; padding-top: 32px; }
.done-icon {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-text);
  animation: pop .35s ease-out;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.done-title { margin: 0 0 8px; font-size: 22px; }
.done-text { margin: 0 auto 20px; max-width: 340px; color: var(--hint); }
.done .summary { text-align: left; margin-bottom: 16px; }

.link-button { border: 0; background: transparent; color: var(--link); font-size: 16px; padding: 10px; }
.primary-button {
  width: 100%; min-height: 50px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 16px;
}
.primary-button:disabled { opacity: .45; }
.fallback-bar { position: sticky; bottom: 0; padding: 16px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: rgba(0,0,0,.82); color: #fff; font-size: 14px; z-index: 10;
}
