:root {
  --bg: #fff8f8;
  --surface: #ffffff;
  --ink: #1f1f1f;
  --muted: #8a8a8a;
  --line: #f0e4e6;
  --brand: #ff2442;
  --brand-hover: #e01f3a;
  --brand-soft: #ffe8ec;
  --ok: #2f9b63;
  --warn: #c47a16;
  --danger: #d14343;
  --shadow: 0 10px 30px rgba(255, 36, 66, 0.08);
  --radius: 16px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 18px;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,36,66,.12), transparent 36%),
    radial-gradient(circle at 88% 12%, rgba(255,120,140,.12), transparent 28%),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 36px 28px 28px; box-shadow: var(--shadow);
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800;
}
.brand-row strong { display: block; font-size: 18px; }
.brand-row span { color: var(--muted); font-size: 12px; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.02em; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; color: #555; }
.control {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.control:focus { border-color: rgba(255,36,66,.45); box-shadow: 0 0 0 3px rgba(255,36,66,.12); }
textarea.control { min-height: 88px; resize: vertical; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 11px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
}
.btn:hover { border-color: #e7cfd4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.auth-submit { width: 100%; margin-top: 8px; }
.auth-error { min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 13px; }
.auth-note { margin-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }

.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 58px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 18px; background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--danger); }
.page { width: min(1080px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 80px; }
.steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 6px;
}
.step-tab {
  border: 0; background: transparent; border-radius: 14px; padding: 12px 10px; text-align: left;
}
.step-tab b { display: block; font-size: 11px; color: var(--muted); }
.step-tab strong { display: block; margin-top: 2px; }
.step-tab.active { background: var(--brand-soft); color: var(--brand); }
.step-tab.active b { color: var(--brand); }
.step-tab.locked { opacity: .45; cursor: not-allowed; }
.app.is-busy .step-tab:not(.active) { opacity: .45; cursor: not-allowed; }
.app.is-busy .hero-panel,
.app.is-busy #view-topics .topic-toolbar,
.app.is-busy #titlePrefs,
.app.is-busy .sticky-bar,
.app.is-busy .editor-panel,
.app.is-busy .topbar-left .btn {
  pointer-events: none;
  opacity: .72;
}
.app.is-busy #view-topics .topic-grid { pointer-events: none; opacity: .85; }

.work-banner {
  margin-bottom: 16px; padding: 16px 18px; border: 1px solid rgba(255,36,66,.18);
  border-radius: 18px; background: linear-gradient(180deg, #fff, var(--brand-soft));
  box-shadow: var(--shadow);
}
.work-banner-top {
  display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap;
}
.work-banner-copy { display: flex; gap: 12px; align-items: flex-start; }
.work-banner-copy strong { display: block; font-size: 15px; }
.work-banner-copy p { margin: 4px 0 0; color: #8a3a46; font-size: 13px; }
.work-banner-actions { display: flex; align-items: center; gap: 10px; }
.work-spinner {
  width: 22px; height: 22px; margin-top: 2px; border-radius: 50%;
  border: 2px solid rgba(255,36,66,.2); border-top-color: var(--brand);
  animation: spin .8s linear infinite; flex: 0 0 auto;
}
.work-stages {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px;
}
.work-stage {
  min-width: 0; padding: 10px 10px 12px; border-radius: 12px; background: rgba(255,255,255,.72);
  border: 1px solid transparent; color: var(--muted); font-size: 12px;
}
.work-stage b { display: block; margin-bottom: 4px; font-size: 10px; letter-spacing: .04em; }
.work-stage.active {
  color: var(--brand); border-color: rgba(255,36,66,.25); background: #fff;
  box-shadow: 0 0 0 3px rgba(255,36,66,.06);
}
.work-stage.done { color: var(--ok); }
.work-bar {
  height: 4px; margin-top: 12px; border-radius: 999px; background: rgba(255,36,66,.12); overflow: hidden;
}
.work-bar i {
  display: block; height: 100%; width: 28%; border-radius: inherit; background: var(--brand);
  animation: indeterminate 1.6s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(420%); }
}
@media (max-width: 720px) {
  .work-stages { grid-template-columns: 1fr 1fr; }
}

.hero-panel, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 28px; box-shadow: var(--shadow);
}
.hero-panel { text-align: center; }
.hero-panel .eyebrow { color: var(--brand); font-weight: 700; font-size: 12px; margin-bottom: 8px; }
.hero-panel h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.03em; }
.hero-panel .lead { margin: 0 auto 22px; max-width: 520px; color: var(--muted); }
.topic-input {
  width: min(720px, 100%); margin: 0 auto 18px; text-align: left;
}
.topic-input textarea {
  min-height: 96px; font-size: 16px; border-radius: 18px; padding: 16px 18px;
}
.type-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px;
  width: min(720px, 100%); margin: 0 auto 16px;
}
.type-card {
  border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 14px 10px;
  text-align: center; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.type-card:hover { transform: translateY(-1px); }
.type-card.active {
  border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px rgba(255,36,66,.08);
}
.type-card strong { display: block; }
.type-card span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.count-row, .cta-row {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap;
}
.count-box {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; background: #fff;
}
.count-box button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 18px; }
.count-box input {
  width: 48px; border: 0; text-align: center; font-weight: 700; background: transparent;
}
.extras {
  width: min(720px, 100%); margin: 18px auto 0; text-align: left;
  border-top: 1px dashed var(--line); padding-top: 14px;
}
.extras summary {
  cursor: pointer; color: var(--muted); font-weight: 700; list-style: none;
}
.extras summary::-webkit-details-marker { display: none; }
.hint { color: var(--warn); font-size: 12px; margin-top: 8px; min-height: 18px; }
.conversion {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font-size: 12px;
}
.chip.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 700; }

