:root {
  --bg: #0d1014;
  --panel: #15191f;
  --panel-2: #1b2027;
  --panel-3: #232a33;
  --text: #f5f6f7;
  --muted: #a9b0b9;
  --accent: #ff9b2f;
  --accent-2: #ffb45d;
  --accent-soft: rgba(255, 155, 47, .18);
  --border: rgba(255, 155, 47, .7);
  --danger: #ff7272;
  --shadow: 0 12px 35px rgba(0, 0, 0, .42);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 155, 47, .08), transparent 25%),
    radial-gradient(circle at 90% 88%, rgba(49, 109, 133, .13), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: var(--normal-font, Arial, Helvetica, sans-serif);
  font-size: var(--normal-fontsize, 16px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.site-header {
  min-height: 82px;
  padding: 13px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, #191d22, #101317);
  box-shadow: 0 8px 25px rgba(0,0,0,.25);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark, .login-logo {
  width: 48px; height: auto; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--accent); font-weight: 900;
  border: 2px solid var(--accent); box-shadow: 0 0 18px rgba(255,155,47,.32);
  background: #11151a;
}
.brand-mark span, .login-logo span { color: var(--text); }
.brand h1 { margin: 0; font-size: clamp(20px, 2.3vw, 32px); letter-spacing: -.02em; }
.session-user { color: var(--muted); font-size: var(--small-fontsize, 12px); }

.main-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.control-panel {
  width: 305px;
  flex: 0 0 305px;
  border-right: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(20,24,30,.98), rgba(15,18,23,.98));
  overflow: auto;
}
.panel-inner { padding: 24px 22px; }
.section-caption {
  font-weight: 800; font-size: 15px; letter-spacing: .04em;
  margin: 8px 0 16px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 6px; color: #e9ebee;
  font-size: .88em; font-weight: 650;
}
.field input, .field select {
  width: 100%; min-height: 42px; border: 1px solid #606872;
  border-radius: 8px; background: #11151a; color: var(--text);
  padding: 9px 11px; outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,155,47,.12);
}
.field input[readonly] { color: #c7cbd0; background: #191d22; }

.primary-button, .secondary-button, .download-button {
  border: 0; border-radius: 8px; min-height: 42px;
  font-weight: 800; transition: transform .12s ease, filter .12s ease;
}
.primary-button {
  width: 100%; background: linear-gradient(180deg, #ffad4b, #ff8d1e);
  color: #17130f; box-shadow: 0 5px 17px rgba(255,155,47,.22);
}
.download-button {
  flex: 0 0 auto;
  padding: 0 1rem;
  background: linear-gradient(180deg, #ffad4b, #ff8d1e);
  color: #17130f;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button:hover, .secondary-button:hover, .download-button:hover { filter: brightness(1.08); }
.primary-button:active, .secondary-button:active, .download-button:active { transform: translateY(1px); }

.status-field { margin-top: 16px; }
.status {
  min-height: 38px; padding: 8px 10px; border-radius: 8px;
  background: #11151a; color: var(--muted); font-size: var(--small-fontsize, 12px);
  line-height: 1.35; border: 1px solid rgba(255,255,255,.08);
}
.history-row { display: grid; grid-template-columns: 1fr 54px; gap: 9px; align-items: end; margin-top: 22px; }
.history-field { margin: 0; }
.secondary-button { width: 54px; background: #2b323b; color: #fff; border: 1px solid #68717d; }

.results-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.results-header {
  padding: 20px 24px 15px; border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(15,18,22,.65);
}
.results-query { font-size: 1.25em; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results-count { margin-top: 4px; color: var(--muted); font-size: var(--small-fontsize, 12px); }
.results {
  flex: 1; min-height: 0; overflow: auto; padding: 18px 24px 30px;
}
.empty-results { display: grid; place-items: center; }
.empty-state { text-align: center; color: #737b85; font-size: .95em; }
.empty-icon {
  width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%;
  border: 1px solid #444c56; display: grid; place-items: center; color: var(--accent);
}

.grid-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  align-content: start;
}

/* Geöffnete Vorschau über die gesamte Trefferlistenbreite */
.grid-results .movie-card.expanded {
  grid-column: 1 / -1;
}

.movie-card {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, #1c2128, #14181d); box-shadow: 0 0 12px rgba(255,155,47,.08);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.movie-card:hover { border-color: var(--accent-2); box-shadow: 0 0 18px rgba(255,155,47,.17); }
.movie-card.expanded { border-color: var(--accent-2); }

/* Geöffneter Film ersetzt seine normale Kachel/Zeile */
.movie-card.expanded-preview,
.list-card.expanded-preview {
  width: 100%;
  box-sizing: border-box;
}

/* Im Grid nimmt die Vorschau die komplette Trefferlistenbreite ein */
.grid-results .movie-card.expanded-preview {
  grid-column: 1 / -1;
}

/* Die Vorschau selbst benötigt keinen zusätzlichen Kartenrahmen */
.expanded-preview .preview {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.thumbnail-wrap { position: relative; aspect-ratio: 16/9; background: #090b0e; overflow: hidden; }
.thumbnail-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 34px; border-radius: 9px; background: rgba(20,20,20,.86);
  display: grid; place-items: center; color: white; font-size: 18px;
}
.movie-content { padding: 10px; }
.movie-title { font-weight: 800; line-height: 1.18; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.movie-meta { margin-top: 8px; display: grid; grid-template-columns: 1fr auto; gap: 8px; color: #c3c9cf; font-size: var(--small-fontsize, 12px); }
.channel-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { text-align: right; white-space: nowrap; }

.list-results { display: flex; flex-direction: column; gap: 8px; }
.list-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 8px 10px; border: 1px solid rgba(255,255,255,.09); border-radius: 9px; background: #151a20; }
.list-card:hover { border-color: rgba(255,155,47,.6); }
.list-main { min-width: 0; }
.list-line { 
  font-family: var(--big-font, Arial, Helvetica, sans-serif);
  font-size: var(--big-fontsize, 20px);
  line-height: 1.3; 
}

/* Basis-Style für das Bild */
.list-thumb { 
  width: auto; /* Behält das Seitenverhältnis bei */
  /* aspect-ratio: 16/9; */
  object-fit: cover; /* Verhindert ein Verzerrung des Bildes */
  border-radius: 7px; 
}

/* Je nach state.output-Klasse unterschiedliche Höhen */
.list-thumb.list-small {
  height: 100px;
}

.list-thumb.list-medium {
  height: 150px;
}

.list-thumb.list-large {
  height: 200px;
}

.list-medium .list-thumb { width: 190px; }
.list-large .list-thumb { width: 280px; }

.preview {
  width: 100%;
  box-sizing: border-box;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
  cursor: default;
}

.preview-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}

.preview-text {
  width: 100%;
  box-sizing: border-box;
  padding-top: 14px;
}

.preview-title {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--normal-font);
  font-size: var(--normal-fontsize);
  font-weight: 700;
  line-height: 1.35;
}

.preview-url-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  width: 100%;
}

.preview-url-row,
.preview-likes,
.preview-duration {
  margin-top: 8px;
}

.preview-url a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.preview-url a:hover {
  color: var(--accent-2);
}

.preview-description {
  font-family: var(--normal-font);
  font-size: var(--normal-fontsize);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(4px);
}
.login-card, .info-card {
  width: min(420px, 100%); background: linear-gradient(180deg, #1c2229, #12161b);
  border: 1px solid var(--accent); border-radius: 14px; box-shadow: 0 25px 70px rgba(0,0,0,.65);
  padding: 28px;
}
.login-logo { margin: 0 auto 12px; }
.login-card h2, .info-card h2 { margin: 0; text-align: center; }
.login-subtitle { text-align: center; color: var(--muted); font-size: var(--small-fontsize, 12px); margin: 7px 0 22px; }
.password-hint { color: #9ca4ad; font-size: var(--small-fontsize, 12px); line-height: 1.4; margin: -5px 0 14px; }
.login-error { min-height: 20px; color: var(--danger); font-size: var(--small-fontsize, 12px); margin-bottom: 8px; }
.login-button { margin-top: 3px; }
.modal-close { float: right; border: 0; background: transparent; color: #cbd0d5; font-size: 28px; line-height: 1; }
.info-card { position: relative; }
.info-card h2 { text-align: left; margin-bottom: 15px; }
.info-card p { color: #cfd4d9; line-height: 1.5; }

.site-footer {
  min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 15px;
  padding: 8px 24px; background: #000; color: #aeb3b8; font-size: var(--small-fontsize, 12px);
}
.site-footer nav { display: flex; gap: 16px; }
.site-footer button { background: transparent; border: 0; color: #c9ced3; padding: 3px; }
.site-footer button:hover { color: var(--accent); }

.preview-duration {
  margin-top: 0.25rem;
}

@media (max-width: 780px) {
  .site-header { min-height: 70px; padding: 11px 15px; }
  .brand-mark { width: 40px; height: 40px; font-size: 18px; }
  .main-area { flex-direction: column; }
  .control-panel { width: 100%; flex-basis: auto; max-height: none; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.08); }
  .panel-inner { padding: 16px; }
  .section-caption { display: none; }
  .results { padding: 14px 16px 25px; }
  .results-header { padding: 14px 16px 12px; }
  .grid-results { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .preview { grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; align-items: flex-start; padding: 10px 15px; }
  .site-footer nav { flex-wrap: wrap; }
}

@media (max-width: 500px) {
  .grid-results { grid-template-columns: 1fr; }
  .list-card { grid-template-columns: 1fr; }
  .list-thumb, .list-medium .list-thumb, .list-large .list-thumb { width: 100%; }
  .movie-meta { grid-template-columns: 1fr; }
  .stats { text-align: left; }
}
