:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #3b82f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.header {
  padding: 16px 24px;
  border-bottom: 1px solid #374151;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.version {
  color: var(--muted);
  font-size: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-right a.secondary-btn {
  text-decoration: none;
  color: var(--text);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #4b5563;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
  overflow-x: hidden;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.title-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.secondary-btn {
  background: #374151;
  border: 1px solid #4b5563;
}

.cookie-badge {
  display: inline-block;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.cookie-ok {
  color: #86efac;
  border-color: #166534;
  background: #052e16;
}

.cookie-ng {
  color: #fca5a5;
  border-color: #7f1d1d;
  background: #450a0a;
}

.cookie-unknown {
  color: #d1d5db;
  border-color: #6b7280;
  background: #111827;
}

.cookie-guide {
  margin: 10px 0 14px;
}

.cookie-command {
  white-space: pre-wrap;
  word-break: break-word;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
}

.cookie-dropzone {
  border: 2px dashed #4b5563;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  color: #d1d5db;
  background: #0f172a;
  cursor: pointer;
}

.cookie-dropzone.dragover {
  border-color: #3b82f6;
  background: #111827;
}

textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.card {
  color: var(--text);
  text-decoration: none;
}

form.panel {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

input,
select,
button {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #4b5563;
  background: #111827;
  color: var(--text);
}

button {
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.task-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.task-item {
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 10px;
  overflow: hidden;
  min-width: 0;
}

.task-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  flex-wrap: wrap;
}

.task-message {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-break: anywhere;
}

.task-current-step {
  color: var(--fg, #e5e7eb);
  font-weight: 600;
}

.task-actions {
  margin-top: 10px;
}

.user-edit-form {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed #374151;
}

.user-edit-form[hidden] {
  display: none !important;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.apps-checklist {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.apps-checkitem {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #374151;
  border-radius: 999px;
  background: #0f172a;
  cursor: pointer;
  user-select: none;
}

.apps-checkitem input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.download-btn {
  display: inline-block;
  text-decoration: none;
  color: #fff;
  background: #2563eb;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.retry-failed-btn {
  margin-left: 8px;
  background: #b45309;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.failed-urls-block {
  margin-top: 8px;
  font-size: 12px;
}
.failed-urls-details {
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 6px 10px;
  background: #1f2937;
}
.failed-urls-summary {
  cursor: pointer;
  user-select: none;
}
.failed-urls-list {
  margin: 8px 0;
  padding: 8px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
  background: #111827;
  border-radius: 4px;
}
.copy-failed-urls-btn {
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  background: #374151;
  color: #e5e7eb;
  border: 1px solid #4b5563;
  cursor: pointer;
}

.exclude-keywords-list {
  margin: 10px 0;
}
.exclude-keyword-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.exclude-keyword-text {
  flex: 1;
}
.exclude-keyword-delete {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  background: #7f1d1d;
  color: #fecaca;
  border: 1px solid #991b1b;
  cursor: pointer;
}
.exclude-keyword-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.exclude-keyword-form input {
  flex: 1;
  padding: 8px;
  border-radius: 4px;
}

@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  .panel,
  .card {
    padding: 12px;
  }

  .task-head {
    font-size: 12px;
  }

  .task-message {
    font-size: 12px;
  }

  .title-actions {
    width: 100%;
  }

  .cookie-badge,
  .secondary-btn {
    width: 100%;
  }

  .retry-failed-btn {
    margin-left: 0;
    margin-top: 8px;
    width: 100%;
  }

  .apps-checkitem {
    width: 100%;
    justify-content: center;
  }
}
