:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 { font-size: 1.25rem; font-weight: 600; }

.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.mode-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  max-width: 9rem;
}

.kino-canvas.hidden { display: none !important; }

.hidden { display: none !important; }

.kino-stage {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

.kino-stage.hidden { display: none !important; }

.kino-frame-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#kino-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.kino-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.kino-overlay .overlay-btn {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.kino-overlay .overlay-play.hidden-when-playing {
  opacity: 0;
  pointer-events: none;
}

.kino-overlay .overlay-play.show-when-paused {
  opacity: 1;
}

.icon-img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.player-controls .btn .icon-img {
  width: 24px;
  height: 24px;
}

.kino-overlay .overlay-fs {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
}

.kino-overlay .overlay-fs .icon-img {
  width: 26px;
  height: 26px;
}

.media-wrap.layout-kino {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  gap: 0;
}

.media-wrap.layout-kino .kino-stage {
  flex: 1;
  min-height: 0;
}

.media-wrap.layout-kino #audio-el {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.35rem 0.5rem 0.5rem;
  flex-shrink: 0;
  display: block !important;
  box-sizing: border-box;
}

.mode-tabs {
  display: flex;
  gap: 0.35rem;
  margin-left: 0.5rem;
}

.mode-btn {
  background: #1e293b;
  color: var(--text);
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mode-tabs-header .mode-btn {
  padding: 0.3rem 0.45rem;
  font-size: 0.7rem;
}

.kino-engine-tabs {
  margin-left: 0.5rem;
}

.kino-engine-tabs .kino-engine-btn {
  font-size: 0.7rem;
  padding: 0.3rem 0.5rem;
  min-width: 2.5rem;
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  background: var(--surface, #1e293b);
  color: inherit;
  cursor: pointer;
}

.kino-engine-tabs .kino-engine-btn.active {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
}

.kino-engine-tabs.hidden {
  display: none;
}

#video-el.hidden { display: none !important; }

#audio-el.audio-only {
  display: block;
  width: min(100%, 520px);
  margin: 0 auto;
}

.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:hover { background: #334155; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 1.25rem; }

.date-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border-bottom: 1px solid #334155;
}

.date-tab {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid #334155;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

.date-tab.active { background: var(--accent); border-color: var(--accent); }

.items-list { padding: 0.5rem; }

.item-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}

.item-card:hover { border-color: #334155; }

.item-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.item-info { flex: 1; min-width: 0; }
.item-title { font-weight: 500; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.35; }
.item-source {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}
.item-source:hover { text-decoration: underline; }

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: #334155;
  color: var(--muted);
}

.btn-redownload { margin-left: 0.25rem; padding: 0.25rem 0.5rem !important; }

.pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.pin-overlay.hidden { display: none; }

/* Hide feed behind PIN (removing overlay via DevTools still leaves empty list without API) */
body.pin-locked > :not(#pin-overlay) {
  visibility: hidden;
}

.pin-box {
  background: var(--surface);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  width: 280px;
}

.pin-box input {
  width: 100%;
  padding: 0.75rem;
  margin: 1rem 0;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  text-align: center;
}

/* Player */
.player-body { background: #000; overflow: hidden; }

.player-container {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

.media-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 0.5rem;
}

#video-el {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}

#audio-el {
  display: none;
  width: min(100%, 520px);
  margin: 0 auto;
}

#audio-el.visible {
  display: block;
}

.player-info {
  padding: 1rem 1.25rem;
  background: rgba(0,0,0,0.95);
  border-top: 1px solid #334155;
}

.player-source {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
}
.player-source:hover { text-decoration: underline; }

.player-title { font-size: 1.1rem; font-weight: 600; }
.player-meta { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.95);
  position: relative;
  z-index: 30;
  flex-shrink: 0;
}

.player-controls .btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 48px;
  min-height: 48px;
}

#player-hint {
  display: none;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.25rem 1rem 0;
}

#player-hint.visible {
  display: block;
}

.btn-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 20;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.text-item-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 23, 0.72);
  padding: 1rem;
  overflow: auto;
}
.text-item-panel.show { display: flex; align-items: flex-start; justify-content: center; }
.text-item-card {
  position: relative;
  width: min(640px, 100%);
  margin: 10vh auto;
  background: var(--card, #0f172a);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 1.25rem 1.25rem 1.5rem;
  color: inherit;
}
.text-item-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.text-item-body {
  white-space: pre-wrap;
  line-height: 1.45;
  margin: 1rem 0 1.25rem;
  font-size: 0.95rem;
}
