* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #1a1a1a; background: #fafafa; }
header { background: #1a1a1a; color: #fff; padding: 12px 24px; display: flex; gap: 24px; align-items: center; }
header nav a { color: #fff; text-decoration: none; opacity: 0.8; }
header nav a:hover { opacity: 1; }
main { max-width: 1080px; margin: 24px auto; padding: 0 24px; }
section { margin-bottom: 32px; }
h2 { display: flex; align-items: center; gap: 12px; font-size: 18px; margin: 0 0 12px; }
.count { background: #eee; color: #555; font-size: 12px; padding: 2px 8px; border-radius: 12px; font-weight: normal; }
.empty { color: #888; }
.add-form { display: flex; gap: 8px; }
.add-form input { flex: 1; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
.add-form button, button { padding: 10px 16px; border: 0; border-radius: 6px; background: #1a1a1a; color: #fff; font: inherit; cursor: pointer; }
button.primary { background: #2563eb; }
button.danger { background: #dc2626; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; transition: border-color 0.15s; }
.card:hover { border-color: #888; }
.card a { display: block; padding: 12px 14px; color: inherit; text-decoration: none; }
.card .title { font-weight: 600; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: #666; }
.state-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; background: #eee; color: #333; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.state-pill.big { font-size: 13px; padding: 4px 12px; }
.state-FETCHING_META .state-pill { background: #fef3c7; color: #92400e; }
.state-READY_FOR_TRIAGE .state-pill { background: #dbeafe; color: #1e40af; }
.state-QUEUED .state-pill { background: #e0e7ff; color: #3730a3; }
.state-DOWNLOADING .state-pill { background: #dbeafe; color: #1e40af; }
.state-POSTPROCESSING .state-pill { background: #f3e8ff; color: #6b21a8; }
.state-INDEXED .state-pill, .state-ARCHIVED .state-pill { background: #d1fae5; color: #065f46; }
.state-ERROR .state-pill { background: #fecaca; color: #991b1b; }
.state-DISCARDED .state-pill { background: #e5e5e5; color: #666; }
.hash { font-family: monospace; }
.back { color: #2563eb; text-decoration: none; }
.cover { max-width: 320px; border-radius: 8px; margin: 12px 0; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #eee; }
.files li label { display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer; }
.files .path { flex: 1; }
.files .size { color: #666; font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }
.kind-tag { font-size: 10px; padding: 2px 6px; background: #f3f3f3; border-radius: 4px; color: #666; min-width: 50px; text-align: center; }
.kind-video .kind-tag { background: #dbeafe; color: #1e40af; }
.kind-image .kind-tag { background: #fef3c7; color: #92400e; }
.kind-junk .kind-tag { background: #f3f3f3; color: #999; }
.sel-tag { background: #2563eb; color: #fff; padding: 2px 6px; font-size: 10px; border-radius: 4px; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.raw dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 12px; color: #555; }
.raw dt { font-weight: 600; }
.raw dd { margin: 0; }
.raw .break { word-break: break-all; }
footer { padding: 8px 24px; text-align: center; color: #888; font-size: 11px; }
#conn { color: #aaa; }

/* setup_nas page */
table.kv { border-collapse: collapse; margin: .8em 0; }
table.kv th { text-align: left; padding: .3em .8em .3em 0; color: #666; font-weight: 500; }
table.kv td { padding: .3em 0; font-family: ui-monospace, Menlo, monospace; }
pre.snippet { background: #f4f4f6; border: 1px solid #ddd; border-radius: 6px;
              padding: .9em 1em; overflow-x: auto; font-size: .85em; line-height: 1.4; }
p.hint { color: #555; font-size: .9em; }

/* header right-aligned help link */
header { display: flex; align-items: center; gap: 1rem; }
header nav { flex: 1; }
header a.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7em; height: 1.7em; border-radius: 50%;
  border: 1px solid #bbb; color: #555; text-decoration: none;
  font-weight: 600; font-size: .95em;
}
header a.help:hover { background: #eee; color: #000; }

header a.lang-switch {
  border: 1px solid #ccc; padding: .15em .55em; border-radius: 4px;
  color: #444; text-decoration: none; font-size: .8em;
}
header a.lang-switch:hover { background: #eee; }

/* ----- readability overrides (larger fonts, CJK stack, darker text) ----- */
html, body {
  font-size: 16px;
  line-height: 1.65;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
               "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  color: #111;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
header { padding: 14px 24px; font-size: 1rem; }
header nav a { opacity: 1; font-weight: 500; }
header nav a:hover { color: #9cf; }
.empty { color: #666; font-size: .95rem; }
.card .meta { font-size: .82rem; color: #555; }
.state-pill { font-size: .75rem; padding: 3px 10px; }
.state-pill.big { font-size: .9rem; padding: 5px 14px; }
.count { font-size: .8rem; color: #444; }
.files li { font-size: .95rem; }
.files .size { color: #444; }
.kind-tag { color: #555; }
p.hint { color: #444; font-size: .95rem; }
table.kv th { color: #444; font-weight: 500; font-size: .95rem; }
table.kv td { font-size: .9rem; }
pre.snippet { font-size: .82rem; line-height: 1.55; background: #f3f3f6; color: #1a1a1a; }
footer { color: #555; font-size: .85rem; padding: 8px 24px; }

/* preview player */
video.preview {
  width: 100%;
  max-width: 720px;
  display: block;
  margin: 8px 0 4px;
  background: #000;
  border-radius: 6px;
}
p.hint {
  color: #555;
  font-size: 13px;
  margin: 4px 0 16px;
}
img.cover {
  max-width: 240px;
  height: auto;
  border-radius: 6px;
  margin: 8px 0;
}
li.files.selected, li.kind-video.selected {
  opacity: 1;
}
.empty {
  color: #777;
  font-style: italic;
}


/* ====== ui polish round 2 ====== */
main { max-width: 1280px; }
section { width: 100%; }

/* progress bar on download cards */
.progress {
  width: 100%; height: 6px; background: #eee; border-radius: 3px;
  overflow: hidden; margin-top: 8px;
}
.progress .bar {
  height: 100%; background: linear-gradient(90deg, #5cb3ff, #2e8bff);
  transition: width .6s ease;
}
.card .meta .speed { color: #2e8bff; font-weight: 600; }
.card .meta .eta { color: #888; font-variant-numeric: tabular-nums; }

/* top-bar contrast bump */
header { background: #fafafa; border-bottom: 1px solid #e3e3e3; }
header a.lang-switch {
  border: 1px solid #888; color: #222; font-size: .95rem;
  padding: .25em .7em; font-weight: 500;
}
header a.lang-switch:hover { background: #333; color: #fff; border-color: #333; }
header a.help {
  width: 2em; height: 2em; border: 1.5px solid #888; color: #222;
  font-size: 1.1em; font-weight: 700;
}
header a.help:hover { background: #333; color: #fff; border-color: #333; }

/* nas warn banner */
p.warn {
  background: #fff7e0; border: 1px solid #f0c060; color: #6b4400;
  padding: 10px 14px; border-radius: 6px; margin: 0 0 12px;
}
p.warn a { color: #b35900; font-weight: 600; }

/* topbar brand + nav contrast fix */
header strong { color: #111; font-size: 1.05rem; }
header nav a {
  color: #222 !important; opacity: 1 !important;
  font-weight: 500; text-decoration: none;
  padding: .2em .5em; border-radius: 4px;
}
header nav a:hover { background: #eee; color: #000 !important; }
header nav a.active { background: #222; color: #fff !important; }


/* ====== round 3: constrained list rows ====== */
main { max-width: 1200px !important; margin: 16px auto; padding: 0 20px; }
section { width: 100%; }

.cards {
  display: flex !important;
  flex-direction: column;
  gap: 6px !important;
  grid-template-columns: none !important;
}
.card {
  position: relative;
  min-height: 0;
  display: block;
  border-left: 3px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
}
.card a {
  display: grid !important;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 14px;
  padding: 8px 12px !important;
  width: 100%;
  min-height: 0;
}
.card .title {
  font-size: .95rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: #111;
  margin: 0;
  grid-column: 1;
  grid-row: 1;
}
.card .meta {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  font-size: .78rem !important;
  color: #555;
  white-space: nowrap;
}
.card .meta .hash { display: none; }
.card .meta .speed { font-weight: 500; color: #2e8bff; }
.card .meta .eta { color: #777; }
.card .progress {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 4px !important;
  height: 3px !important;
}

/* state-tinted left border */
.card.state-DOWNLOADING    { border-left-color: #2e8bff; }
.card.state-POSTPROCESSING { border-left-color: #f0a020; }
.card.state-READY_FOR_TRIAGE { border-left-color: #9c4dff; }
.card.state-QUEUED         { border-left-color: #888; }
.card.state-INDEXED        { border-left-color: #2ea845; }
.card.state-ARCHIVED       { border-left-color: #2ea845; opacity: .7; }
.card.state-DISCARDED      { opacity: .5; }
.card.state-ERROR          { border-left-color: #d33; }