.style-pref-block {
  width: min(720px, 100%);
  margin: 20px auto 0;
  text-align: left;
}
.style-pref-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.style-pref-head label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #333;
}
.style-pref-note {
  color: var(--muted);
  font-size: 12px;
}
.style-pref-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.style-pref-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 14px 14px 12px;
  transition: transform .15s, border-color .15s, box-shadow .15s, background .15s;
}
.style-pref-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 36, 66, .28);
}
.style-pref-card.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(255, 36, 66, .08);
}
.style-pref-card strong {
  display: block;
  font-size: 14px;
  letter-spacing: -.01em;
}
.style-pref-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.style-pref-card.active strong { color: var(--brand); }
.style-pref-card.active span { color: #a14a58; }
.style-pref-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.topic-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.topic-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.topic-card {
  position: relative; text-align: left; border: 1px solid var(--line); border-radius: 18px;
  background: #fff; padding: 16px; min-height: 168px; transition: transform .15s, border-color .15s;
}
.topic-card:hover { transform: translateY(-2px); }
.topic-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,36,66,.1); }
.topic-card.blocked { opacity: .48; cursor: not-allowed; }
.topic-card.blocked:hover { transform: none; }
.topic-card.preferred { border-color: #86efac; }
.topic-card .thesis-kind {
  display: inline-block; margin: 0 6px 8px 0; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: #f3f4f6; color: #4b5563;
}
.topic-card .thesis-kind.catchAll { background: #fef3c7; color: #92400e; }
.topic-card .thesis-kind.boundary { background: #fee2e2; color: #991b1b; }
.topic-card .thesis-kind.contrastWin { background: #dcfce7; color: #166534; }
.topic-card .tag {
  display: inline-block; margin-bottom: 8px; padding: 3px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 700;
}
.topic-card .source-type {
  display: inline-block; margin: 0 0 8px 6px; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; vertical-align: top;
}
.topic-card .source-type.evergreen { background: #f3f4f6; color: #4b5563; }
.topic-card .source-type.hot { background: #fff1f0; color: #c2410c; }
.topic-card .score-line { color: #888; font-size: 11px; margin-bottom: 8px; }
.topic-card h3 { margin: 0 0 8px; font-size: 16px; line-height: 1.35; }
.topic-card p { margin: 0 0 6px; color: #666; font-size: 12px; }
.topic-card .check {
  position: absolute; right: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; color: transparent;
}
.topic-card.active .check { background: var(--brand); border-color: var(--brand); color: #fff; }
.sticky-bar {
  position: sticky; bottom: 12px; margin-top: 18px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.96);
  border: 1px solid var(--line); box-shadow: var(--shadow); flex-wrap: wrap;
}
.progress-line { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.research-panel {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 10px 14px 12px;
}
.research-panel > summary {
  cursor: pointer;
  font-weight: 700;
  color: #333;
  list-style: none;
}
.research-panel > summary::-webkit-details-marker { display: none; }
.research-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.research-meta { margin-top: 6px; }
.research-sources {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
}
.research-source {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
  cursor: pointer;
}
.research-source strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  color: #222;
}
.research-source small {
  display: block;
  margin-top: 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
}
.research-source em {
  display: block;
  margin-top: 4px;
  color: #777;
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
}
.loading-box {
  padding: 28px; border-radius: 18px; background: var(--brand-soft); color: #a31930; text-align: center;
}

.workspace { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; }
.list-panel, .editor-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.list-panel { padding: 14px; }
.note-item {
  width: 100%; text-align: left; border: 1px solid transparent; border-radius: 14px; background: transparent;
  padding: 12px; margin-bottom: 8px;
}
.note-item.active { background: var(--brand-soft); border-color: rgba(255,36,66,.2); }
.note-item h4 { margin: 0 0 6px; font-size: 13px; }
.note-item .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px;
  background: #f5f5f5; color: #666; font-size: 11px;
}
.pill.pass { background: #eaf7f0; color: var(--ok); }
.pill.warn { background: #fff4e5; color: var(--warn); }
.pill.hard { background: #fdecee; color: #c62828; }
.editor-panel { padding: 16px; }
.check-status { font-size: 12px; }
.check-status.ok { color: var(--muted); }
.check-status.soft { color: var(--warn); }
.check-status.hard { color: #c62828; font-weight: 700; }
.check-box ul .check-item.hard { color: #c62828; }
.check-box ul .check-item.soft { color: #a66a00; }
.check-box ul .check-item.ok { color: #666; }

.phone {
  width: min(380px, 100%); margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 28px;
  background: #fff; padding: 18px 16px 22px; min-height: 420px; box-shadow: inset 0 0 0 1px #fff;
}
.phone h1 { margin: 0 0 10px; font-size: 18px; line-height: 1.4; }
.phone .body { white-space: pre-wrap; color: #333; font-size: 14px; }
.phone .tags { margin-top: 14px; color: #3a78c2; font-size: 13px; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.check-box { border-top: 1px solid var(--line); padding-top: 12px; }
.check-box ul { margin: 8px 0 0; padding-left: 18px; color: #666; }
.plan-brief {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line);
  color: #555; font-size: 12px; line-height: 1.55;
}
.plan-brief p { margin: 0 0 6px; }
.plan-brief p:last-child { margin-bottom: 0; }
.plan-brief b { color: #333; font-weight: 700; }
.export-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1f1f1f; color: #fff; padding: 10px 14px; border-radius: 999px; opacity: 0;
  transition: .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.drawer {
  position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 40; display: grid;
  justify-content: start;
}
.drawer-panel {
  width: min(360px, 92vw); height: 100%; background: #fff; padding: 18px; overflow: auto;
}
.more-block { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }
.images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.image-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; padding: 0; background: #fff; }
.image-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.image-card.selected { border-color: var(--brand); }

@media (max-width: 860px) {
  .type-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .style-pref-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .style-pref-grid { grid-template-columns: 1fr; }
}
