/* 小红书发布面板 —— 浅色主题，扁平风格 */

:root {
  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --surface-2: #F1EFE8;
  --border: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);
  --text: #2C2C2A;
  --text-2: #5F5E5A;
  --text-3: #888780;
  --brand: #FF2442;
  --brand-dark: #D91A34;
  --ok: #1D9E75;
  --warn: #EF9F27;
  --err: #E24B4A;
  --info: #378ADD;
  --purple: #7F77DD;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

/* hidden 属性必须压过任何 display 声明，否则元素切换 hidden 时不生效 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 500; }

/* ── 顶栏 ─────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.topbar-title h1 { font-size: 15px; line-height: 1.3; }
.topbar-sub { font-size: 12px; color: var(--text-3); }

.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #FF2442, #FF6B4A);
  flex-shrink: 0;
}
.brand-mark.sm { width: 30px; height: 30px; border-radius: 8px; }

/* MCP 状态 */
.mcp-status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface-2); font-size: 12px; color: var(--text-2);
}
.mcp-status .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-3);
}
.mcp-refresh {
  background: none; border: none; cursor: pointer; padding: 0 0 0 2px;
  color: inherit; font-size: 13px; line-height: 1; opacity: .65;
}
.mcp-refresh:hover { opacity: 1; }
.mcp-status.online .dot { background: var(--ok); }
.mcp-status.online { color: var(--ok); }
.mcp-status.offline .dot { background: var(--err); }
.mcp-status.offline { color: var(--err); }

.stat-chips { display: flex; gap: 6px; }
.chip {
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--text-2);
}
.chip b { font-weight: 500; color: var(--text); }

