:root {
  --bg: #fdf6ee;
  --bg-elevated: #ffffff;
  --text: #2b2117;
  --text-muted: #7a6d5e;
  --border: #ead9c3;
  --accent: #d9622b;
  --accent-contrast: #ffffff;
  --up: #2f9e44;
  --down: #e03131;
  --neutral: #9a9082;
  --danger: #e03131;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1712;
    --bg-elevated: #26201a;
    --text: #f2e9dd;
    --text-muted: #b3a493;
    --border: #3a3126;
    --accent: #ef7f45;
    --accent-contrast: #1b1712;
    --up: #51cf66;
    --down: #ff6b6b;
    --neutral: #6b6255;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(24px + var(--safe-bottom));
}

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

.topbar h1 {
  font-size: 1.3rem;
  margin: 0;
}

.icon-btn {
  border: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.new-rumor {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 18px;
}

.new-rumor textarea {
  width: 100%;
  resize: vertical;
  min-height: 4.5em;
  font-size: 1rem;
  font-family: inherit;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 4px;
}

.new-rumor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.btn-primary:active {
  opacity: 0.85;
}

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

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 44px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
  padding: 10px 0;
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}

.sort-toggle {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.sort-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 36px;
}

.sort-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.rumor-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rumor-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.rumor-votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  width: 56px;
}

.vote-btn {
  width: 48px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.vote-btn.up.active {
  background: var(--up);
  border-color: var(--up);
  color: #fff;
}

.vote-btn.down.active {
  background: var(--down);
  border-color: var(--down);
  color: #fff;
}

.rumor-score {
  font-weight: 700;
  font-size: 1rem;
  min-width: 2ch;
  text-align: center;
}

.rumor-score.pos { color: var(--up); }
.rumor-score.neg { color: var(--down); }
.rumor-score.zero { color: var(--neutral); }

.rumor-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rumor-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1rem;
  line-height: 1.4;
}

.rumor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rumor-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.delete-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 8px;
  min-height: 36px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  margin-top: 40px;
  padding: 0 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.admin-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-elevated);
  color: var(--text);
  max-width: 90vw;
  width: 340px;
}

.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.admin-dialog h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.admin-dialog label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.admin-dialog input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.admin-status {
  font-size: 0.85rem;
  min-height: 1.2em;
}

.admin-status.error { color: var(--danger); }
.admin-status.ok { color: var(--up); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 44px;
}

.btn-danger:active {
  background: var(--danger);
  color: #fff;
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.admin-danger-zone hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.admin-danger-zone h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 4px;
}

body.is-admin .delete-btn {
  display: inline-flex;
}

.delete-btn {
  display: none;
}
