/* ============== 基础 ============== */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* 全局 .hidden 工具类(对任何元素都生效) */
.hidden { display: none !important; }

:root {
  --bg: #f7f7f8;
  --bg-card: #ffffff;
  --bg-soft: #fafafa;
  --bg-hover: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2328;
  --text-soft: #6b7280;
  --text-faint: #9ca3af;
  --primary: #ff2442;     /* 小红书红 */
  --primary-hover: #e01e3a;
  --primary-soft: #ffe8eb;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
}

html, body { height: auto; min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-y: auto;
}

/* ============== 顶部 ============== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.2;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============== 用户胶囊 + 下拉(大厂模式) ============== */
.user-menu {
  position: relative;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s ease;
}

.user-pill:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.user-pill[aria-expanded="true"] {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.user-pill .avatar {
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-pill .name {
  font-size: 13px;
  font-weight: 500;
  max-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pill .caret {
  font-size: 10px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.user-pill[aria-expanded="true"] .caret {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  animation: dropdown-in 0.15s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-dropdown-header .dd-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-dropdown-header .dd-sub {
  font-size: 11px;
  color: var(--text-soft);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  transition: background 0.1s;
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
}

.user-dropdown-item.danger {
  color: var(--danger);
}

.user-dropdown-item.danger:hover {
  background: #fef2f2;
}

/* ============== 布局 ============== */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 8px;
}

.sidebar-header h2 { font-size: 15px; font-weight: 600; }

.search {
  margin: 0 16px 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-soft);
}

.search:focus { outline: none; border-color: var(--primary); }

.post-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.post-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.post-item:hover { background: var(--bg-soft); }
.post-item.active { background: var(--primary-soft); border-color: var(--primary); }

.post-item .title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-item .date { font-size: 11px; color: var(--text-soft); margin-top: 4px; }

.empty {
  padding: 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

/* ============== 主区 ============== */
.workspace {
  padding: 16px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.card-header h3 { font-size: 14px; font-weight: 600; }
.card-header .meta { font-size: 12px; color: var(--text-soft); }
.header-actions { display: flex; align-items: center; gap: 12px; }

.card-body { padding: 16px; }

.original-content {
  font-size: 13px;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, monospace;
  background: var(--bg-soft);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  line-height: 1.6;
}

.original-content.empty { color: var(--text-soft); font-family: inherit; }

/* ============== 控制栏 ============== */
.control-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px;
  flex-wrap: wrap;
}

.control-bar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); }

#style-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-card);
}

.status { font-size: 12px; color: var(--text-soft); }
.status.error { color: var(--danger); }
.status.success { color: var(--success); }

/* ============== 表单 ============== */
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin: 12px 0 6px;
  font-weight: 500;
}

.field-label:first-child { margin-top: 0; }

#result-title, #result-tags, .prompt-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
}

#result-title:focus, #result-tags:focus, .prompt-input:focus {
  outline: none; border-color: var(--primary);
}

#result-content {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  background: var(--bg-card);
  min-height: 200px;
}

#result-content:focus { outline: none; border-color: var(--primary); }

.disclosure-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
}

.disclosure-row.hidden { display: none; }

.warn-badge {
  background: var(--warn);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ============== 按钮 ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-soft); border-color: var(--text-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost { background: transparent; }
.btn-icon { padding: 4px 10px; font-size: 16px; }

.btn-mini {
  padding: 4px 8px;
  font-size: 11px;
}

/* ============== 图片 ============== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.image-slot {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 10px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot-label { font-size: 12px; font-weight: 500; color: var(--text-soft); }

.slot-preview {
  aspect-ratio: 3/4;
  max-height: 160px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-soft);
  overflow: hidden;
  position: relative;
}

.slot-preview:not(.empty) { border-style: solid; }

.slot-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.slot-actions { display: flex; gap: 4px; }
.file-input { display: none; }

.prompt-input { font-size: 12px; padding: 6px 8px; }

/* ============== Modal 通用 ============== */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 18, 22, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: modal-bg-in 0.18s ease;
}

@keyframes modal-bg-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-content-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-content-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h3 { font-size: 16px; }
.modal-tip { font-size: 12px; color: var(--text-soft); }

#paste-title, #paste-markdown {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-soft);
}

#paste-markdown { font-family: ui-monospace, monospace; resize: vertical; min-height: 200px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 通用 modal 关闭按钮(右上角) */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  font-family: inherit;
  padding: 0;
  z-index: 2;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-close:active {
  transform: scale(0.95);
}

/* ============== Auth Modal(大厂风格) ============== */
.auth-modal {
  width: 92%;
  max-width: 420px;
  padding: 36px 36px 28px;
  gap: 0;
  align-items: stretch;
  text-align: center;
  background: var(--bg-card);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0 auto 18px;
  display: block;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(255, 36, 66, 0.15);
}

.auth-modal h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.auth-sub {
  font-size: 13px;
  color: var(--text-soft);
  margin: 6px 0 24px;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.auth-field {
  position: relative;
  width: 100%;
}

.auth-field input {
  width: 100%;
  height: 46px;
  padding: 16px 14px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  transition: all 0.15s;
  outline: none;
}

.auth-field input:hover {
  border-color: var(--border-strong);
}

.auth-field input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(255, 36, 66, 0.12);
}

.auth-field label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-soft);
  pointer-events: none;
  transition: all 0.15s ease;
  background: transparent;
  padding: 0 4px;
}

.auth-field input:focus + label,
.auth-field input:not(:placeholder-shown) + label {
  top: 8px;
  transform: translateY(0);
  font-size: 11px;
  color: var(--text-soft);
  background: var(--bg-card);
  padding: 0 4px;
}

.auth-field input:focus + label {
  color: var(--primary);
}

.auth-error {
  font-size: 12px;
  color: var(--danger);
  text-align: left;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  line-height: 1.4;
}

.auth-error.hidden { display: none; }

.btn-auth-submit {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.btn-auth-submit:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 36, 66, 0.25);
}

.btn-auth-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-auth-submit.loading::after {
  content: "...";
  animation: dots 1s infinite;
}

@keyframes dots {
  0%, 20%   { content: "."; }
  40%       { content: ".."; }
  60%, 100% { content: "..."; }
}

.auth-switch {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-soft);
  text-align: center;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  margin-left: 4px;
  cursor: pointer;
  transition: opacity 0.1s;
}

.auth-switch a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* ============== 用户菜单旧版(已废弃) ============== */
.user-info { display: none; }

/* ============== Config Modal ============== */
.config-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-empty {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.config-item .config-info {
  flex: 1;
  min-width: 0;
}
.config-item .config-info strong {
  display: inline-block;
  margin-right: 8px;
}
.config-item .config-meta {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}
.config-item .config-actions {
  display: flex;
  gap: 6px;
}

.badge-default {
  display: inline-block;
  padding: 1px 6px;
  background: var(--success);
  color: white;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
}

.btn-set-default {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
}
.btn-set-default:hover { color: var(--primary); border-color: var(--primary); }

.btn-del {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
}
.btn-del:hover { color: var(--danger); border-color: var(--danger); }

.config-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
}

/* ============== Toast ============== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transition: opacity 0.2s;
}

.toast.hidden { opacity: 0; pointer-events: none; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ============== 滚动条 ============== */
.post-list::-webkit-scrollbar,
.original-content::-webkit-scrollbar { width: 8px; }

.post-list::-webkit-scrollbar-thumb,
.original-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
