:root {
  --bg: #0b0e11;
  --panel: #12161c;
  --line: #1e2329;
  --text: #eaecef;
  --muted: #848e9c;
  --yellow: #f0b90b;
  --yellow-dark: #c99400;
  --green: #0ecb81;
  --red: #f6465d;
  --radius: 14px;
  --thumb-w: 112px;
  --thumb-h: 96px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(240, 185, 11, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  min-height: 0;
}

.topbar, .panel-head, .toolbar, .phone-head, .modal-actions, .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  flex: 0 0 auto;
  align-items: center;
  gap: 16px;
}
.topbar-brand { min-width: 0; }
.eyebrow {
  margin: 0 0 2px;
  color: var(--yellow);
  letter-spacing: 0.08em;
  font-size: 11px;
  text-transform: uppercase;
}
h1, h2, h3 { margin: 0; }
h1 { font-size: 20px; line-height: 1.2; }
h2 { font-size: 15px; }
h3 { font-size: 18px; }

.topbar-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }

.model-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}
.model-select {
  max-width: 260px;
  border: 1px solid rgba(240, 185, 11, 0.4);
  background: #181a20;
  color: var(--yellow);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.model-select:disabled {
  opacity: 0.7;
}
.model-picker .btn {
  height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

.badge {
  border: 1px solid var(--line);
  background: #181a20;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.badge-muted { color: var(--muted); }
.badge-ai { color: var(--yellow); border-color: rgba(240, 185, 11, 0.4); }
.badge-ok { color: var(--green); border-color: rgba(14, 203, 129, 0.35); }
.badge-warn { color: var(--red); border-color: rgba(246, 70, 93, 0.4); }

.toolbar, .ticker, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.source-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}
.watch-panel {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.watch-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.watch-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.watch-head strong { color: var(--yellow); font-size: 14px; }
.watch-head p { margin: 4px 0 0; }
.watch-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.watch-panel.collapsed .watch-form { display: none; }
.watch-field {
  display: grid;
  gap: 6px;
  min-width: 132px;
  flex: 1;
}
.watch-field span {
  color: var(--muted);
  font-size: 12px;
}
.watch-field select,
.watch-field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b0e11;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
}
.watch-num { flex: 0 0 128px; min-width: 110px; }
.watch-form .btn { height: 36px; }
.watch-field .mode-switch { flex-wrap: wrap; }
.watch-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  max-height: 72px;
  overflow: auto;
}
.watch-rule {
  border: 1px solid var(--line);
  background: #181a20;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}
.watch-rule.active {
  border-color: var(--yellow);
  color: var(--yellow);
}
.watch-rule.on {
  box-shadow: inset 0 0 0 1px rgba(14, 203, 129, 0.45);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #181a20;
  border: 1px solid var(--line);
  position: relative;
  flex: 0 0 auto;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}
.switch input:checked + .switch-ui {
  background: rgba(240, 185, 11, 0.22);
  border-color: var(--yellow);
}
.switch input:checked + .switch-ui::after {
  transform: translateX(20px);
  background: var(--yellow);
}
.switch-label { font-size: 13px; color: var(--text); }

.source-btn, .section-btn, .category-btn {
  border: 1px solid var(--line);
  background: #181a20;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.source-btn.active, .section-btn.active, .category-btn.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #1e2329;
  font-weight: 700;
}
.sections, .categories {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.categories { margin-top: 6px; margin-bottom: 8px; }
.sections { margin-bottom: 0; }

.toolbar {
  padding: 0;
  margin: 0;
  gap: 12px;
  flex-wrap: wrap;
  border: 0;
  background: transparent;
}

.types { display: flex; gap: 8px; flex-wrap: wrap; }

.type-btn, .btn {
  border: 1px solid var(--line);
  background: #181a20;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.type-btn.active, .btn-primary {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #1e2329;
  font-weight: 700;
}
.btn-publish {
  background: var(--green);
  border-color: var(--green);
  color: #08130e;
  font-weight: 700;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ticker {
  padding: 8px 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.ticker strong { color: var(--text); }
.up { color: var(--green); }
.down { color: var(--red); }

.status {
  min-height: 20px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}
.status.error { color: var(--red); }
.status.ok { color: var(--green); }

.workbench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr) 280px;
  gap: 12px;
}

.col-list,
.col-work,
.col-side {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 12px;
}

.panel {
  padding: 12px;
  min-height: 0;
}
.panel-head { margin-bottom: 8px; color: var(--muted); }
.panel-head h2 { color: var(--text); }
.list-head-copy { min-width: 0; }
.list-head-copy .muted { display: block; margin-top: 4px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.muted { color: var(--muted); font-size: 12px; }

.schedule-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.articles-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.articles-panel .panel-head {
  align-items: flex-start;
  flex-wrap: wrap;
}

.articles {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}
.article-card {
  display: grid;
  grid-template-columns: var(--thumb-w) minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  text-align: left;
  width: 100%;
  height: var(--thumb-h);
  min-height: var(--thumb-h);
  max-height: var(--thumb-h);
  border: 1px solid var(--line);
  background: #0b0e11;
  color: inherit;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  flex: 0 0 auto;
}
.cover-wrap {
  width: var(--thumb-w);
  height: var(--thumb-h);
  overflow: hidden;
  background: #181a20;
  flex: 0 0 var(--thumb-w);
}
.article-card img,
.cover-fallback {
  width: var(--thumb-w);
  height: var(--thumb-h);
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center top;
  background: #181a20;
  display: block;
}
.cover-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.article-card > div {
  padding: 6px 10px 6px 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.article-card strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
}
.article-card small {
  color: var(--muted);
  display: block;
  margin: 2px 0;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card:hover,
.article-card.selected { border-color: rgba(240, 185, 11, 0.55); }
.article-card.selected { box-shadow: inset 0 0 0 1px rgba(240, 185, 11, 0.4); }
.article-card.published { border-color: rgba(14, 203, 129, 0.5); }
.article-card.published.selected { box-shadow: inset 0 0 0 1px rgba(14, 203, 129, 0.5); }
.article-card.failed { border-color: rgba(246, 70, 93, 0.5); }
.article-card.failed.selected { box-shadow: inset 0 0 0 1px rgba(246, 70, 93, 0.5); }
.published-badge {
  display: inline-block;
  margin-top: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(14, 203, 129, 0.16);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  width: fit-content;
}
.article-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.failed-badge {
  background: rgba(246, 70, 93, 0.16);
  color: var(--red);
}
.mark-published-btn {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(14, 203, 129, 0.45);
  background: transparent;
  color: var(--green);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  width: fit-content;
  cursor: pointer;
  line-height: 1.4;
  flex: 0 0 auto;
}
.mark-published-btn:hover,
.mark-published-btn:focus-visible {
  background: rgba(14, 203, 129, 0.16);
}
.mark-published-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.published-banner {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(14, 203, 129, 0.12);
  border: 1px solid rgba(14, 203, 129, 0.4);
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
}
.published-banner a {
  color: #5ee4b0;
  margin-left: 8px;
}
.published-banner.failed {
  background: rgba(246, 70, 93, 0.12);
  border-color: rgba(246, 70, 93, 0.4);
  color: var(--red);
}

.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.version-select {
  border: 1px solid var(--line);
  background: #181a20;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  min-width: 180px;
  max-width: 280px;
}
.done-banner {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(14, 203, 129, 0.12);
  border: 1px solid rgba(14, 203, 129, 0.4);
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
}
.image-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.image-actions .btn { padding: 6px 12px; font-size: 12px; }
.editor-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}
.image-block img { pointer-events: none; }
.log-panel,
.publish-log-panel {
  margin: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.log-panel { flex: 1.2; }
.publish-log-panel { flex: 0.8; }
.log-panel .panel-head {
  flex-wrap: wrap;
}
.log-view {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #0b0e11;
  border-radius: 12px;
  padding: 10px;
  color: #7dffb3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.publish-options { display: grid; gap: 8px; margin-bottom: 10px; }
.mode-switch { display: flex; gap: 8px; }
.mode-btn {
  border: 1px solid var(--line);
  background: #181a20;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #1e2329;
  font-weight: 700;
}
.title-input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b0e11;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
}
.preview-title {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.4;
}
.preview-cover {
  width: 100%;
  height: 160px;
  object-fit: cover;
  object-position: center;
  border-radius: 12px;
  margin-bottom: 12px;
  background: #181a20;
}
.hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}
.cover-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(240, 185, 11, 0.18);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 700;
}
.preview-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 10px;
}

.editor-panel,
.preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.block-editor {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}
.empty-editor {
  color: var(--muted);
  padding: 28px 12px;
  text-align: center;
}
.block {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  background: #0b0e11;
  border-radius: 12px;
  padding: 8px;
}
.block.dragging { opacity: 0.55; }
.block.drag-over { border-color: var(--yellow); }
.handle {
  cursor: grab;
  color: var(--muted);
  display: grid;
  place-items: center;
  user-select: none;
}
.block textarea {
  min-height: 100px;
  width: 100%;
  resize: vertical;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px;
  line-height: 1.7;
  font-size: 15px;
  font-family: inherit;
}
.image-block img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: #181a20;
  border-radius: 8px;
}
.image-block small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}
.img-error { color: var(--red); font-size: 13px; }