/* ── 布局 ─────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: 16px;
  padding: 16px 24px 32px;
  align-items: start;
}

@media (max-width: 1280px) {
  .layout { grid-template-columns: 1fr 1fr; }
  .calendar-panel { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .calendar-panel { order: 0; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel[hidden] { display: none; }

.panel-title { font-size: 14px; margin-bottom: 12px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.panel-head .panel-title { margin-bottom: 0; }

/* ── 按钮 ─────────────────────────────────────────── */
.btn {
  font-family: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: var(--radius);
  padding: 8px 14px; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-accent { background: var(--info); border-color: var(--info); color: #fff; }
.btn-accent:hover { filter: brightness(.93); }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover { filter: brightness(.93); }
.btn-ghost { background: var(--surface); color: var(--text-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* 按钮组（带副标题） */
.btn-grid { display: grid; gap: 8px; margin-top: 12px; }
.btn-grid .btn {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px; padding: 10px 14px; text-align: left;
}
.btn-main { font-size: 13px; font-weight: 500; }
.btn-sub { font-size: 11px; opacity: .8; }

/* ── 表单 ─────────────────────────────────────────── */
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.field.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.field.inline > span { margin: 0; }
input[type=text], input[type=password], input[type=date] {
  width: 100%; font-family: inherit; font-size: 13px;
  padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
}
input:focus { outline: 2px solid rgba(55, 138, 221, .35); outline-offset: -1px; }
.field-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { font-size: 11px; color: var(--text-3); }

/* ── 进度条 ───────────────────────────────────────── */
.progress-wrap { margin-top: 14px; }
.progress-bar {
  height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; background: var(--brand);
  border-radius: 999px; transition: width .3s ease;
}
.progress-text { font-size: 12px; color: var(--text-2); margin-top: 6px; }

/* ── 日历 ─────────────────────────────────────────── */
.calendar { display: grid; gap: 14px; }
.day-block { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; background: var(--surface-2);
  font-size: 13px; font-weight: 500;
}
.day-theme { font-size: 12px; color: var(--text-2); font-weight: 400; }
.day-slots { display: grid; grid-template-columns: repeat(3, 1fr); }

@media (max-width: 720px) { .day-slots { grid-template-columns: 1fr; } }

.note-card {
  display: flex; gap: 12px; padding: 12px 14px;
  border-right: 1px solid var(--border); position: relative;
}
.note-card:last-child { border-right: none; }
@media (max-width: 720px) {
  .note-card { border-right: none; border-bottom: 1px solid var(--border); }
  .note-card:last-child { border-bottom: none; }
}
.note-card:hover { background: rgba(0, 0, 0, .015); }

.note-cover {
  width: 66px; height: 88px; object-fit: cover; flex-shrink: 0;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  cursor: zoom-in;
}
.note-info { flex: 1; min-width: 0; }
.note-title {
  font-size: 13px; font-weight: 500; line-height: 1.45;
  margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.note-meta {
  font-size: 11px; color: var(--text-3);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.note-actions { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

.status-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 999px; font-size: 11px;
  background: var(--surface-2); color: var(--text-2);
}
.status-tag.published { background: rgba(29,158,117,.13); color: var(--ok); }
.status-tag.scheduled { background: rgba(55,138,221,.13); color: var(--info); }
.status-tag.failed { background: rgba(226,75,74,.13); color: var(--err); }
.status-tag.pending { background: rgba(136,135,128,.16); color: var(--text-2); }

.note-check {
  width: 15px; height: 15px; accent-color: var(--brand);
  position: absolute; top: 12px; right: 12px; cursor: pointer;
}

/* 图例 */
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); }
.sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.sw.published { background: var(--ok); }
.sw.scheduled { background: var(--info); }
.sw.failed { background: var(--err); }
.sw.pending { background: var(--text-3); }

/* ── 侧栏 ─────────────────────────────────────────── */
.side { display: grid; gap: 16px; }
.log-box {
  height: 300px; overflow-y: auto; background: var(--surface-2);
  border-radius: var(--radius); padding: 10px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 11.5px; line-height: 1.65;
}
.log-line { display: flex; gap: 7px; padding: 1px 0; }
.log-ts { color: var(--text-3); flex-shrink: 0; }
.log-msg { word-break: break-word; }
.log-line.info .log-msg { color: var(--text-2); }
.log-line.success .log-msg { color: var(--ok); }
.log-line.error .log-msg { color: var(--err); }
.log-line.warn .log-msg { color: var(--warn); }
.log-line.progress .log-msg { color: var(--info); }

.side-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.sse-state { font-size: 11px; color: var(--text-3); }
.sse-state.on { color: var(--ok); }

.qr-box {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
  display: flex; align-items: center; justify-content: center;
}
.qr-box img { max-width: 100%; display: block; image-rendering: pixelated; }

/* ── 弹层 ─────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: flex;
         align-items: center; justify-content: center; padding: 24px; }
/* hidden 属性必须能压过 display:flex，否则弹层会一直显示 */
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-card {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  max-width: 620px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 26px; line-height: 1; color: var(--text-3); cursor: pointer;
}
.modal-cover {
  width: 100%; max-width: 300px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 16px; display: block;
}
.modal-title { font-size: 16px; margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.modal-body pre {
  white-space: pre-wrap; word-break: break-word; background: var(--surface-2);
  padding: 14px; border-radius: var(--radius); font-size: 12.5px;
  line-height: 1.75; margin: 0 0 12px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255, 36, 66, .09); color: var(--brand);
}
.kv-row { display: flex; gap: 10px; font-size: 12px; padding: 3px 0; }
.kv-row .k { color: var(--text-3); width: 68px; flex-shrink: 0; }

/* ── 登录页 ───────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-wrap { width: 100%; max-width: 380px; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { font-size: 16px; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.login-err { color: var(--err); font-size: 12px; min-height: 18px; margin-bottom: 8px; }
.login-hint {
  font-size: 11px; color: var(--warn); background: rgba(239, 159, 39, .09);
  border: 1px solid rgba(239, 159, 39, .25); border-radius: 8px;
  padding: 7px 10px; margin-bottom: 10px; line-height: 1.55;
}
.login-hint.danger {
  color: var(--err); background: rgba(224, 49, 49, .08);
  border-color: rgba(224, 49, 49, .3);
}
.login-hint b { font-weight: 700; }
.pw-wrap input.has-error {
  border-color: var(--err);
  box-shadow: 0 0 0 3px rgba(224, 49, 49, .1);
}
.login-foot { font-size: 11px; color: var(--text-3); text-align: center; margin: 16px 0 0; }
.login-foot code {
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
  font-size: 10.5px; font-family: "SF Mono", Consolas, monospace;
}

/* ── 密码显示/隐藏 ─────────────────────────────────── */
.field-label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 5px;
}
.field-label-row > span { font-size: 12px; color: var(--text-2); }

.toggle-pw {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: var(--text-3); font-size: 11.5px; font-family: inherit;
  border-radius: 5px; transition: color .15s, background .15s;
}
.toggle-pw:hover { color: var(--text-2); background: var(--surface-2); }
.toggle-pw.on { color: var(--brand); }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 38px; }

/* 眼睛图标（纯 CSS） */
.eye {
  display: inline-block; width: 15px; height: 10px;
  border: 1.4px solid currentColor; border-radius: 50% / 60%;
  position: relative; flex-shrink: 0;
}
.eye::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 3.4px; height: 3.4px; border-radius: 50%;
  background: currentColor; transform: translate(-50%, -50%);
}
.toggle-pw.on .eye, .pw-peek.on .eye { border-color: var(--brand); }
.toggle-pw.on .eye::after, .pw-peek.on .eye::after { background: var(--brand); }

.pw-peek {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; background: none; border: none; cursor: pointer;
  color: var(--text-3); border-radius: 6px; padding: 0;
  transition: color .15s, background .15s;
}
.pw-peek:hover { color: var(--text-2); background: var(--surface-2); }
.pw-peek.on { color: var(--brand); }

.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--brand); font-size: 11px; font-family: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--brand-dark); }

