:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #e5eaf0;
  --paper: #f8fbff;
  --surface: #ffffff;
  --wash: #f2f6fb;
  --blue: #2f6df6;
  --green: #16a66a;
  --red: #e04444;
  --amber: #f59e0b;
  --shadow: 0 12px 32px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Geist", "Aptos", "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: wait;
  opacity: .68;
}
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(47, 109, 246, .24);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}
.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; font-weight: 850; }
.mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--blue);
  color: white;
  font-family: inherit;
  font-weight: 900;
  font-size: 14px;
}
.nav button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 13px 14px;
  border-radius: 12px;
  font-weight: 760;
  margin-bottom: 8px;
  color: var(--muted);
}
.nav button span { position: relative; z-index: 1; }
.nav button.active, .nav button:hover {
  background: #eef4ff;
  color: var(--blue);
  box-shadow: none;
}
.nav-card {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: white;
  color: var(--muted);
  font-size: 13px;
}
.nav-card strong { color: var(--green); }
.nav-card p { margin: 8px 0 12px; }
.nav-card button {
  margin: 0;
  text-align: center;
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
}
.workspace { min-width: 0; }
.appbar {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  background: white;
  padding: 0 28px;
}
.appbar nav { display: flex; align-self: stretch; gap: 26px; }
.appbar nav button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 820;
  padding: 0;
  border-bottom: 3px solid transparent;
}
.appbar nav button.active { color: var(--blue); border-bottom-color: var(--blue); }
.search {
  margin-left: auto;
  width: min(360px, 32vw);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  color: #98a2b3;
  background: #fbfcff;
  font-size: 13px;
}
.user-dot { width: 36px; height: 36px; border-radius: 50%; background: #111827; color: white; display: grid; place-items: center; font-weight: 850; }
.main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.main.no-rail { grid-template-columns: minmax(0, 1fr); }
.main.no-rail .rail { display: none; }
.stage { border-right: 1px solid var(--line); min-height: 100vh; }
.topbar {
  position: sticky;
  top: 66px;
  z-index: 2;
  background: rgba(248,251,255,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 28px 36px 22px;
}
h1 {
  margin: 0;
  font-family: inherit;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 860;
}
h2 { margin: 0; font-size: 17px; line-height: 1.2; letter-spacing: 0; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.date-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.date-tabs button, .source-tabs button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 12px;
  font-weight: 750;
  font-size: 13px;
}
.date-tabs button.active, .source-tabs button.active { border-color: #c8d6ff; background: #eef3ff; color: var(--blue); }
.date-tabs input { width: auto; min-width: 150px; padding: 7px 10px; }
.source-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(255,255,255,.78);
  color: var(--muted);
  font-size: 12px;
}
.chip strong { color: var(--ink); }
.rail {
  padding: 22px;
  background: #fbfcff;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(23, 32, 28, .04);
}
.panel.soft { background: var(--wash); }
.queue-total { display: flex; align-items: baseline; gap: 10px; margin: 16px 0; }
.queue-total strong { font-size: 34px; line-height: 1; }
.queue-total span { color: var(--muted); }
.ok { color: var(--green); }
.rail-action { width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: white; font-weight: 760; text-align: left; }
.kv { display: flex; justify-content: space-between; gap: 18px; margin: 10px 0; }
.kv strong { font-size: 18px; }

.feed-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 16px;
  margin: 16px 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.feed-list { padding: 4px 0 22px; }
.feed-item:hover {
  transform: translateY(-1px);
  border-color: #cfd9ff;
  box-shadow: 0 18px 42px rgba(16, 24, 40, .08);
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  display: grid;
  place-items: center;
  font-family: inherit;
  font-weight: 850;
}
.avatar.reddit { background: #111827; }
.avatar.xueqiu { background: var(--blue); }
.item-body { min-width: 0; }
.item-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.source-line {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}
.item-title { font-weight: 870; letter-spacing: 0; }
.pill {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.72);
}
.approved { color: #097245; background: #effcf6; border-color: #b9f2d4; }
.rejected { color: #a71919; background: #fff1f1; border-color: #ffd0d0; }
.publish { color: #7a4b00; background: #fff8e8; border-color: #f6d48a; }
.copy {
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 12px 0;
  max-width: 760px;
}
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 560px; }
.media-tile {
  min-height: 124px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--wash);
  overflow: hidden;
  position: relative;
}
.media-tile img { width: 100%; height: 124px; object-fit: cover; display: block; }
.media-tile span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(16,20,24,.85);
  color: white;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}
.selected-media {
  width: 220px;
  max-width: 100%;
  height: 124px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 12px;
  display: block;
}
.selected-media.compact {
  width: 100%;
  height: 96px;
}
.media-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.media-choice label {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  background: rgba(255,255,255,.78);
}
.media-choice label:has(input:checked) {
  border-color: #b9caff;
  background: #eef3ff;
}
.media-choice input { width: auto; margin: 0 0 6px; }
.media-choice img { width: 100%; height: 92px; object-fit: cover; border-radius: 6px; display: block; }
.media-choice span { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.actions button, .small-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 750;
  font-size: 13px;
}
.actions button:hover, .small-btn:hover { border-color: #cfd9ff; box-shadow: 0 8px 18px rgba(16, 24, 40, .06); }
.primary { border-color: var(--blue) !important; background: var(--blue) !important; color: white !important; }
.danger { color: var(--red) !important; }

.editor-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.editor-title h1 { font-size: 24px; }
.editor { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.15fr) minmax(280px, .75fr); min-height: calc(100vh - 132px); background: #fbfcff; }
.source-pane, .edit-pane, .preview-pane { padding: 24px 28px; border-bottom: 1px solid var(--line); }
.source-pane { border-right: 1px solid var(--line); }
.edit-pane { border-right: 1px solid var(--line); background: white; }
.preview-pane { background: #f6f9ff; }
pre {
  white-space: pre-wrap;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
textarea {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  line-height: 1.58;
  resize: vertical;
  background: #fbfcff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
}
select, input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--surface);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.wide-btn {
  width: 100%;
  border: 0;
  background: var(--blue);
  color: white;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 850;
}
.post-preview {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  padding: 16px;
  box-shadow: var(--shadow);
}
.preview-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  margin-right: 8px;
  background: var(--blue);
  color: white;
  font-weight: 850;
  font-size: 12px;
}
.post-preview p {
  white-space: pre-wrap;
  line-height: 1.65;
}
.post-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.preview-pane label {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}
.sync-grid { display: grid; grid-template-columns: repeat(12, 1fr); grid-auto-flow: dense; gap: 14px; padding: 22px; }
.sync-grid .span-8 { grid-column: span 8; }
.sync-grid .span-4 { grid-column: span 4; }
.sync-grid .span-6 { grid-column: span 6; }
.run-row { border-top: 1px solid var(--line); padding: 10px 0; }
.sync-status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 14px 0;
}
.sync-status strong {
  color: var(--green);
  font-size: 30px;
  line-height: 1;
}
.sync-status.fetch strong, .sync-status.write strong { color: var(--blue); }
.sync-status.error strong { color: var(--red); }
.sync-status span { color: var(--muted); }
.sync-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 18px;
}
.sync-bar {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}
.sync-bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f6df6, #7aa2ff);
  transform: translateX(-100%);
}
.sync-flow.running .sync-bar span {
  animation: sync-progress 1.1s ease-in-out infinite;
}
.sync-flow.done .sync-bar span {
  transform: translateX(0);
}
.sync-flow.error .sync-bar span {
  background: var(--red);
  transform: translateX(0);
}
.sync-flow > span {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  color: var(--muted);
  background: #fbfcff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.sync-flow > span.active {
  border-color: #bfd0ff;
  color: var(--blue);
  background: #eef4ff;
}
.sync-flow > span.done {
  border-color: #b9f2d4;
  color: #097245;
  background: #effcf6;
}
@keyframes sync-progress {
  0% { transform: translateX(-100%); }
  55% { transform: translateX(-18%); }
  100% { transform: translateX(100%); }
}
.timeline { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100vh - 132px); background: #fbfcff; }
.schedule-top { background: linear-gradient(180deg, rgba(248,251,255,.98), rgba(241,246,252,.94)); }
.schedule-planner { grid-template-columns: 340px minmax(0, 1fr); background: #eef3f8; }
.approved-pool {
  border-right: 1px solid var(--line);
  padding: 18px;
  background: #f9fbfd;
}
.pool-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.pool-head span {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e8eef7;
  color: var(--ink);
  font-weight: 850;
}
.empty-note {
  border: 1px dashed #c8d3df;
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  background: #ffffff;
}
.confirm-bar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  background: #ffffff;
}
.confirm-bar p { margin: 4px 0 0; }
.schedule-board { min-width: 0; }
.slot-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
  overflow-x: auto;
}
.day-column {
  overflow: hidden;
  border: 1px solid #d8e1eb;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(55, 73, 92, .08);
}
.day-column header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #dfe7ef;
  background: #f7fafc;
  font-weight: 900;
}
.day-column header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}
.slot {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  min-height: 76px;
  border-bottom: 1px solid #edf1f5;
  background: #ffffff;
  padding: 12px 14px;
}
.slot:last-child { border-bottom: 0; }
.slot time {
  display: block;
  padding-top: 6px;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.slot-drop {
  min-height: 52px;
  border: 1px dashed transparent;
  border-radius: 12px;
  padding: 6px;
  background: #f8fafc;
}
.slot-drop > span {
  display: block;
  padding: 11px 10px;
  color: #9aa6b2;
  font-size: 12px;
}
.slot.dragover .slot-drop {
  border-color: #8fb0ff;
  background: #edf4ff;
}
.mini-card {
  border: 1px solid #dfe7ef;
  background: white;
  border-radius: 12px;
  padding: 10px;
  margin-top: 10px;
  cursor: grab;
  box-shadow: 0 10px 20px rgba(55, 73, 92, .06);
}
.slot .mini-card {
  margin-top: 0;
  border-color: #cfd9ff;
  background: #ffffff;
}
.mini-card .item-head { gap: 5px; }
.mini-card .source-line {
  flex-basis: auto;
  color: #667085;
}
.mini-card .item-title {
  flex-basis: 100%;
  font-size: 13px;
  line-height: 1.35;
}
.mini-card .copy {
  margin: 8px 0 0;
  max-width: none;
  color: #475467;
  font-size: 12px;
  line-height: 1.45;
}
.mini-card .actions { margin-top: 8px; }
.unschedule-btn {
  margin-top: 6px;
  padding: 6px 9px;
}
.tabbar { display: none; }

@media (max-width: 980px) {
  .app-shell { display: block; padding-bottom: 70px; }
  .nav { display: none; }
  .appbar { height: auto; min-height: 58px; padding: 0 14px; overflow-x: auto; }
  .appbar nav { gap: 18px; min-width: max-content; }
  .search, .user-dot { display: none; }
  .main { display: block; }
  .rail { display: none; }
  .stage { border-right: 0; }
  .editor, .timeline { display: block; }
  .confirm-bar { align-items: stretch; flex-direction: column; }
  .source-pane, .edit-pane { border-right: 0; }
  .sync-grid { display: block; padding: 14px; }
  .sync-grid .panel { margin-bottom: 14px; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media-choice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed-item { margin: 12px 12px; grid-template-columns: 1fr; }
  .avatar { display: none; }
  .topbar { top: 58px; padding: 18px 14px; }
  h1 { font-size: 26px; }
  .slot-grid { grid-template-columns: 1fr; overflow: visible; padding: 14px; }
  .approved-pool { border-right: 0; border-bottom: 1px solid var(--line); }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
    z-index: 5;
  }
  .tabbar button { border: 0; background: transparent; padding: 12px 6px; font-weight: 760; color: var(--muted); }
  .tabbar button.active { color: var(--ink); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
