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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #e1e1e1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgb(70, 120, 220) url('assets/bg.jpg') no-repeat center center;
}

/* Password gate */
.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
}

.gate h1 { font-size: 24px; color: #fff; }
.gate p { font-size: 14px; color: #717171; }

.gate-form {
  display: flex;
  gap: 8px;
}

.gate-form input {
  padding: 10px 16px;
  border: 1px solid #383838;
  border-radius: 8px;
  background: #181818;
  color: #e1e1e1;
  font-size: 14px;
  width: 240px;
  outline: none;
}

.gate-form input:focus { border-color: #cc0000; }

.gate-form button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: #cc0000;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.gate-form button:hover { background: #e00; }

.gate-error {
  color: #ff6666;
  font-size: 13px;
  min-height: 20px;
}

.app {
  display: none;
  width: 85vw;
  height: 85vh;
  margin: auto;
  background: rgb(0, 75, 225);
  border-radius: 4px;
  border: 3px solid rgb(0, 75, 225);
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
}
.app.visible { display: flex; flex-direction: column; align-items: center; }

header {
  width: 100%;
  padding: 6px 4px;
  background: rgb(0, 75, 225);
  display: flex;
  align-items: center;
  gap: 8px;
}

header .header-icon {
  width: 24px;
  height: 24px;
}

header h1 { font-size: 18px; font-weight: 600; color: #fff; }

header .badge {
  font-size: 12px;
  background: rgb(39,133,249);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

header .cache-badge {
  font-size: 11px;
  background: #2a5d2a;
  color: #8f8;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

header .cache-badge:hover { background: #3a7a3a; }

header .refresh-btn {
  font-size: 11px;
  background: #333;
  color: #aaa;
  border: 1px solid #444;
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
}

header .refresh-btn:hover { background: #444; color: #fff; }
header .refresh-btn.spinning { animation: spin 0.8s linear infinite; }

/* Alert banner */
.alert-banner {
  width: 100%;
  padding: 10px 24px;
  background: #4a1a1a;
  border-bottom: 1px solid #6a2a2a;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #ffaaaa;
}

.alert-banner .icon { font-size: 16px; }

.alert-banner .dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: #ffaaaa;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.main {
  width: 100%;
  display: flex;
  flex: 1;
  min-height: 0;
  background: rgb(50,60,101);
}

.player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgb(30,35,56);;
  border-right: 2px solid rgb(102,102,102);
}

.player-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  overflow: hidden;
  background: #333;
}

.player-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

#loading-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 10;
  gap: 16px;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid #333;
  border-top-color: #cc0000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay p { color: #aaa; font-size: 14px; }

.now-playing { padding: 12px; background: rgb(30,35,56); }
.now-playing h2 { font-size: 16px; font-weight: 600; color: #fff; line-height: 1.4; }
.now-playing .play-count { color: #555; font-weight: 400; }
.now-playing .meta { font-size: 13px; color: #aaa; margin-top: 4px; }

.controls {
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.controls button {
  padding: 8px 16px;
  border: 1px solid rgb(114,127,142);
  border-radius: 20px;
  background: linear-gradient(rgb(250,252,254), rgb(190,204,230));
  color: rgb(58,98,134);
  box-shadow: rgba(0, 0, 0, 0.3);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls button:hover { background: linear-gradient(rgb(190,204,230), rgb(250,252,254)); }
.controls button.active { background: #cc0000; border-color: #cc0000; color: #fff; }

/* Player details */
.player-details {
  background: linear-gradient(rgb(250,252,254), rgb(190,204,230));
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Anime info card */
.anime-info {
  padding: 16px;
  display: none;
  gap: 16px;
  margin-top: 4px;
  height: 220px;
  border-bottom: 2px solid rgb(102,102,102);
}

.anime-info.visible { display: flex; }

.anime-info .anime-cover {
  width: 100px;
  height: 142px;
  border-radius: 8px;
  object-fit: cover;
  background: #272727;
  flex-shrink: 0;
}

.anime-info .anime-details { flex: 1; min-width: 0; }

.anime-info .anime-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.anime-info .anime-title-jp {
  font-size: 12px;
  color: #717171;
  margin-bottom: 8px;
}

.anime-info .anime-meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.anime-info .anime-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #272727;
  color: #ccc;
}

.anime-info .anime-tag.score { background: #1a3a1a; color: #8f8; font-weight: 600; }
.anime-info .anime-tag.year { background: #1a2a3a; color: #8af; }

.anime-info .anime-synopsis {
  font-size: 13px;
  color: #aaa;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.anime-info .wrong-match {
  font-size: 11px;
  color: #555;
  cursor: pointer;
  margin-top: 8px;
  margin-left: 12px;
  background: none;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 2px 8px;
}

.anime-info .wrong-match:hover { color: #ff6666; border-color: #ff6666; }

.correction-form {
  display: none;
  margin-top: 8px;
  padding: 12px;
  background: #222;
  border-radius: 8px;
  gap: 8px;
}

.correction-form.visible { display: flex; flex-direction: column; }

.correction-form .form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.correction-form input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #383838;
  border-radius: 6px;
  background: #181818;
  color: #e1e1e1;
  font-size: 13px;
  outline: none;
}

.correction-form input:focus { border-color: #cc0000; }

.correction-form .type-toggle {
  display: flex;
  border: 1px solid #383838;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.correction-form .type-toggle button {
  padding: 5px 12px;
  border: none;
  background: #181818;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
}

.correction-form .type-toggle button.active {
  background: #cc0000;
  color: #fff;
}

.correction-form .form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.correction-form .form-actions button {
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.correction-form .btn-save { background: #cc0000; color: #fff; }
.correction-form .btn-save:hover { background: #e00; }
.correction-form .btn-cancel { background: #333; color: #aaa; }
.correction-form .btn-cancel:hover { background: #444; }

/* Right section */
.right-section {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
}

/* Queue */
.queue-section {
  overflow: hidden;
  max-height: calc(100vh - 100px);
}

.queue-header {
  padding: 12px 16px;
  border-bottom: 1px solid #272727;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.queue-header h3 { font-size: 14px; font-weight: 600; }
.queue-header span { font-size: 12px; color: #aaa; }

.queue-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
  height: 100%;
}

.queue-item {
  display: flex;
  gap: 10px;
  padding: 8px 0px;
  cursor: pointer;
  transition: background 0.15s;
  align-items: center;
  border-top: 1px solid rgb(30,35,56);
}

.queue-item:hover { background: rgb(30,35,56); }
.queue-item.active { background: rgb(30,35,56); }

.queue-item .index {
  font-size: 12px;
  color: #aaa;
  min-width: 24px;
  text-align: right;
}

.queue-item.active .index { color: #cc0000; font-weight: 700; }

.queue-item .thumb {
  width: 64px; height: 36px;
  border-radius: 4px;
  object-fit: cover;
  background: #272727;
  flex-shrink: 0;
}

.queue-item .info { flex: 1; min-width: 0; }

.queue-item .info .title {
  font-size: 13px;
  color: #e1e1e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.queue-item.active .info .title { color: #fff; font-weight: 500; }

.queue-item .play-count-badge {
  font-size: 11px;
  color: #AAA;
}

.queue-item .play-count-badge.empty { color: #333; display: none; }

.queue-item .info .channel {
  font-size: 11px;
  color: #717171;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* History */
.history-section {
  display: none;
  width: 100%;
  max-width: 1200px;
  padding: 12px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-header h3 { font-size: 14px; font-weight: 600; color: #aaa; }

.history-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #383838 transparent;
}

.history-item { flex-shrink: 0; cursor: pointer; width: 160px; }

.history-item .thumb {
  width: 160px; height: 90px;
  border-radius: 8px;
  object-fit: cover;
  background: #272727;
}

.history-item .title {
  font-size: 12px;
  color: #aaa;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 800px) {
  .main { flex-direction: column; }
  .queue-section { width: 100%; max-height: 300px; }
  .anime-info .anime-cover { width: 80px; height: 113px; }
}
