:root {
  --bg: #0e0d0b;
  --surface: #181612;
  --surface-2: #211e18;
  --line: #2c2820;
  --ink: #f2efe6;
  --muted: #8a857a;
  --accent: #ff5c1f;
  --amber: #ffc53d;
  --green: #5dbb63;
  --red: #e5484d;
  --ig: #d6409f;
  --fb: #1877f2;
  --tt: #3fd2c7;
  --yt: #e5484d;
  --x-c: #b8b3a7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 36px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.wordmark {
  font-family: "Bebas Neue", sans-serif;
  font-size: 30px;
  letter-spacing: 2px;
  line-height: 1;
}
.wordmark-dot { color: var(--accent); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 6px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); background: var(--surface-2); }
.tab:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.topbar-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

main { max-width: 1060px; margin: 0 auto; padding: 36px 28px 90px; }
.view.hidden { display: none; }
.view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}
h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: 38px;
  font-weight: 400;
  letter-spacing: 1.5px;
}

/* ── buttons ── */
.btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #16100a;
  font-weight: 700;
}
.btn-primary:hover { background: #ff7038; border-color: #ff7038; }
.btn-ghost { background: none; }
.btn-big { width: 100%; padding: 13px; font-size: 16px; margin-top: 18px; }
.btn-mini { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* ── the rail (signature element) ── */
.rail { position: relative; padding-left: 130px; }
.rail::before {
  content: "";
  position: absolute;
  left: 108px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.rail-day {
  font-family: "Bebas Neue", sans-serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: var(--amber);
  margin: 26px 0 10px;
  position: relative;
}
.rail-day::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 50%;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--amber);
}
.rail-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.rail-item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 26px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateX(-50%);
}
.rail-item.s-done::before { background: var(--green); }
.rail-item.s-failed::before, .rail-item.s-partial::before { background: var(--red); }
.rail-item.s-publishing::before { background: var(--amber); }
.rail-time {
  position: absolute;
  left: -130px;
  top: 18px;
  width: 92px;
  text-align: right;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--muted);
}
.rail-body { flex: 1; min-width: 0; }
.rail-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  margin-bottom: 8px;
}
.rail-text:empty::before { content: "(no caption)"; color: var(--muted); font-style: italic; }
.rail-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.rail-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.now-marker {
  position: relative;
  height: 1px;
  background: var(--accent);
  margin: 18px 0;
}
.now-marker::before {
  content: "NOW";
  position: absolute;
  left: -56px;
  top: -9px;
  font-family: "Bebas Neue", sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--accent);
}
.now-marker::after {
  content: "";
  position: absolute;
  left: -22.5px;
  top: -3.5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.empty {
  color: var(--muted);
  padding: 30px 0;
}

/* ── month calendar ── */
.calendar { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0 0 38px; }
.calendar-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; }
.calendar-head h2 { font-size: 20px; font-weight: 500; }
.calendar-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.calendar-controls { display: flex; gap: 7px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.calendar-weekdays span { text-align: center; padding: 9px 4px; color: var(--muted); text-transform: uppercase; font: 10px "JetBrains Mono", monospace; letter-spacing: 1px; }
.calendar-day { min-width: 0; min-height: 116px; padding: 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day-outside { background: #14120f; }
.calendar-day-today { box-shadow: inset 0 0 0 1px var(--accent); }
.calendar-day-number { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; color: var(--muted); font: 12px "JetBrains Mono", monospace; }
.calendar-day-today .calendar-day-number > span:first-child { color: var(--accent); font-weight: 700; }
.calendar-count { color: var(--muted); font-size: 10px; }
.calendar-event { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 5px; margin-top: 4px; padding: 4px 5px; background: var(--surface-2); border-left: 2px solid var(--amber); border-radius: 4px; overflow: hidden; }
.calendar-event-done { border-left-color: var(--green); }
.calendar-event-failed, .calendar-event-partial { border-left-color: var(--red); }
.calendar-event-publishing { border-left-color: var(--accent); }
.calendar-event time { color: var(--muted); font: 9px "JetBrains Mono", monospace; white-space: nowrap; }
.calendar-event-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.calendar-event-platforms { display: inline-flex; gap: 3px; }
.calendar-event-platforms .pchip { width: 17px; height: 17px; border-radius: 4px; }
.calendar-event-platforms svg { width: 10px; height: 10px; }

/* ── platform chips ── */
.pchip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 22px;
  border-radius: 5px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  color: #0e0d0b;
}
.p-instagram { background: var(--ig); }
.p-facebook { background: var(--fb); color: #fff; }
.p-tiktok { background: var(--tt); }
.p-youtube { background: var(--yt); color: #fff; }
.p-x { background: var(--x-c); }
.pchip svg { display: block; width: 15px; height: 15px; fill: currentColor; }
.p-instagram { color: #fff; }
.p-tiktok, .p-x { color: #101010; }

.tchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px 3px 4px;
}
.tchip .pchip { width: 22px; height: 20px; font-size: 10px; }
.tchip .pchip svg { width: 13px; height: 13px; }
.tchip.t-published { border-color: var(--green); color: var(--green); }
.tchip.t-failed { border-color: var(--red); color: var(--red); }
.tchip.t-publishing { border-color: var(--amber); color: var(--amber); }

/* ── compose ── */
.compose-grid { display: grid; grid-template-columns: 1fr 320px; gap: 32px; }
textarea, input[type="datetime-local"], input[type="date"], input[type="time"], select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  padding: 14px;
}
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.char-counts {
  display: flex;
  gap: 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 2px 20px;
}
.char-counts .over { color: var(--red); }
.drop {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.drop:hover, .drop.dragover { border-color: var(--accent); color: var(--ink); }
.media-preview { margin-top: 14px; display: flex; gap: 14px; align-items: center; }
.media-preview img, .media-preview video {
  max-width: 200px;
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.schedule-panel { margin-top: 22px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.schedule-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.schedule-heading p { color: var(--muted); font-size: 12px; margin-top: -4px; }
.schedule-fields { display: flex; gap: 12px; margin-top: 14px; }
.schedule-shortcuts { display: flex; gap: 8px; margin-top: 12px; }
.schedule-preview { min-height: 20px; margin-top: 12px; color: var(--amber); font-size: 13px; }
.field { flex: 1; display: block; }
.field-label, .side-label {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.compose-side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  align-self: start;
  position: sticky;
  top: 84px;
}
.target-list { display: flex; flex-direction: column; gap: 8px; }
.target {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.target:hover { border-color: var(--muted); }
.target.selected { border-color: var(--accent); background: var(--surface-2); }
.target img { width: 26px; height: 26px; border-radius: 50%; }
.target .tname { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popts {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}
.popts .field { margin-bottom: 10px; }
.popts select, .popts input[type="text"] {
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
}
.compose-error { color: var(--red); font-size: 13.5px; margin-top: 12px; min-height: 20px; }
.compose-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* ── accounts ── */
.account-list { display: flex; flex-direction: column; gap: 10px; }
.account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
}
.account-row img { width: 36px; height: 36px; border-radius: 50%; }
.account-row .aname { flex: 1; font-weight: 500; }
.account-row .aexp { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.connect-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.connect-card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.connect-card:hover { border-color: var(--accent); }
.connect-card small { width: 100%; color: var(--muted); font-weight: 400; }

/* ── activity ── */
.activity-list { font-family: "JetBrains Mono", monospace; font-size: 13px; }
.activity-row {
  display: flex;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.activity-row .at { color: var(--muted); flex-shrink: 0; }
.activity-row.l-error { color: var(--red); }
.activity-row.l-warn { color: var(--amber); }

@media (max-width: 860px) {
  .compose-grid { grid-template-columns: 1fr; }
  .compose-side { position: static; }
  .calendar-day { min-height: 94px; padding: 5px; }
  .calendar-event { grid-template-columns: minmax(0, 1fr) auto; }
  .calendar-event time { display: none; }
  .calendar-event-text { grid-column: 1; }
  .calendar-event-platforms { grid-column: 2; grid-row: 1; }
  .rail { padding-left: 0; }
  .rail::before, .rail-day::before, .rail-item::before, .now-marker::before, .now-marker::after { display: none; }
  .rail-time { position: static; width: auto; text-align: left; margin-bottom: 6px; }
  .rail-item { flex-direction: column; }
  .topbar { gap: 14px; flex-wrap: wrap; }
}

@media (max-width: 540px) {
  main { padding: 24px 14px 64px; }
  .calendar-day { min-height: 70px; padding: 4px; }
  .calendar-head { padding: 14px; }
  .calendar-day-number { font-size: 10px; }
  .calendar-event { display: flex; justify-content: center; padding: 3px; }
  .calendar-event-text, .calendar-event time { display: none; }
  .calendar-event-platforms .pchip { width: 15px; height: 15px; }
  .calendar-event-platforms svg { width: 9px; height: 9px; }
  .schedule-fields, .schedule-heading { flex-direction: column; }
  .connect-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .rail-item { transition: border-color 0.15s; }
  .rail-item:hover { border-color: var(--muted); }
}

/* ── login + utility classes (no inline styles: strict CSP) ── */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; }
.login-card { display: flex; flex-direction: column; gap: 16px; width: min(360px, 100%); }
.login-error { color: #e0674f; margin: 0; font-size: 14px; }
.mt-48 { margin-top: 48px; }
.mt-36 { margin-top: 36px; }
.empty-compact { padding: 10px 0; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
