:root {
  --bg: #0b1220;
  --card: #131c2e;
  --text: #e6edf7;
  --muted: #8a98b3;
  --accent: #4f8cff;
  --accent-hover: #6aa0ff;
  --danger: #ff5e6c;
  --ok: #3ddb83;
  --border: #243149;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  padding: 12px 16px calc(12px) 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.3px;
}

.topbar nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
}

.nav-btn.active {
  color: var(--text);
  border-color: var(--accent);
}

.view { padding: 16px; max-width: 720px; margin: 0 auto; }
.view.hidden { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 4px 0;
  font-size: 16px;
}

.hint {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 14px;
}

.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.big-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.big-btn:not(:disabled):active {
  background: var(--accent-hover);
}

.link-btn,
.link-btn-real {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.thumbs:empty { display: none; }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

textarea, input {
  width: 100%;
  background: #0e1626;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  font-size: 15px;
}

textarea { resize: vertical; }

.status {
  margin-top: 12px;
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.primary { background: var(--accent); color: white; border: none; }
.danger  { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

.listing {
  background: #0e1626;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.listing-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.listing-images img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
}

.row { margin-top: 10px; }
.row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.kv {
  white-space: pre-wrap;
  background: #0a1120;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin: 0;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: #0a1120;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions button {
  flex: 1;
  min-width: 100px;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.actions button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
