:root { --pico-font-size: 95%; }
main.container { padding-top: 0.5rem; }
.brand { text-decoration: none; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: 1em; background: var(--pico-primary); color: var(--pico-primary-inverse); font-size: 0.75em; text-align: center; vertical-align: middle; }
.muted { color: var(--pico-muted-color); }
.small { font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.error { border-left: 4px solid #d33; }
.notice { padding: 0.75rem 1rem; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

/* Suchergebnisse */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.card { display: flex; flex-direction: column; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); overflow: hidden; text-decoration: none; color: inherit; background: var(--pico-card-background-color); }
.card:hover { border-color: var(--pico-primary); }
.poster { aspect-ratio: 2 / 3; background: var(--pico-muted-border-color); }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--pico-muted-color); }
.card-body { padding: 0.6rem 0.75rem 0.75rem; }
.card-body .desc { font-size: 0.8em; color: var(--pico-muted-color); margin: 0.4rem 0 0; }
.tags { margin-top: 0.25rem; }
.tag { display: inline-block; font-size: 0.72em; padding: 0.05em 0.5em; border-radius: 0.6em; background: var(--pico-muted-border-color); margin-right: 0.3em; vertical-align: middle; }
.tag-series { background: #2b6cb0; color: #fff; }
.tag-ok { background: #2f855a; color: #fff; }
.tag-off { background: #7a7a7a; color: #fff; }
.tag-done { background: #2f855a; color: #fff; }
.tag-failed { background: #c53030; color: #fff; }
.tag-cancelled { background: #7a7a7a; color: #fff; }

/* Detailseite */
.title-head { display: grid; grid-template-columns: 200px 1fr; gap: 1.5rem; }
.title-poster img { width: 100%; border-radius: var(--pico-border-radius); }
@media (max-width: 640px) { .title-head { grid-template-columns: 1fr; } .title-poster { max-width: 200px; } }
.desc-full { font-size: 0.95em; }
.prefs { margin-bottom: 0.5rem; }
.episodes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.episodes .episode { width: auto; padding: 0.35rem 0.8rem; margin: 0; }
.episodes .ep-done { border-color: #2f855a; color: #2f855a; }
.episodes .ep-pending { border-color: #b7791f; color: #b7791f; }
.outcomes { margin: 0; padding-left: 1.2rem; }
.outcome-queued { color: #2f855a; }
.outcome-duplicate, .outcome-exists { color: #b7791f; }
.outcome-unsupported, .outcome-error { color: #c53030; }
button.small { padding: 0.25rem 0.7rem; font-size: 0.8em; width: auto; margin: 0; }

/* Warteschlange */
.jobs { display: flex; flex-direction: column; gap: 0.75rem; }
.job { padding: 0.75rem 1rem; margin: 0; }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.4rem; }
.job progress { margin-bottom: 0.3rem; }
.job-stats { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.path { font-family: var(--pico-font-family-monospace); font-size: 0.8em; word-break: break-all; }
progress.indeterminate { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }

/* Verlauf */
.table-wrap { overflow-x: auto; }
.actions button { margin-right: 0.3rem; margin-bottom: 0.2rem; }
.error-text { color: #c53030; }
.pager { display: flex; gap: 1rem; align-items: center; margin-top: 0.5rem; }
.filter { max-width: 260px; }


/* Einzelseiten-Layout */
html { scroll-behavior: smooth; }
header.container { position: sticky; top: 0; z-index: 20; background: var(--pico-background-color); border-bottom: 1px solid var(--pico-muted-border-color); }
section { margin-bottom: 2.75rem; scroll-margin-top: 4.5rem; }
#downloads, #verlauf { border-top: 1px solid var(--pico-muted-border-color); padding-top: 1rem; }
.section-head { margin-bottom: 0.75rem; }
.section-head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head-row .filter { margin: 0; }
.section-head-row .filter select { margin: 0; }
.detail-panel:not(:empty) { margin: 1.25rem 0 1.75rem; padding: 1.25rem; border: 1px solid var(--pico-primary); border-radius: var(--pico-border-radius); background: var(--pico-card-background-color); }
.detail-panel .title-head { margin-top: 0; }
.detail-close { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.detail-close button { margin: 0; }


/* ============ Mobile (<= 640px) ============ */
@media (max-width: 640px) {
  :root { --pico-font-size: 100%; }
  main.container { padding-top: 0.75rem; }

  /* Kopfzeile kompakt, ohne Umbruch */
  header.container nav { gap: 0.25rem; }
  header.container .brand strong { font-size: 0.95rem; }
  header.container nav ul:last-child { gap: 0; }
  header.container nav ul:last-child li { padding-inline: 0.35rem; }
  header.container nav a { font-size: 0.9rem; }
  section { scroll-margin-top: 4rem; }

  /* Suchergebnisse: zwei Spalten, kompakter */
  .grid-cards { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .card-body { padding: 0.5rem 0.6rem 0.6rem; }
  .card-body .desc { display: none; }

  /* Detail-Panel */
  .detail-panel:not(:empty) { padding: 1rem; }
  .prefs .grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .episodes .episode { min-height: 2.4rem; }

  /* Download-Karte: Kopf stapeln, Abbrechen volle Breite */
  .job-head { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .job-head > button { width: 100%; min-height: 2.4rem; }
  .job-stats { gap: 0.2rem 1rem; }

  /* Verlauf: Tabelle -> Karten */
  .history-table thead { display: none; }
  .history-table, .history-table tbody, .history-table tr, .history-table td { display: block; width: 100%; }
  .history-table tr { border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); padding: 0.6rem 0.85rem; margin-bottom: 0.75rem; }
  .history-table td { border: none !important; padding: 0.18rem 0; }
  .history-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--pico-muted-color); margin-right: 0.4rem; }
  .history-table td.path { word-break: break-all; }
  .history-table .cell-title { font-size: 1.05em; }
  .history-table td.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; padding-top: 0.5rem; border-top: 1px dashed var(--pico-muted-border-color) !important; }
  .history-table td.actions::before { flex-basis: 100%; margin-bottom: 0.1rem; }
  .history-table td.actions button { flex: 1 1 auto; min-height: 2.4rem; margin: 0; }
}


/* Login */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 24rem; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 0.2rem; }
.login-card button { width: 100%; }