/* 忘记密码弹层 */
.modal-sm { max-width: 460px; }
.modal-h3 { font-size: 15px; margin-bottom: 10px; }
.modal-p { margin-bottom: 8px; }
.cmd-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 13px; margin: 0 0 12px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 11.5px; line-height: 1.7; white-space: pre-wrap;
  word-break: break-all; color: var(--text);
}

/* 密码值展示 */
.pw-val {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 7px;
  font-family: "SF Mono", Consolas, monospace; font-size: 12px;
  color: var(--brand); user-select: all;
}

/* ── 扫码登录 ─────────────────────────────────────────── */
.login-head { margin-bottom: 22px; }

.scan-box { text-align: center; }

.qr-frame {
  width: 100%; max-width: 300px; aspect-ratio: 1 / 1;
  margin: 0 auto 16px; padding: 14px;
  border: 1px solid var(--border); border-radius: 14px;
  background: #fff; display: flex; align-items: center;
  justify-content: center; overflow: hidden; position: relative;
  box-sizing: border-box;
}
/* 二维码：后端已做整数倍放大，这里保持锐利不插值 */
.qr-frame img {
  width: 100%; height: 100%; object-fit: contain;
  image-rendering: pixelated; image-rendering: crisp-edges;
}

/* [hidden] 默认 display:none 会被下面的 display:flex 覆盖，必须显式声明 */
.qr-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; color: var(--text-3); font-size: 12px;
}
.qr-loading[hidden] { display: none; }
.qr-loading p { margin: 0; }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scan-hint { font-size: 12.5px; color: var(--text-2); margin: 0 0 10px; }
.scan-hint.warn { color: var(--warn); }

.scan-status {
  font-size: 12px; min-height: 20px; color: var(--text-3);
  margin-bottom: 12px; line-height: 1.6;
}
.scan-status.ok { color: var(--ok, #16a34a); font-weight: 600; }
.scan-status.err { color: var(--err); font-weight: 600; }

.pw-fallback {
  margin-top: 20px; border-top: 1px solid var(--border);
  padding-top: 14px;
}
.pw-fallback summary {
  font-size: 12px; color: var(--text-3); cursor: pointer;
  list-style: none; text-align: center; user-select: none;
}
.pw-fallback summary::-webkit-details-marker { display: none; }
.pw-fallback summary:hover { color: var(--text-2); }
.pw-fallback[open] summary { margin-bottom: 14px; }
.pw-fallback .field { margin-bottom: 12px; }

/* ── Toast ────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
}
.toast {
  background: var(--text); color: #fff; padding: 10px 14px;
  border-radius: var(--radius); font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  animation: slideIn .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.16); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
