:root {
  --bg:        #0d0d0d;
  --surface:   #1c1c1c;
  --surface2:  #272727;
  --accent:    #e53935;
  --accent2:   #ff6f60;
  --text:      #f0f0f0;
  --muted:     #888;
  --focus:     2px solid #e53935;
  --r:         10px;
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 17px;
}
/* Screens */
.screen {
  display: none;
  flex-direction: column;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  padding: 0 0 24px;
}
.screen.active { display: flex; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 40px;
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-size: 24px; font-weight: 700; color: var(--accent); letter-spacing: 1px; }
.topbar h1 { font-size: 18px; font-weight: 600; flex: 1; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; }

/* Focus */
:focus { outline: none; }
.focusable:focus { outline: var(--focus); outline-offset: 3px; border-radius: 4px; }

/* Search */
.search-wrap {
  display: flex; gap: 12px;
  padding: 24px 40px;
  max-width: 900px;
}
.search-input {
  flex: 1;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--r);
  color: var(--text);
  font-size: 18px;
  padding: 14px 20px;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary:hover, .btn-primary:focus { background: var(--accent2); }

/* Back button */
.btn-back {
  background: var(--surface2);
  color: var(--text);
  border: none;
  border-radius: var(--r);
  padding: 10px 20px;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-back:hover, .btn-back:focus { background: #333; }

/* Sections */
.section { padding: 0 40px 8px; }
.section h2 { font-size: 15px; color: var(--muted); margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: .06em; }
.hidden { display: none !important; }

/* Chips (recent searches) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface2);
  border: none;
  border-radius: 20px;
  color: var(--text);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
.chip:hover, .chip:focus { background: #333; }

/* Grid (catalog / history) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  padding: 16px 40px;
}
.card {
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
}
.card:hover, .card:focus { transform: scale(1.04); box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.card:focus { border-color: var(--accent); }
.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.card-poster-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #444;
}
.card-info { padding: 10px 12px; }
.card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-year  { font-size: 12px; color: var(--muted); }

/* List (torrents / files) */
.list { padding: 8px 40px; display: flex; flex-direction: column; gap: 4px; }
.list-item {
  background: var(--surface);
  border-radius: var(--r);
  padding: 14px 20px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .12s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.list-item:hover, .list-item:focus { background: var(--surface2); }
.list-item:focus { border-color: var(--accent); }
.list-item-title { font-size: 14px; font-weight: 500;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.list-item-meta  { font-size: 12px; color: var(--muted);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.badge {
  display: inline-block;
  background: #333;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  margin-right: 4px;
}
.badge-res  { background: #1a3a5c; }
.badge-seed { background: #1a4a2a; }

/* Loading */
.loading-msg {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 48px; color: var(--muted); font-size: 15px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.global-loading {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.spinner-large {
  width: 60px; height: 60px;
  border: 4px solid #444;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Player */
.player-screen { background: #000; padding: 0; }
#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.player-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(transparent 40%, rgba(0,0,0,.85) 100%);
  transition: opacity .3s;
}
.player-overlay.hidden-overlay { opacity: 0; pointer-events: none; }
.player-title-bar {
  padding: 12px 32px;
  font-size: 15px; color: rgba(255,255,255,.8);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.player-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 24px;
}
.pctrl {
  background: rgba(255,255,255,.15);
  color: #fff; border: none; border-radius: 8px;
  padding: 12px 20px; font-size: 16px; cursor: pointer;
  min-width: 56px; text-align: center;
}
.pctrl:hover, .pctrl:focus { background: rgba(255,255,255,.3); }
.pctrl:focus { outline: var(--focus); }
.pctrl-main { font-size: 22px; padding: 12px 24px; background: var(--accent); }
.pctrl-main:hover { background: var(--accent2); }
.player-progress {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px 20px;
}
#progress-bar {
  flex: 1; height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}
#player-time, #player-duration { font-size: 14px; color: rgba(255,255,255,.7);
  min-width: 42px; text-align: center; }

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .topbar, .search-wrap, .section, .list { padding-left: 16px; padding-right: 16px; }
}
