* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f0f0f; color: #e1e1e1; min-height: 100vh; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 20px; }

/* Header */
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.header h1 { font-size: 22px; font-weight: 600; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid #272727; }
.tab { padding: 12px 28px; font-size: 15px; font-weight: 500; cursor: pointer; color: #888; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; user-select: none; }
.tab:hover { color: #ccc; }
.tab.active { color: #ff4444; border-bottom-color: #ff4444; }

/* Tab Content */
.tab-content { display: none; padding: 28px 0; }
.tab-content.active { display: block; }

/* Input Row */
.input-row { display: flex; gap: 12px; }
.input-row input {
  flex: 1; padding: 14px 18px; border-radius: 10px; border: 1px solid #333;
  background: #1a1a1a; color: #e1e1e1; font-size: 15px; outline: none; transition: border-color 0.2s;
}
.input-row input:focus { border-color: #ff4444; }
.input-row input::placeholder { color: #666; }

.btn-primary {
  padding: 14px 28px; border-radius: 10px; border: none; background: #ff4444;
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.btn-primary:hover { background: #e03030; }
.btn-primary:disabled { background: #555; cursor: not-allowed; }

/* Channel Options */
.channel-options { display: flex; gap: 16px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.channel-options label { font-size: 14px; color: #999; }
.channel-options select {
  padding: 8px 12px; border-radius: 8px; border: 1px solid #333;
  background: #1a1a1a; color: #e1e1e1; font-size: 14px; outline: none; cursor: pointer;
}
.channel-options select:focus { border-color: #ff4444; }

/* Channel Loading */
.channel-loading {
  display: flex; align-items: center; gap: 12px; margin-top: 24px;
  padding: 20px; background: #1a1a1a; border-radius: 12px; border: 1px solid #272727;
  font-size: 14px; color: #999;
}
.spinner {
  width: 24px; height: 24px; border: 3px solid #333; border-top-color: #ff4444;
  border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Video List */
.video-list-wrap { margin-top: 20px; display: none; }
.video-list-wrap.show { display: block; }
.video-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.video-list-header span { font-size: 14px; color: #999; }
.video-list {
  background: #1a1a1a; border-radius: 12px; border: 1px solid #272727;
  overflow: hidden; max-height: 450px; overflow-y: auto;
}
.video-list::-webkit-scrollbar { width: 6px; }
.video-list::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

.video-item {
  display: flex; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid #222; gap: 12px; transition: background 0.15s; cursor: pointer;
}
.video-item:last-child { border-bottom: none; }
.video-item:hover { background: #222; }
.video-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: #ff4444; cursor: pointer; flex-shrink: 0; }
.video-item .thumb {
  width: 120px; height: 68px; border-radius: 6px; background: #333;
  flex-shrink: 0; object-fit: cover;
}
.video-item .info { flex: 1; min-width: 0; }
.video-item .info .title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-item .info .meta { font-size: 12px; color: #888; margin-top: 4px; }

.video-list-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn-sm {
  padding: 8px 16px; border-radius: 8px; border: 1px solid #333;
  background: transparent; color: #ccc; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.btn-sm:hover { border-color: #ff4444; color: #ff4444; }
.selected-count { font-size: 13px; color: #888; }
.btn-batch {
  padding: 10px 24px; border-radius: 8px; border: none; background: #ff4444;
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; margin-left: auto; transition: background 0.2s;
}
.btn-batch:hover { background: #e03030; }

/* Divider */
.divider { height: 1px; background: #272727; margin: 32px 0; }

/* Task Section */
.task-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.task-header h2 { font-size: 17px; font-weight: 600; }
.btn-clear {
  padding: 6px 14px; border-radius: 6px; border: 1px solid #333;
  background: transparent; color: #888; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.btn-clear:hover { border-color: #666; color: #ccc; }

/* Task List */
.task-list { display: flex; flex-direction: column; gap: 10px; }

/* Task Group */
.task-group {
  background: #1a1a1a; border-radius: 12px; border: 1px solid #272727; overflow: hidden;
}
.task-group-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  background: #1e1e1e; cursor: pointer; user-select: none;
}
.task-group-header:hover { background: #242424; }
.task-group-header .folder-icon { font-size: 16px; }
.task-group-header .group-title { font-size: 14px; font-weight: 600; flex: 1; }
.task-group-header .group-progress { font-size: 13px; color: #888; }
.task-group-header .chevron { font-size: 12px; color: #666; transition: transform 0.2s; }
.task-group.expanded .chevron { transform: rotate(90deg); }
.task-group-body { display: none; }
.task-group.expanded .task-group-body { display: block; }
.task-group-body .task-card { border-radius: 0; border: none; border-top: 1px solid #222; background: #1a1a1a; }

/* Task Card */
.task-card {
  background: #1a1a1a; border-radius: 12px; border: 1px solid #272727; padding: 16px 18px;
}
.task-top { display: flex; align-items: flex-start; gap: 12px; }
.task-status-dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}
.task-status-dot.completed { background: #4caf50; }
.task-status-dot.downloading { background: #2196f3; }
.task-status-dot.translating { background: #ff9800; }
.task-status-dot.failed { background: #f44336; }
.task-status-dot.queued { background: #666; }

.task-info { flex: 1; min-width: 0; }
.task-title-zh {
  font-size: 15px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.task-title-en {
  font-size: 12px; color: #888; margin-top: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.task-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-icon {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid #333;
  background: transparent; color: #999; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-icon:hover { border-color: #ff4444; color: #ff4444; }
.btn-icon.play { border-color: #4caf50; color: #4caf50; }
.btn-icon.play:hover { background: #4caf50; color: #fff; }
.btn-icon.retry { border-color: #ff9800; color: #ff9800; }
.btn-icon.retry:hover { background: #ff9800; color: #fff; }

.task-bottom { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.task-status-text { font-size: 13px; color: #999; white-space: nowrap; min-width: 90px; }
.progress-bar { flex: 1; height: 6px; background: #272727; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.progress-fill.completed { background: #4caf50; }
.progress-fill.downloading { background: #2196f3; }
.progress-fill.translating { background: #ff9800; }
.progress-fill.failed { background: #f44336; }
.progress-fill.queued { background: #444; }
.task-percent { font-size: 13px; color: #999; white-space: nowrap; min-width: 40px; text-align: right; }

/* Error text */
.task-error { font-size: 12px; color: #f44336; margin-top: 6px; word-break: break-all; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; color: #555; }
.empty-state p { font-size: 15px; margin-top: 12px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 14px 22px;
  background: #333; color: #fff; border-radius: 10px; font-size: 14px;
  z-index: 9999; opacity: 0; transform: translateY(20px);
  transition: all 0.3s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b71c1c; }
.toast.success { background: #2e7d32; }

/* Settings button */
.btn-settings {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid #333;
  background: transparent; color: #888; font-size: 20px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-settings:hover { border-color: #ff4444; color: #ff4444; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #1a1a1a; border-radius: 16px; border: 1px solid #333;
  width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid #272727;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border: none; background: transparent;
  color: #888; font-size: 22px; cursor: pointer; border-radius: 8px; transition: all 0.2s;
}
.modal-close:hover { background: #333; color: #fff; }
.modal-body { padding: 20px 24px; }
.cookie-desc { font-size: 13px; color: #999; line-height: 1.6; margin-bottom: 12px; }
.cookie-desc strong { color: #ccc; }
.cookie-status {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}
.cookie-status.ok { background: #1b3a1b; color: #4caf50; border: 1px solid #2e7d32; display: flex; align-items: center; gap: 8px; }
.cookie-status.no { background: #3a1b1b; color: #f44336; border: 1px solid #b71c1c; display: flex; align-items: center; gap: 8px; }
.cookie-status.warn { background: #3a351b; color: #ff9800; border: 1px solid #e65100; }
.cookie-status.checking { background: #1b2a3a; color: #64b5f6; border: 1px solid #1565c0; display: flex; align-items: center; gap: 8px; }

/* Cookie status dots */
.cookie-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.cookie-dot.green { background: #4caf50; box-shadow: 0 0 6px #4caf50; }
.cookie-dot.red { background: #f44336; box-shadow: 0 0 6px #f44336; animation: pulse-red 2s infinite; }
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 4px #f44336; }
  50% { box-shadow: 0 0 12px #f44336; }
}

/* Cookie checking spinner */
.cookie-spinner {
  width: 14px; height: 14px; border: 2px solid #1565c0; border-top-color: #64b5f6;
  border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; flex-shrink: 0;
}

/* Header cookie badge */
.header-cookie-badge {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px;
  border-radius: 20px; font-size: 12px; font-weight: 500; margin-left: auto; margin-right: 8px;
  transition: all 0.3s;
}
.header-cookie-badge.ok { background: #1b3a1b; color: #4caf50; border: 1px solid #2e7d32; }
.header-cookie-badge.bad { background: #3a1b1b; color: #f44336; border: 1px solid #b71c1c; }
.header-cookie-badge.no { background: #2a2a2a; color: #888; border: 1px solid #444; }

/* Setting sections */
.setting-section { margin-bottom: 20px; }
.setting-label { font-size: 14px; font-weight: 600; color: #ccc; margin-bottom: 10px; display: block; }
.setting-input {
  width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid #333;
  background: #0f0f0f; color: #e1e1e1; font-size: 14px; outline: none;
}
.setting-input:focus { border-color: #ff4444; }

/* Method cards */
.method-cards { display: flex; gap: 10px; }
.method-card {
  flex: 1; padding: 14px 16px; border-radius: 10px; border: 2px solid #333;
  background: #141414; cursor: pointer; transition: all 0.2s; display: flex; align-items: flex-start; gap: 10px;
}
.method-card:hover { border-color: #555; }
.method-card input[type="radio"] { accent-color: #ff4444; margin-top: 3px; flex-shrink: 0; }
.method-card.selected { border-color: #ff4444; background: #1a1215; }
.method-content { display: flex; flex-direction: column; gap: 4px; }
.method-content strong { font-size: 14px; color: #e1e1e1; }
.method-content span { font-size: 12px; color: #888; }

/* Device code display */
.device-code {
  padding: 16px; text-align: center; font-size: 28px; font-weight: 700; letter-spacing: 4px;
  color: #ff4444; background: #1a1215; border: 2px solid #ff4444; border-radius: 10px;
  font-family: monospace; margin: 12px 0;
}

#cookies-input {
  width: 100%; height: 100px; padding: 12px; border-radius: 10px; border: 1px solid #333;
  background: #0f0f0f; color: #e1e1e1; font-size: 12px; font-family: monospace;
  resize: vertical; outline: none;
}
#cookies-input:focus { border-color: #ff4444; }
.modal-actions {
  display: flex; justify-content: space-between; align-items: center; margin-top: 12px;
}

/* Tutorial button */
.btn-tutorial {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid #333;
  background: transparent; color: #888; font-size: 20px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-tutorial:hover { border-color: #64b5f6; color: #64b5f6; }

/* Tutorial modal wider */
.modal-wide { max-width: 700px; }

/* Tutorial body */
.tutorial-body { padding-bottom: 32px !important; }
.tutorial-intro { margin-bottom: 24px; }
.tutorial-intro p { font-size: 14px; color: #bbb; line-height: 1.7; }

/* Tutorial step */
.tutorial-step {
  display: flex; gap: 16px; margin-bottom: 24px;
  padding: 18px; background: #141414; border-radius: 12px; border: 1px solid #272727;
}
.step-number {
  width: 36px; height: 36px; border-radius: 50%; background: #ff4444; color: #fff;
  font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step-content { flex: 1; min-width: 0; }
.step-content h4 { font-size: 15px; font-weight: 600; color: #e1e1e1; margin-bottom: 8px; }
.step-content p { font-size: 13px; color: #999; line-height: 1.6; margin-bottom: 8px; }
.step-content p:last-child { margin-bottom: 0; }

/* Step links */
.step-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.step-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  text-decoration: none; transition: all 0.2s;
}
.step-link.chrome { background: #1a2a1a; color: #66bb6a; border: 1px solid #2e7d32; }
.step-link.chrome:hover { background: #2e7d32; color: #fff; }
.step-link.firefox { background: #2a1a1a; color: #ff9800; border: 1px solid #e65100; }
.step-link.firefox:hover { background: #e65100; color: #fff; }

/* Step detail & shortcuts */
.step-detail { margin-top: 10px; }
.shortcut-box {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: #bbb;
}
.shortcut-label { color: #888; min-width: 120px; }
kbd {
  display: inline-block; padding: 3px 8px; border-radius: 5px;
  background: #222; border: 1px solid #444; color: #e1e1e1;
  font-family: monospace; font-size: 12px; line-height: 1.4;
}

/* Step list */
.step-list {
  margin: 8px 0 0 0; padding-left: 20px; font-size: 13px; color: #bbb; line-height: 2;
}
.step-list li { margin-bottom: 2px; }
.step-list code {
  padding: 2px 6px; border-radius: 4px; background: #222; color: #64b5f6;
  font-family: monospace; font-size: 12px;
}
.step-list a { color: #64b5f6; text-decoration: none; }
.step-list a:hover { text-decoration: underline; }

/* Step tip */
.step-tip { font-size: 12px !important; color: #777 !important; margin-top: 6px; }

/* Tutorial notes */
.tutorial-notes {
  margin-top: 28px; padding: 18px; background: #1a1a0f; border-radius: 12px;
  border: 1px solid #3a351b;
}
.tutorial-notes h4 { font-size: 14px; font-weight: 600; color: #ff9800; margin-bottom: 12px; }
.tutorial-notes ul { padding-left: 18px; font-size: 13px; color: #bbb; line-height: 1.8; }
.tutorial-notes li { margin-bottom: 6px; }
.tutorial-notes strong { color: #ddd; }

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 16px 12px; }
  .header h1 { font-size: 18px; }
  .input-row { flex-direction: column; }
  .tab { padding: 10px 18px; font-size: 14px; }
  .video-item .thumb { width: 90px; height: 51px; }
  .channel-options { flex-direction: column; align-items: flex-start; }
  .video-list-actions { flex-direction: column; align-items: stretch; }
  .btn-batch { margin-left: 0; }
}
