:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-hover: #232d3b;
  --border: #2d3a4d;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3d9cf0;
  --accent-dim: #2563a8;
  --success: #34d399;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Breite per Klasse .app--wide (setzt app.js bei Ranking-Ansicht) */
.app.app--wide {
  max-width: 1100px;
}

.header {
  margin-bottom: 1.25rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo:hover {
  color: var(--accent);
}

.tagline {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.footer {
  margin-top: auto;
  padding-top: 2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.h-page {
  font-size: 1.2rem;
  margin: 0;
  line-height: 1.25;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.75rem 0 0.75rem;
  color: var(--muted);
}

.h-tight {
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.panel--compact {
  padding: 0.85rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
}

.panel--votes {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel--compact label {
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.panel--compact input[type="text"] {
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 156, 240, 0.2);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.5rem 0 1rem;
}

.hint--inline {
  margin: 0 0 0.65rem;
}

.hint--edit {
  margin: 0 0 0.5rem;
  color: var(--success);
  font-size: 0.78rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
}

.btn-block {
  width: 100%;
}

.btn-compact {
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  margin-top: 0.65rem;
}

.btn-icon {
  padding: 0.45rem;
  min-width: 2.25rem;
  border-radius: 8px;
}

.btn-icon svg {
  display: block;
}

.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.share-box {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
  margin-top: 0.75rem;
}

.share-box input {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
  font-size: 0.85rem;
}

.ranking-page {
  width: 100%;
}

.ranking-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.ranking-head__title {
  min-width: 0;
  flex: 1;
}

.ranking-meta {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.share-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.share-tools__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.15rem;
}

.share-url-reveal {
  margin: 0 0 0.75rem;
}

.share-url-reveal[hidden] {
  display: none !important;
}

.share-url-input {
  width: 100%;
  font-size: 0.78rem;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0;
}

.ranking-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.ranking-col--results {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.creator-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  margin: -0.25rem -0.25rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.creator-strip__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.creator-strip .btn-danger {
  margin: 0;
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
}

.ranking-footer {
  margin: 0.85rem 0 0;
}

.link-home {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
}

.link-home:hover {
  text-decoration: underline;
}

.vote-tabs-hint {
  margin: 0 0 0.5rem !important;
  font-size: 0.75rem !important;
}

.vote-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.65rem;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.vote-tab {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  max-width: 100%;
}

.vote-tab:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.vote-tab[aria-selected="true"] {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 156, 240, 0.25);
}

.vote-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vote-tabpanel {
  margin-top: 0.25rem;
}

.vote-tabpanel[hidden] {
  display: none !important;
}

.vote-card--tab {
  margin-bottom: 0;
}

.vote-order-list {
  margin: 0.4rem 0 0;
  padding-left: 1.35rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.vote-order-list li {
  padding: 0.1rem 0;
}

.vote-card--compact {
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.45rem;
}

.vote-card--compact:last-child {
  margin-bottom: 0;
}

.vote-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.vote-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.vote-card__head .btn {
  flex-shrink: 0;
  margin: 0;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.vote-card--compact .vote-order {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  padding-left: 1rem;
}

.empty-hint--tight {
  padding: 0.75rem 0.5rem;
  font-size: 0.85rem;
  margin: 0;
}

/* Drag & Drop: leere Plätze + Pool */
.dnd-workspace {
  margin-top: 0.35rem;
}

.dnd-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.dnd-subtitle {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.rank-slots-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(52vh, 440px);
  overflow-y: auto;
  padding-right: 0.2rem;
}

.rank-slot {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  min-height: 2.5rem;
}

.rank-slot-num {
  flex: 0 0 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.45rem;
}

.rank-slot-inner {
  flex: 1;
  min-height: 2.45rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  padding: 0.25rem 0.4rem;
  transition: border-color 0.15s, background 0.15s;
}

.rank-slot-inner[data-empty="true"] {
  justify-content: center;
}

.rank-slot-inner[data-empty="true"]::before {
  content: "Hier ablegen";
  font-size: 0.72rem;
  color: var(--muted);
  pointer-events: none;
}

.rank-slot-inner[data-empty="false"]::before {
  display: none;
}

.rank-slot-inner.is-drag-over {
  border-color: var(--accent);
  background: rgba(61, 156, 240, 0.12);
}

.chip-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-content: flex-start;
  min-height: 3rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  max-height: min(40vh, 280px);
  overflow-y: auto;
}

.chip-pool.is-drag-over {
  border-color: var(--accent);
  background: rgba(61, 156, 240, 0.08);
}

.rank-chip {
  display: inline-block;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  max-width: 100%;
  word-break: break-word;
}

.rank-chip:active {
  cursor: grabbing;
}

.rank-chip--dragging {
  opacity: 0.55;
}

@media (max-width: 640px) {
  .dnd-grid {
    grid-template-columns: 1fr;
  }

  .dnd-pool-col {
    order: 1;
  }

  .dnd-slots-col {
    order: 2;
  }
}

.sortable-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sortable-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.sortable-item:active {
  cursor: grabbing;
}

.sortable-item.sortable-ghost {
  opacity: 0.45;
}

.sortable-item .rank-num {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.sortable-item .label {
  flex: 1;
}

.stats-bar {
  margin-top: 0.35rem;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.35s ease;
}

.stat-row {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.stat-name {
  font-weight: 500;
}

.stat-meta {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.vote-card {
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.vote-card strong {
  color: var(--accent);
  font-weight: 600;
}

.vote-order {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.empty-hint {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .ranking-col--results {
    order: 2;
  }

  .ranking-col--vote {
    order: 1;
  }
}

@media (max-width: 480px) {
  .share-box {
    flex-direction: column;
  }

  .share-box input {
    min-width: 100%;
  }

  .ranking-head {
    flex-direction: column;
    align-items: stretch;
  }

  .share-tools {
    align-self: flex-end;
  }
}

/* Startseite: Ranking-Liste */
.home-page {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.home-rankings-hint {
  margin: 0 0 0.65rem !important;
}

.rankings-table-wrap {
  overflow-x: auto;
  margin-top: 0.35rem;
}

.rankings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.rankings-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.4rem 0.5rem 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.rankings-table td {
  padding: 0.45rem 0.5rem 0.45rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.rankings-table tr:last-child td {
  border-bottom: none;
}

.rankings-title a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.rankings-title a:hover {
  text-decoration: underline;
}

.rankings-num {
  text-align: center;
  width: 6rem;
  color: var(--muted);
}

.rankings-date {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.rankings-actions {
  text-align: right;
  width: 6.5rem;
}

.rankings-empty {
  text-align: center;
  color: var(--muted);
  padding: 1rem !important;
  font-size: 0.9rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-box {
  width: 100%;
  max-width: 400px;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.app:has(main.view-home) {
  max-width: 920px;
}
