:root {
  --bg: #0f1115; --card: #181b22; --line: #2a2f3a; --text: #e8eaf0; --muted: #8b93a5;
  --accent: #ff6b35; --ok: #2ecc71;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
h1 { font-size: 20px; margin: 0; }
nav { display: flex; gap: 6px; margin-right: auto; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 7px 14px; border-radius: 8px; }
button:hover { border-color: var(--muted); }
nav button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ghost { background: transparent; }
.badge { background: rgba(255,255,255,.18); border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 20px 0; }
.toolbar input { flex: 1 1 280px; }
input, select { font: inherit; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.status { color: var(--muted); padding: 0 20px; margin: 12px 0 0; min-height: 22px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; padding: 14px 20px 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; }
.card:hover { border-color: var(--muted); }
.poster { aspect-ratio: 2/3; width: 100%; object-fit: cover; background: #222733; display: block; }
.noposter { display: flex; align-items: center; justify-content: center; font-size: 40px; }
.card .body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-weight: 600; line-height: 1.25; }
.meta { color: var(--muted); font-size: 13px; }
.rating { color: #f5c518; font-weight: 600; }
.genres { color: var(--muted); font-size: 12px; }
.card button, .modal-actions button { margin-top: auto; width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.card button.in, .modal-actions button.in { background: transparent; color: var(--ok); border-color: var(--ok); }
.card button.in:hover, .modal-actions button.in:hover { color: #ff5c5c; border-color: #ff5c5c; }
.more { text-align: center; padding-bottom: 30px; }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(760px, 94vw); max-height: 90vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.7); }
.modal { display: flex; gap: 20px; padding: 20px; }
.modal img, .modal .noposter { width: 220px; flex-shrink: 0; border-radius: 10px; align-self: flex-start; aspect-ratio: 2/3; object-fit: cover; background: #222733; }
.modal h2 { margin: 0 0 2px; }
.modal .tagline { color: var(--muted); font-style: italic; margin: 0 0 10px; }
.modal p { margin: 8px 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.close { position: sticky; top: 0; float: right; margin: 10px; width: 34px; height: 34px; padding: 0; border-radius: 50%; }
@media (max-width: 560px) { .modal { flex-direction: column; } .modal img, .modal .noposter { width: 160px; } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2a2f3a; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.5); display: flex; gap: 14px; align-items: center; z-index: 10; }
.toast[hidden] { display: none; }
.toast button { padding: 3px 10px; }
