:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232d;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --danger: #f6685e;
  --ok: #4ac97e;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f0f3f6;
    --border: #d8dee6;
    --text: #1c2128;
    --muted: #5b6774;
    --accent-soft: rgba(76, 141, 255, 0.1);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.alert { color: var(--danger); font-size: 13px; }

/* ── Trang công khai ─────────────────────────────────────── */

.shell { max-width: 880px; margin: 0 auto; padding: 48px 20px 24px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px 0 40px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card.center { text-align: center; max-width: 420px; margin: 40px auto; }
.glyph { font-size: 34px; line-height: 1; margin-bottom: 8px; }
.card h1 { font-size: 20px; margin: 0 0 4px; }

.filehead {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
.filename { font-size: 18px; margin: 0; word-break: break-word; }
.actions { display: flex; gap: 8px; }

.preview { margin-top: 20px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.preview img, .preview video { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; }
.preview iframe { display: block; width: 100%; height: 78vh; border: 0; }
.preview.audio { padding: 20px; }
.preview audio { width: 100%; }

.note {
  margin: 20px 0 0;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 70vh;
}

.pw-form { display: flex; gap: 8px; margin-top: 16px; }
.pw-form input { flex: 1; }

/* ── Điều khiển ──────────────────────────────────────────── */

input, select, textarea, button { font-family: inherit; font-size: 14px; }

input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.danger:hover { background: rgba(246, 104, 94, 0.12); }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* ── Trang quản trị ──────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 15px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1 1 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat b { display: block; font-size: 19px; }
.stat span { color: var(--muted); font-size: 12px; }

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.queue { margin: 14px 0 0; display: grid; gap: 8px; }
.qitem {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
}
.qhead { display: flex; justify-content: space-between; gap: 10px; }
.qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; background: var(--surface-2); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.qitem.done .bar > i { background: var(--ok); }
.qitem.failed .bar > i { background: var(--danger); }

.toolbar { display: flex; gap: 8px; margin: 22px 0 12px; flex-wrap: wrap; }
.toolbar input[type="text"] { flex: 1; min-width: 180px; }
.toolbar select { width: auto; }

.list { display: grid; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.thumb {
  width: 42px; height: 42px; flex: none;
  border-radius: 7px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 17px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.rowmain { flex: 1; min-width: 0; }
.rowtitle { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowmeta { color: var(--muted); font-size: 12px; }
.rowactions { display: flex; gap: 6px; flex: none; }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 7px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent);
  margin-left: 6px;
}

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: min(520px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin: 0 0 14px; font-size: 17px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.linkout {
  display: flex; gap: 8px; margin-top: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; align-items: center;
}
.linkout code { flex: 1; font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: nowrap; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 16px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; }
.toast.error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .tabs { margin-left: 0; }
  .topbar { flex-wrap: wrap; }
}
