:root {
  --bg: #0f1216;
  --card: #181d24;
  --line: #2a323d;
  --ink: #e8edf3;
  --muted: #94a3b3;
  --accent: #2d7ff9;
  --ok: #2ea043;
  --warn: #d29922;
  --bad: #e5534b;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --line: #dde3ea;
    --ink: #1a1f26;
    --muted: #5c6773;
  }
}

* {
  box-sizing: border-box;
}

/* `display` đặt qua selector ID/class thắng `display: none` mà thuộc tính
   `hidden` đặt trong UA stylesheet — khối bị "ẩn" vẫn hiện ra. Chốt lại ở đây
   một lần cho mọi phần tử thay vì nhớ thêm `[hidden]` cho từng khối. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 22px;
  margin: 8px 0 16px;
}

h2 {
  font-size: 16px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.row {
  display: flex;
  gap: 12px;
}

.row .field {
  flex: 1;
}

input,
textarea,
button {
  font: inherit;
  color: var(--ink);
}

input,
textarea {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--bg);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  font-weight: 600;
}

.ghost {
  padding: 6px 10px;
  font-size: 13px;
}

.danger {
  color: var(--bad);
  border-color: var(--bad);
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

.item textarea {
  margin-bottom: 8px;
}

.queue-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.queue-row:last-child {
  border-bottom: none;
}

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

.queue-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.badge.pending {
  background: #3a4250;
  color: #cbd5e1;
}
.badge.posting {
  background: var(--warn);
  color: #1a1f26;
}
.badge.posted {
  background: var(--ok);
  color: #fff;
}
.badge.failed {
  background: var(--bad);
  color: #fff;
}

/* --- Tab nền tảng --- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  font-weight: 600;
  background: var(--card);
}

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

/* --- Kết nối nền tảng --- */

#fb-connected,
#yt-connected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.thumb-field {
  display: block;
  margin-bottom: 8px;
}

.thumb-field span {
  display: block;
  margin-bottom: 4px;
}

.connected {
  min-width: 0;
}

.pages {
  margin: 12px 0;
}

.page-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.page-option input {
  width: auto;
  margin: 0;
  flex: none;
}

.page-option:has(input:checked) {
  border-color: var(--accent);
}

.page-option .name {
  font-weight: 600;
}

#fb-save {
  margin-top: 4px;
}

.item input[data-role="title"] {
  font-weight: 600;
  margin-bottom: 8px;
}

.item input[data-role="tags"] {
  margin-bottom: 8px;
}

.banner {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin: 0 0 12px;
}

code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 12px;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.error {
  color: var(--bad);
}

.log {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Thanh tiến độ cho từng video: mỗi video là một request riêng nên tiến độ
   phải hiện theo dòng, không phải một thanh chung cho cả loạt. */
.progress {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}

.progress-note {
  margin-bottom: 8px;
  min-height: 16px;
}

.item-sending {
  border-color: var(--accent);
}

.item-done {
  opacity: 0.55;
}

.item-failed {
  border-color: #d64545;
}
