:root {
  color-scheme: light dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--tg-theme-bg-color, #f2f2f2);
  color: var(--tg-theme-text-color, #111);
  padding-bottom: 24px;
}

.tabs {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--tg-theme-secondary-bg-color, #fff);
  z-index: 5;
}

.tab-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-theme-hint-color, #888);
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--tg-theme-link-color, #2481cc);
  border-bottom-color: var(--tg-theme-link-color, #2481cc);
}

.tab-panel { display: none; padding: 12px; }
.tab-panel.active { display: block; }

.list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.card {
  background: var(--tg-theme-bg-color, #fff);
  border: 1px solid rgba(127,127,127,0.25);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 10px;
}

.card img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.card-body { flex: 1; min-width: 0; }

.card-title {
  font-weight: 600;
  font-size: 14px;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-meta {
  font-size: 12px;
  color: var(--tg-theme-hint-color, #888);
  margin-top: 4px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 999px;
  transition: 0.15s;
  cursor: pointer;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
}

.switch input:checked + .slider {
  background: var(--tg-theme-link-color, #2481cc);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.edit-btn {
  border: none;
  background: none;
  font-size: 18px;
  color: var(--tg-theme-hint-color, #888);
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--tg-theme-button-color, #2481cc);
  color: var(--tg-theme-button-text-color, #fff);
  font-size: 15px;
  font-weight: 600;
}

.secondary-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(127,127,127,0.4);
  background: none;
  color: var(--tg-theme-text-color, #111);
}

.danger-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: #e53935;
  color: #fff;
  margin-right: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.overlay.hidden { display: none; }

.modal {
  background: var(--tg-theme-bg-color, #fff);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px;
}

.modal h3 { margin-top: 0; }

.modal form.hidden { display: none; }

.modal label {
  display: block;
  font-size: 13px;
  color: var(--tg-theme-hint-color, #888);
  margin: 10px 0 4px;
}

.modal input[type=text],
.modal input[type=time],
.modal select,
.modal textarea {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(127,127,127,0.4);
  background: var(--tg-theme-secondary-bg-color, #f7f7f7);
  color: var(--tg-theme-text-color, #111);
  font-size: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.checkbox-row input { width: auto; }

#ad-photo-preview img {
  margin-top: 8px;
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.empty-hint {
  text-align: center;
  color: var(--tg-theme-hint-color, #888);
  padding: 24px 0;
  font-size: 14px;
}
