:root {
  --bg: #f4ece2;
  --panel: #fffaf3;
  --ink: #2b211a;
  --muted: #8a7a6a;
  --brown: #6f4e37;
  --brown-d: #543a28;
  --cream: #e8d9c4;
  --ok: #2e7d52;
  --warn: #b9772a;
  --err: #c0392b;
  --line: #e3d6c5;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(80, 50, 20, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--brown); color: #fff;
}
.brand { font-size: 20px; font-weight: 700; }
.brand small { font-weight: 400; opacity: .8; font-size: 13px; margin-left: 6px; }
.conn { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.on { background: #6fe3a0; }
.dot.off { background: #e0a0a0; }

.tabs { display: flex; gap: 4px; padding: 10px 18px 0; background: var(--bg); }
.tab {
  border: none; background: transparent; padding: 10px 18px; cursor: pointer;
  font-size: 15px; color: var(--muted); border-radius: 10px 10px 0 0;
}
.tab.active { background: var(--panel); color: var(--brown-d); font-weight: 600; }

main { padding: 22px; max-width: 1100px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.form label { display: block; margin: 12px 0 4px; font-size: 14px; font-weight: 600; }
.form label small { font-weight: 400; color: var(--muted); }
input, textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; background: #fff; font-family: inherit;
}
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin-top: 12px; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-weight: 500; }
.chk input { width: auto; }

button {
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px;
  cursor: pointer; font-weight: 600;
}
button.ok { background: var(--brown); color: #fff; }
button.ok:hover { background: var(--brown-d); }
button.warn { background: var(--warn); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; margin-bottom: 16px; }
.statcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.statcard .n { font-size: 26px; font-weight: 700; color: var(--brown-d); }
.statcard .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.postlist { display: flex; flex-direction: column; gap: 10px; }
.postitem {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start;
}
.postitem img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.postitem .body { flex: 1; min-width: 0; }
.postitem .cap { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.postitem .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.platforms { display: inline-flex; gap: 5px; margin-left: 6px; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: var(--cream); color: var(--brown-d); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.badge.pending { background: #efe2cf; color: var(--warn); }
.badge.published { background: #d8f0e2; color: var(--ok); }
.badge.partial { background: #f6e7c8; color: var(--warn); }
.badge.failed { background: #f6d6d2; color: var(--err); }
.badge.publishing { background: #e0e8f0; color: #36659a; }
.itemActions { display: flex; flex-direction: column; gap: 6px; }
.itemActions button { padding: 5px 10px; font-size: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.libcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.libcard img { width: 100%; height: 130px; object-fit: cover; display: block; }
.libcard .cap { padding: 8px; font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.libcard .cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.form.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form.inline input[type=text] { flex: 1; min-width: 160px; }
.form.inline input[type=file] { width: auto; }

.imgPreview img { max-height: 140px; border-radius: 8px; margin-top: 8px; }
.hint { font-size: 12px; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(40,25,10,.45); display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modalbox { width: 420px; max-width: 92vw; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--brown-d); color: #fff; padding: 12px 20px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 14px; z-index: 50;
}
.toast.hidden { display: none; }
.toast.err { background: var(--err); }

h3 { margin: 6px 0 12px; color: var(--brown-d); }
