:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --accent-a: #ff8a3d;
  --accent-b: #ff4d8d;
  --up: #e53935;
  --down: #2fb670;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--secondary-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 78px;
}

.topbar {
  padding: 18px 18px 22px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 16px rgba(255, 77, 141, 0.25);
}

.brand {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .eagle {
  font-size: 26px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}

.tagline {
  color: rgba(255,255,255,0.85);
  font-size: 12.5px;
  margin-top: 3px;
}

#view {
  padding: 14px 12px 16px;
  margin-top: -12px;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-top: 1px solid rgba(127,127,127,0.15);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 4px;
  border-radius: 12px;
  transition: background-color .15s, color .15s;
}

.tab.active {
  color: var(--link);
  font-weight: 700;
  background: var(--secondary-bg);
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-row {
  display: flex;
  gap: 12px;
}

.thumb {
  width: 68px;
  height: 68px;
  border-radius: 13px;
  overflow: hidden;
  background: var(--secondary-bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.thumb-placeholder {
  font-size: 26px;
  opacity: .35;
}

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

.card-title {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.3;
  margin-bottom: 4px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-meta {
  font-size: 11.5px;
  color: var(--hint);
  margin-top: 6px;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.owner-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--link);
  background: var(--secondary-bg);
  border-radius: 8px;
  padding: 2px 7px;
  margin-bottom: 6px;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(127,127,127,0.12);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--secondary-bg);
  color: var(--text);
  flex: 1;
}

.btn.primary {
  background: var(--button);
  color: var(--button-text);
  font-weight: 600;
}

.btn.danger {
  color: var(--up);
}

input[type=text], input[type=url] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 13px;
  border: 1px solid rgba(127,127,127,0.25);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 10px;
}

input[type=text]:focus, input[type=url]:focus {
  outline: 2px solid var(--link);
  outline-offset: -1px;
}

.empty {
  color: var(--hint);
  text-align: center;
  padding: 50px 20px;
  font-size: 14px;
  line-height: 1.5;
}

.candidate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--card);
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.candidate .price {
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}

.candidate .label {
  font-size: 11.5px;
  color: var(--hint);
  margin-top: 2px;
}

.candidate {
  border: 2px solid transparent;
}

.candidate.selected {
  border-color: var(--link);
}

.candidate.selected::after {
  content: "✓";
  color: var(--link);
  font-weight: 800;
  font-size: 16px;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 4px 6px 10px;
}

.rename-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.rename-row[hidden] {
  display: none;
}

.rename-row input {
  margin-bottom: 0;
  flex: 1;
}

.spinner {
  text-align: center;
  padding: 40px;
  color: var(--hint);
  font-size: 14px;
}

.success-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.success-card .thumb {
  width: 56px;
  height: 56px;
}

.success-icon {
  font-size: 22px;
}

.photo-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(127,127,127,0.12);
}

.image-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.image-picker-item {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--secondary-bg);
  padding: 0;
}

.image-picker-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.image-picker-item:active,
.image-picker-item.selected {
  border-color: var(--link);
}
