:root {
  --orange: #f26b1d;
  --orange-dark: #d9560f;
  --red: #c8102e;
  --green: #2e8b57;
  --ink: #1e1a17;
  --muted: #6f655d;
  --cream: #fffaf4;
  --cream-2: #fff0e0;
  --line: #ecdccb;
  --white: #ffffff;
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 15px/1.5 "Inter", system-ui, sans-serif; }
h1, h2, h3 { font-family: "Poppins", sans-serif; font-weight: 800; margin: 0 0 12px; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 24px;
  background: var(--white); border-bottom: 3px solid var(--orange);
  position: sticky; top: 0; z-index: 10;
}
.logo { height: 46px; }
.title { font: 600 15px "Poppins"; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.conn { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--cream-2); }
.conn.ok { color: var(--green); }
.conn.bad { color: var(--red); }

main, .narrow { max-width: 920px; margin: 24px auto; padding: 0 16px; }
.narrow { max-width: 420px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 6px 18px rgba(30,26,23,.05); }

label, .label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 14px; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.label-row .label { margin: 0; }
input, textarea, select {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: var(--white); color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--orange); border-color: transparent; }

button, .chip { font: 600 14px "Inter", sans-serif; cursor: pointer; border-radius: 999px; padding: 10px 18px; border: 2px solid transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--orange); color: #fff; box-shadow: 0 4px 10px rgba(242,107,29,.3); }
.primary:hover:not(:disabled) { background: var(--orange-dark); }
.secondary { background: var(--cream-2); color: var(--ink); border-color: var(--line); }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.ghost:hover { border-color: var(--orange); color: var(--orange-dark); }
.danger { background: var(--red); color: #fff; }
.chip { display: inline-block; padding: 5px 12px; font-size: 13px; background: var(--cream-2); border-color: var(--line); margin: 0; }
.chip.upload { font-weight: 600; }
.small-btn { padding: 6px 12px; font-size: 13px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: var(--white); border-color: var(--line); color: var(--ink); }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge { background: var(--orange); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.actions.right { justify-content: flex-end; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; } }

fieldset.when { border: 1px solid var(--line); border-radius: 12px; margin-top: 18px; padding: 8px 16px 16px; }
fieldset.when legend { font-weight: 700; padding: 0 6px; }
label.radio { display: inline-flex; align-items: center; gap: 8px; margin-right: 18px; font-weight: 500; }
label.radio input { width: auto; margin: 0; }
.quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs figure { margin: 0; position: relative; }
.thumbs img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumbs figure button { position: absolute; top: -6px; right: -6px; padding: 0; width: 22px; height: 22px; background: var(--ink); color: #fff; font-size: 12px; line-height: 1; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 55vh; overflow: auto; }
.lib-grid button { padding: 0; border-radius: 10px; border: 3px solid transparent; overflow: hidden; background: none; }
.lib-grid button.sel { border-color: var(--orange); }
.lib-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }

.post-list { display: grid; gap: 12px; }
.post { display: grid; grid-template-columns: 110px 1fr; gap: 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.post .pic { width: 110px; height: 110px; border-radius: 10px; object-fit: cover; background: var(--cream-2); display: grid; place-items: center; font-size: 30px; }
.post .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.status { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; }
.status.scheduled { background: #fff0e0; color: var(--orange-dark); }
.status.draft { background: #eee; color: #555; }
.status.failed { background: #fde8eb; color: var(--red); }
.status.published { background: #e6f4ec; color: var(--green); }
.status.publishing { background: #e8f0ff; color: #2a5bd7; }
.status.deleted { background: #eee; color: #777; }
.post .text { white-space: pre-wrap; margin: 6px 0 10px; max-height: 7.5em; overflow: hidden; }
.post .err { color: var(--red); font-size: 13px; margin-bottom: 8px; }
.post .btns { display: flex; gap: 6px; flex-wrap: wrap; }
.post .btns button { padding: 6px 12px; font-size: 13px; }
@media (max-width: 560px) { .post { grid-template-columns: 1fr; } .post .pic { width: 100%; height: 180px; } }
.empty { text-align: center; padding: 40px; color: var(--muted); background: var(--white); border: 1px dashed var(--line); border-radius: var(--radius); }

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30,26,23,.45); }
.modal-body { padding: 24px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(140px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; transition: transform .25s ease; max-width: 90vw; z-index: 50; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }

/* comments */
.comment-post { border-left: 3px solid var(--orange); padding-left: 10px; }
.comment-thread { max-height: 50vh; overflow: auto; margin: 8px 0 14px; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment.reply { margin-left: 28px; border-left: 2px solid var(--cream-2); padding-left: 12px; }
.comment .who { font-weight: 600; font-size: 14px; }
.comment .ctext { white-space: pre-wrap; margin: 2px 0 4px; }
.cacts { display: flex; gap: 12px; }
.link-btn { background: none; border: none; padding: 0; font-size: 13px; color: var(--orange-dark); font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.danger-text { color: var(--red); }
.page-badge { background: var(--orange); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.reply-box { margin-top: 8px; }
.reply-actions { display: flex; gap: 8px; margin-top: 6px; }
.comment-compose { display: grid; gap: 8px; }
.comment-compose button { justify-self: end; }

/* post type + video */
.type-switch { display: flex; flex-wrap: wrap; gap: 6px 4px; padding: 10px 14px; background: var(--cream-2); border-radius: 12px; }
#videoProgress { width: 100%; height: 10px; accent-color: var(--orange); margin-top: 8px; }
.video-fig { margin: 10px 0 0; display: grid; gap: 8px; justify-items: start; }
.video-fig video { max-width: 100%; max-height: 360px; border-radius: 12px; background: #000; }