.phone-body {
  display: grid;
  gap: 12px;
  white-space: normal;
  line-height: 1.75;
  font-size: 14px;
}
.phone-body p { margin: 0; white-space: pre-wrap; }
.phone-body img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border-radius: 12px;
  background: #181a20;
}

.actions { margin-top: 10px; justify-content: flex-end; flex: 0 0 auto; }

.phone {
  background: #0b0e11;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.phone-head { justify-content: flex-start; margin-bottom: 12px; }
.phone-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yellow);
  color: #1e2329;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.modal-card p { color: var(--muted); }
.modal-actions { margin-top: 18px; }

.publish-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.publish-log-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 2px;
}
.publish-log-item {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  background: #0b0e11;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
}
.publish-log-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.publish-log-title {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.publish-log-item {
  color: inherit;
  text-decoration: none;
}
a.publish-log-item:hover .publish-log-title {
  color: var(--yellow);
}
.publish-log-item.failed {
  border-color: rgba(246, 70, 93, 0.4);
}
.publish-log-item.failed .publish-log-time,
.publish-log-item.failed .publish-log-title {
  color: var(--red);
}

body.login-body {
  overflow: auto;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: 0; color: var(--muted); font-size: 13px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-field input {
  background: #0b0e11;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}
.login-field input:focus {
  outline: none;
  border-color: rgba(240, 185, 11, 0.55);
}
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.login-error { margin: 0; color: var(--red); font-size: 13px; }

@media (max-width: 1280px) {
  .workbench { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .col-side { grid-column: 1 / -1; flex-direction: row; max-height: 240px; }
  .log-panel, .publish-log-panel { flex: 1; }
}
@media (max-width: 980px) {
  html, body { height: auto; overflow: auto; }
  .app { height: auto; }
  .workbench, .workspace, .col-side { grid-template-columns: 1fr; display: flex; flex-direction: column; }
  .col-list, .col-work, .col-side { max-height: none; }
  .articles { max-height: 360px; }
  .block-editor, .phone { min-height: 240px; }
  .source-bar { justify-content: flex-start; overflow: auto; }
}
