/**
 * 功能说明：定义故事素材工作台的高密度工具界面，负责队列、录入表单和响应式布局。
 * 职责边界：只处理静态视觉与交互状态，不负责素材评分、存储、导入导出和服务端通信。
 */

:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --panel: #fffdf8;
  --panel-soft: #f9f6ee;
  --text: #191d1a;
  --muted: rgba(25, 29, 26, 0.62);
  --faint: rgba(25, 29, 26, 0.42);
  --line: rgba(25, 29, 26, 0.1);
  --line-strong: rgba(25, 29, 26, 0.18);
  --green: #2f765a;
  --green-soft: #d8e9df;
  --amber: #b97720;
  --amber-soft: #f5dfb9;
  --red: #a9493d;
  --ink: #242824;
  --shadow: 0 18px 42px rgba(38, 33, 24, 0.08);
  --radius: 8px;
  --header-height: 68px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), transparent 22%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 242, 234, 0.88);
  backdrop-filter: blur(16px) saturate(112%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 1rem;
  font-weight: 720;
  line-height: 1.2;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.queue-panel,
.insight-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
}

.queue-panel {
  padding: 18px;
}

.insight-panel {
  position: sticky;
  top: calc(var(--header-height) + 18px);
  align-self: start;
  max-height: calc(100vh - var(--header-height) - 36px);
  padding: 16px;
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head--compact {
  margin-bottom: 12px;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 0.74rem;
  font-weight: 760;
  line-height: 1.2;
  color: var(--green);
}

h1 {
  font-size: clamp(1.55rem, 2.2vw, 2.35rem);
  line-height: 1.08;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.25;
  font-weight: 720;
  letter-spacing: 0;
}

.queue-count,
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf0;
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-box {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.metric-box span,
label span,
.search-box span,
.story-meta,
.story-card dt,
.recent-item span {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--faint);
}

.metric-box strong {
  align-self: end;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 780;
}

.queue-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.search-box,
.intake-form label {
  display: grid;
  gap: 6px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fffefb;
  color: var(--text);
  outline: none;
}

input,
select {
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.58;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(47, 118, 90, 0.62);
  box-shadow: 0 0 0 3px rgba(47, 118, 90, 0.12);
}

.primary-header-button,
.ghost-button,
.primary-button,
.danger-button,
.text-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.primary-header-button,
.ghost-button,
.danger-button,
.text-button {
  padding: 0 12px;
  background: #fffdf8;
  color: var(--text);
}

.primary-header-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffaf0;
}

.primary-button {
  width: 100%;
  padding: 0 16px;
  border-color: var(--green);
  background: var(--green);
  color: #f7fff9;
  font-weight: 760;
}

.danger-button {
  color: var(--red);
}

.text-button {
  min-height: 34px;
  color: var(--green);
}

.primary-header-button:hover,
.primary-header-button:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.danger-button:hover,
.danger-button:focus-visible,
.text-button:hover,
.text-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(25, 29, 26, 0.28);
}

.story-list,
.recent-list,
.intake-form {
  display: grid;
  gap: 10px;
}

.story-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.story-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.story-card h2 {
  margin-top: 5px;
  font-size: 1.18rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.story-core {
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: #f4f8f4;
  font-size: 0.97rem;
  line-height: 1.72;
  color: var(--text);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

.tag--hot {
  border-color: rgba(185, 119, 32, 0.28);
  background: var(--amber-soft);
  color: #70470f;
}

.reason-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.story-card dd {
  margin-top: 4px;
  font-size: 0.9rem;
  line-height: 1.48;
  color: var(--muted);
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.storyboard-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(47, 118, 90, 0.18);
  border-radius: var(--radius);
  background: #f6faf6;
}

.storyboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.storyboard-head h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
}

.storyboard-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.storyboard-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.76);
}

.storyboard-list li > strong {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf0;
  font-size: 0.86rem;
}

.storyboard-list p {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
}

.storyboard-list p + p {
  margin-top: 4px;
}

.storyboard-list b {
  color: var(--text);
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fffaf0;
  font-size: 0.86rem;
  font-weight: 740;
}

.source-link[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.42;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.recent-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.recent-panel h2 {
  margin-bottom: 10px;
}

.recent-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.recent-item strong {
  font-size: 0.92rem;
  line-height: 1.35;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.58);
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.pipeline-list {
  display: grid;
  gap: 10px;
}

.pipeline-list article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.pipeline-list span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--faint);
}

.pipeline-list strong {
  font-size: 1.2rem;
  line-height: 1;
}

.data-panel {
  margin-top: 14px;
}

.data-panel .danger-button {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 22, 20, 0.34);
}

.modal-panel {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 28px 72px rgba(20, 18, 14, 0.22);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .insight-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .header-actions,
  .queue-toolbar,
  .form-row {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 10px;
  }

  .metrics-grid,
  .reason-list,
  .storyboard-list p {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .metrics-grid,
  .reason-list,
  .story-card-head,
  .storyboard-head,
  .storyboard-list li,
  .storyboard-list p {
    grid-template-columns: 1fr;
  }

  .score-badge {
    justify-self: start;
  }
}
