:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #939aa8;
  --accent: #4c8dff;
  --accent-2: #3ad29f;
  --danger: #ff5f56;
  --warn: #ffb84d;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

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

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 21, .94);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--accent); }
.grow { flex: 1; }

.who { color: var(--muted); font-size: 13px; }

main { padding: 14px; max-width: 1000px; margin: 0 auto; }

.disk {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.disk-track {
  height: 6px;
  border-radius: 99px;
  background: var(--panel-2);
  overflow: hidden;
  margin-top: 4px;
}
.disk-fill { height: 100%; background: var(--accent); transition: width .4s; }
.disk-fill.low { background: var(--danger); }

button, .btn {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06111f; font-weight: 600; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.small { padding: 5px 9px; min-height: 34px; font-size: 13px; }

#drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  transition: border-color .15s, background .15s;
}
#drop.hot { border-color: var(--accent); background: #172131; color: var(--text); }
#drop b { color: var(--text); }
#drop .hint { font-size: 12.5px; margin-top: 6px; }

.queue { margin: 14px 0; display: grid; gap: 8px; }
.job {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.job-top { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.job-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.track { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.fill { height: 100%; width: 0; background: var(--accent-2); transition: width .2s; }
.job.err .fill { background: var(--danger); }
.job-msg { font-size: 12px; color: var(--muted); margin-top: 6px; }
.job.err .job-msg { color: var(--danger); }

.files { display: grid; gap: 10px; margin-top: 6px; }

.file {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.file.archived { border-color: #4a4327; background: #1b1a14; }

.thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 9px;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 22px;
  cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.meta { flex: 1; min-width: 0; }
.name { font-weight: 600; word-break: break-word; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.keep { color: var(--warn); border-color: #5a4a20; }
.tag.share { color: var(--accent-2); border-color: #24503f; }

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

dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0;
  max-width: min(94vw, 900px);
  width: 100%;
}
dialog::backdrop { background: rgba(0, 0, 0, .72); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dlg-head .t { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-body { padding: 14px; }
.dlg-body img, .dlg-body video { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; }
.dlg-body audio { width: 100%; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 10px; }
input[type=text], input[type=password], select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  min-height: 40px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

code.link {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font-size: 12.5px;
  word-break: break-all;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  z-index: 99;
  max-width: 90vw;
}
.toast.err { border-color: var(--danger); color: #ffd0cd; }

/* หน้า login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px 22px; width: min(380px, 100%); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p.sub { margin: 0 0 18px; }
.login-card .row { margin-top: 12px; }
.err-box { color: #ffd0cd; background: #331a19; border: 1px solid #5c2b28; border-radius: 9px; padding: 9px 11px; font-size: 13.5px; margin-top: 12px; }

@media (max-width: 520px) {
  .thumb { width: 52px; height: 52px; flex-basis: 52px; }
  main { padding: 10px; }
}
