:root {
  --bg: #f3f6f4;
  --card: #fff;
  --text: #1d2a24;
  --muted: #65756d;
  --border: #dbe3de;
  --primary: #1f8a5b;
  --primary-dark: #17704a;
  --danger: #c0392b;
  --blue: #1877f2;
  --warn-bg: #fdecea;
  --ok-bg: #e5f5ec;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121815;
    --card: #1b2420;
    --text: #e3ebe6;
    --muted: #93a39b;
    --border: #2d3a34;
    --warn-bg: #3a1f1c;
    --ok-bg: #1c3427;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 4px 0; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--primary); color: #fff;
}
.top a, .top .link { color: #fff; text-decoration: none; margin-left: 16px; }
.brand { font-weight: 700; font-size: 1.1rem; margin-left: 0 !important; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pagecard { color: inherit; text-decoration: none; display: block; transition: transform .1s; }
.pagecard:hover { transform: translateY(-2px); border-color: var(--primary); }
.pagecard h2 { margin-bottom: 4px; }
.stats { list-style: none; padding: 0; margin: 12px 0; }
.newpage { display: flex; flex-direction: column; gap: 10px; }

input, textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: var(--bg); color: var(--text);
}
textarea { resize: vertical; }
input[type=checkbox] { width: auto; margin-right: 8px; }
input[type=range] { padding: 0; }
label { display: block; margin-bottom: 12px; font-weight: 500; }
label small { display: block; font-weight: 400; color: var(--muted); }
label.check { display: flex; align-items: center; font-weight: 400; }

button {
  font: inherit; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
}
button:hover { border-color: var(--primary); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.publish { background: var(--blue); border-color: var(--blue); color: #fff; }
button.big { padding: 12px 20px; font-size: 1rem; }
button.link { background: none; border: none; padding: 0; }
button:disabled { opacity: .6; cursor: wait; }
form.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); }
.flash.error { background: var(--warn-bg); color: var(--danger); }
.error-text { color: var(--danger); }
.muted, .small { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); text-align: center; padding: 40px; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; vertical-align: middle; }
.badge.on { background: var(--ok-bg); color: var(--primary); }
.badge.off { background: var(--border); color: var(--muted); }
.status-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { padding: 4px 12px; border-radius: 99px; font-size: .85rem; }
.pill.ok { background: var(--ok-bg); }
.pill.bad { background: var(--warn-bg); color: var(--danger); }

.pagehead h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs, .subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a, .subtabs a {
  padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent;
}
.tabs a.active, .subtabs a.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.subtabs { border-bottom: none; }
.subtabs a { border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px; font-size: .9rem; }
.subtabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.count { opacity: .7; margin-left: 4px; }

.infobar { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.filters a { margin-left: 8px; text-decoration: none; color: var(--muted); }
.filters a.active { color: var(--text); font-weight: 600; }

.item { display: grid; grid-template-columns: 180px 1fr; gap: 16px; }
.item-visual img { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; background: var(--border); }
.videothumb, .articlethumb {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  height: 160px; border-radius: 8px; background: var(--bg); font-size: 2rem; text-decoration: none; color: var(--muted);
}
.videothumb { font-size: 1rem; }
.meta { font-size: .8rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { background: var(--bg); border: 1px solid var(--border); padding: 0 8px; border-radius: 99px; }
.tag.prio { background: #fff3cd; color: #7a5b00; }
.excerpt { color: var(--muted); font-size: .9rem; margin: 4px 0; }
.reason { font-size: .85rem; font-style: italic; margin: 4px 0; }
.filename { word-break: break-all; }
.captionlabel { margin: 8px 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.row { display: flex; gap: 10px; }
.grow { flex: 1; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
td small a { color: var(--muted); word-break: break-all; }
tr.disabled { opacity: .5; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.cols { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.dropzone { border: 2px dashed var(--border); text-align: center; position: relative; transition: border-color .15s; }
.dropzone.over { border-color: var(--primary); background: var(--ok-bg); }
.dropzone.busy { pointer-events: none; opacity: .8; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-label { margin: 0; padding: 20px; cursor: pointer; font-weight: 400; }
.dropzone-label small { margin-top: 4px; }
.big-emoji { display: block; font-size: 2.2rem; }
.progress { position: relative; height: 26px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress .bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .85rem; }

.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.libitem { padding: 0; overflow: hidden; margin: 0; display: flex; flex-direction: column; }
.libthumb { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--bg); }
.libthumb img, .libthumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.videobadge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; padding: 2px 8px; border-radius: 99px; }
.libinfo { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.libinfo .filename { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.libinfo textarea { font-size: .85rem; }
.libinfo .actions button { padding: 4px 8px; font-size: .85rem; }
.libstatus { display: flex; flex-wrap: wrap; gap: 4px; font-size: .75rem; }
.tag.posted { background: var(--ok-bg); border-color: transparent; }
.tag.new { background: #e3f0ff; color: #1857a8; border-color: transparent; }
.tag.queued { background: #fff3cd; color: #7a5b00; border-color: transparent; }
.tag.wait { background: var(--border); }
.libitem.state-disabled .libthumb { opacity: .4; }
.libitem.state-cooldown .libthumb { filter: grayscale(.6); }

.choice { border-left: 3px solid var(--border); padding-left: 12px; margin-bottom: 8px; }
.choice strong { display: block; margin-bottom: 6px; }
.testresult { margin-top: 16px; padding: 12px; border-radius: 8px; background: var(--bg); }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.dangerzone { margin-top: 40px; border-color: var(--danger); }

.login { max-width: 360px; margin: 10vh auto; text-align: center; }
.login .card { text-align: left; }
.login button { width: 100%; }

@media (max-width: 700px) {
  .item { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
}
