:root {
  --ink: #1f2528;
  --muted: #6f7477;
  --line: #ddd9d3;
  --paper: #f7f5f1;
  --surface: #ffffff;
  --green: #2f7f49;
  --green-soft: #ddf3df;
  --lime: #a8ec91;
  --red: #9c180d;
  --red-soft: #ffd9d3;
  --shadow: 0 18px 50px rgba(31, 37, 40, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}
button:hover { border-color: #bfb8af; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 116px; resize: vertical; }
small { color: var(--muted); }

.buffer-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 330px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f2f0eb;
  padding: 20px 20px 16px;
  z-index: 5;
}
.brand-line { display: flex; align-items: center; gap: 9px; font-size: 30px; }
.brand-stack { color: #25282a; font-size: 24px; transform: rotate(45deg); }
.brand-line strong { margin-right: auto; }
#quick-add-channel {
  width: 48px;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--lime);
  font-size: 30px;
  font-weight: 500;
}
.side-nav { display: grid; gap: 4px; margin-top: 24px; }
.side-nav a {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 14px;
  border-radius: 10px;
  color: var(--ink);
  padding: 0 16px;
  text-decoration: none;
  font-size: 21px;
}
.side-nav a.active { background: #e7e3de; }
.side-nav span { width: 22px; text-align: center; color: #5d5f60; }
.side-nav em {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
  font-size: 16px;
}
.channel-scroll {
  min-height: 170px;
  overflow: auto;
  margin: 16px -20px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 20px;
}
.channel-row {
  width: 100%;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 7px 0;
  text-align: left;
}
.channel-row:hover { background: transparent; }
.avatar {
  --accent: #147d79;
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 900;
}
.avatar::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--accent);
}
.channel-copy { display: grid; gap: 2px; min-width: 0; }
.channel-copy b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; }
.channel-zero { margin-left: auto; color: var(--muted); }
.channel-alert {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 900;
}
.channel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.channel-disconnect {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.channel-disconnect:hover {
  color: var(--red);
  border-color: var(--red);
}
.empty-side { color: var(--muted); line-height: 1.5; }
.connection-card {
  position: relative;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf9f6;
  padding: 18px;
}
.close-mini {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  padding: 0;
}
.progress-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.progress-bars i { height: 8px; border-radius: 999px; background: #4d9562; }
.connection-card button:last-child { background: #fff; }
.org-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 20px;
}
.org-avatar {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 10px;
  background: #bdc5ff;
  color: #162066;
  font-weight: 900;
}
.org-card span:last-child { display: grid; }

.buffer-main {
  min-height: 100vh;
  margin-left: 330px;
  border-radius: 18px 0 0 18px;
  background: #fff;
  padding: 48px 50px;
}
.buffer-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.title-box { display: flex; align-items: center; gap: 14px; }
.title-box h1 { margin: 0; font-size: 32px; }
.grid-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  font-size: 28px;
}
.view-actions { display: flex; gap: 10px; }
.list-toggle { background: var(--green-soft); color: #17623a; border-color: var(--green-soft); }
.ghost-button { background: #fff; }
#new-post-button { font-size: 18px; }
.tabbar {
  display: flex;
  align-items: end;
  gap: 34px;
  border-bottom: 1px solid var(--line);
  margin-top: 32px;
}
.tab {
  min-height: 54px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 0 12px;
  font-size: 21px;
}
.tab.active { border-color: var(--green); color: #101516; }
.tab span {
  display: inline-grid;
  min-width: 26px;
  height: 26px;
  margin-left: 6px;
  place-items: center;
  border-radius: 999px;
  background: #ece9e4;
  font-size: 15px;
}
.filters { display: flex; gap: 22px; margin-left: auto; padding-bottom: 12px; }
.filters button { border: 0; background: transparent; font-size: 20px; }
.toast, .setup-strip {
  margin-top: 18px;
  border-radius: 10px;
  background: #edf8ef;
  color: #21633a;
  padding: 14px 16px;
  font-weight: 750;
}
.toast.error { background: var(--red-soft); color: var(--red); }
.setup-strip { background: #fff7e3; color: #7a4d00; }

.composer-card, .drawer-card, .analytics-band {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(31,37,40,.04);
  padding: 24px;
}
.section-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 24px; }
.section-heading p { margin: 6px 0 0; color: var(--muted); }
.blast-form, .channel-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.blast-form textarea { grid-column: 1 / -1; }
.blast-form > button, .channel-form > button { background: #101f18; color: #fff; border-color: #101f18; }
.schedule-line, .toggle-line {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}
.toggle-line input { width: auto; min-height: auto; }
.blast-targets {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border: 1px dashed #cfc8bf;
  border-radius: 10px;
  background: #faf9f6;
  padding: 14px;
}
.blast-targets > div { display: flex; flex-wrap: wrap; gap: 8px; }
.channel-chip {
  --accent: #147d79;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  font-weight: 850;
}
.channel-chip::before { content: ""; width: 10px; height: 10px; border-radius: 999px; background: var(--accent); }
.channel-chip small { font-weight: 650; }
.channel-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.channel-form button { grid-column: span 1; }

.queue-section { display: grid; grid-template-columns: 150px 1fr; gap: 0; margin-top: 30px; }
.date-column { display: grid; align-content: start; gap: 42px; padding: 10px 18px 0 0; font-size: 20px; }
.date-column span { color: var(--ink); font-weight: 650; }
.post-list { border-left: 1px solid var(--line); padding-left: 0; }
.queue-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  margin-bottom: 18px;
  background: #fff;
}
.lost-auth {
  background: var(--red-soft);
  color: var(--red);
  padding: 18px 24px;
  font-size: 19px;
  line-height: 1.5;
}
.queue-body {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 24px;
  padding: 24px;
}
.post-meta { display: flex; align-items: center; gap: 14px; }
.post-meta b { font-size: 20px; }
.post-meta div { display: grid; }
.queue-body p { grid-column: 1; margin: 8px 0 0 56px; color: #394044; line-height: 1.55; }
.post-preview {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  min-height: 160px;
  place-items: center;
  border-radius: 8px;
  background: #050505;
  color: #fff;
  font-size: 34px;
}
.queue-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 16px 24px;
}
.card-actions { display: flex; gap: 8px; margin-left: auto; }
.card-actions button { background: #fff; }
.empty-state {
  display: grid;
  place-items: start;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  padding: 34px;
  color: var(--muted);
}
.empty-state h2 { margin: 0; color: var(--ink); }
.analytics-band { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; }
.analytics-band span { display: flex; gap: 8px; color: var(--muted); }
.analytics-band b { color: var(--ink); }
.analytics-band button { margin-left: auto; }

@media (max-width: 980px) {
  .buffer-sidebar { position: static; width: auto; }
  .buffer-main { margin-left: 0; border-radius: 0; padding: 24px; }
  .buffer-topbar, .tabbar, .section-heading, .queue-footer { flex-direction: column; align-items: stretch; }
  .filters { margin-left: 0; flex-wrap: wrap; }
  .blast-form, .channel-form, .queue-section { grid-template-columns: 1fr; }
  .queue-body { grid-template-columns: 1fr; }
  .post-preview { grid-column: auto; grid-row: auto; }
  .post-list { border-left: 0; }
  .queue-card, .empty-state { border-left: 1px solid var(--line); border-radius: 8px; }
}
.oauth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.oauth-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  text-decoration: none;
  font-weight: 850;
}
.oauth-button span {
  --accent: #147d79;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
}
.oauth-button.disabled { color: var(--muted); background: #f7f5f1; }
.manual-connect {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.manual-connect summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 850;
  margin-bottom: 12px;
}
.media-upload {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px dashed #cfc8bf;
  border-radius: 10px;
  background: #faf9f6;
  padding: 12px;
}
.media-upload label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 850;
}
.media-upload input[type="file"] {
  border: 0;
  min-height: auto;
  padding: 0;
  background: transparent;
}
.media-upload small {
  grid-column: 1 / -1;
}
#media-urls {
  font-size: 14px;
}