/* ============================================================
   Moran Tools · 工具页扩展样式（剧本 / 通告单 / 镜头清单）
   依赖 style.css 的 tokens 与 tool.css 的 .toolbar / .sheet 等骨架
   ============================================================ */

/* ---------- 通用：表格内联输入 ---------- */
.cell-input,
.cell-area {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 4px 2px;
  border-radius: 6px;
  outline: none;
}
.cell-input:focus,
.cell-area:focus { background: var(--primary-wash); box-shadow: inset 0 0 0 1px var(--primary); }
.cell-area { resize: none; line-height: 1.5; min-height: 34px; }
.cell-input--num { text-align: center; font-variant-numeric: tabular-nums; }
.cell-select {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 4px 0;
  outline: none;
  cursor: pointer;
}
.cell-select:focus { background: var(--primary-wash); }

.sheet td { vertical-align: top; }
.sheet .row-ops { white-space: nowrap; text-align: center; }

/* tool.css 把 .row-ops 做成悬停出现的内联容器，这里在单元格里改成常显的表格单元 */
.sheet td.row-ops,
.sheet th.col-ops { display: table-cell; opacity: 1; text-align: center; }
.sheet tbody tr .row-ops { opacity: .5; transition: opacity .18s; }
.sheet tbody tr:hover .row-ops,
.sheet tbody tr:focus-within .row-ops { opacity: 1; }
.sheet td.row-ops button { display: inline-grid; vertical-align: middle; margin: 0 1px; }

.cell-input::placeholder,
.cell-area::placeholder { color: #BFC5C4; }

.row-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1;
  padding: 5px 5px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.row-btn:hover { background: var(--primary-wash); color: var(--text); border-color: var(--border); }
.row-btn--danger:hover { background: #F7ECEC; color: #B4635F; border-color: #EBD6D4; }

.sheet td.empty {
  padding: 34px 10px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ---------- 通用：统计条 ---------- */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-end;
  padding: 18px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
}
.stat-item { display: flex; flex-direction: column; gap: 4px; }
.stat-item b { font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-item span { font-size: 12px; color: var(--text-secondary); letter-spacing: .04em; }
.stat-item--grow { flex: 1; min-width: 180px; }
.progress { height: 6px; border-radius: 99px; background: var(--bg-alt); overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--primary-deep)); transition: width var(--dur) var(--ease); }
.progress-meta { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-bar .spacer { flex: 1; }

/* ---------- 镜头清单 ---------- */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--border-strong);
}
.status-dot.is-done { background: var(--ok); }
.status-dot.is-fix { background: var(--warn); }
.sheet tr.is-done { background: rgba(143, 169, 143, .05); }
.sheet tr.is-done .cell-input { color: var(--text-secondary); }

/* ---------- 通告单 ---------- */
.cs-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 18px;
  padding: 20px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.cs-field { display: flex; flex-direction: column; gap: 6px; }
.cs-field label { font-size: 12px; letter-spacing: .06em; color: var(--text-secondary); text-transform: uppercase; }
.cs-field input,
.cs-field textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cs-field input:focus,
.cs-field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-wash); }
.cs-field--wide { grid-column: 1 / -1; }

.cs-block { margin-top: 22px; }
.cs-block h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cs-block h2 small { font-weight: 400; font-size: 12px; color: var(--text-secondary); letter-spacing: .04em; }

.cs-sign {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--text-soft);
}
.cs-sign div { display: flex; gap: 8px; align-items: flex-end; }
.cs-sign i { flex: 1; border-bottom: 1px solid var(--border-strong); height: 22px; }

/* ---------- 剧本编辑器 ---------- */
.script-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 24px;
  align-items: start;
}
.script-doc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 34px 38px 46px;
}
.script-meta { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 22px; }
.script-title {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--font);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
  outline: none;
  padding: 2px 0;
}
.script-title:focus { background: var(--primary-wash); border-radius: 6px; }
.script-sub { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; align-items: center; }
.script-sub input {
  border: 0;
  border-bottom: 1px dashed var(--border-strong);
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text-soft);
  padding: 2px 4px;
  outline: none;
  min-width: 120px;
}
.script-sub input:focus { border-bottom-color: var(--primary); background: var(--primary-wash); }
.script-logline { margin-top: 12px; }
.script-logline textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  font: inherit;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
  padding: 10px 12px;
  resize: vertical;
  min-height: 58px;
  outline: none;
}
.script-logline textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-wash); }

.script-body { font-family: "Songti SC", "SimSun", "Source Han Serif SC", Georgia, serif; }

.blk { position: relative; display: flex; gap: 10px; padding: 2px 0; border-radius: 8px; }
.blk:hover { background: linear-gradient(90deg, rgba(184, 197, 196, .10), transparent 70%); }
.blk-grip {
  flex: 0 0 auto;
  width: 58px;
  padding-top: 7px;
  opacity: .35;
  transition: opacity var(--dur) var(--ease);
}
.blk:hover .blk-grip,
.blk:focus-within .blk-grip { opacity: 1; }
.blk-type {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-secondary);
  padding: 3px 4px;
  cursor: pointer;
  outline: none;
}
.blk-type:focus { border-color: var(--primary); }
.blk textarea {
  flex: 1;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  resize: none;
  outline: none;
  padding: 5px 6px;
  border-radius: 6px;
  overflow: hidden;
}
.blk textarea:focus { background: rgba(237, 241, 240, .55); }

.blk textarea::placeholder { color: #C3C8C7; opacity: 1; }
.blk--character textarea::placeholder { letter-spacing: .04em; }

.blk--scene { margin-top: 22px; }
.blk--scene textarea {
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.blk--action textarea { font-size: 15px; }
.blk--character { margin-top: 14px; }
.blk--character textarea {
  text-align: center;
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .12em;
  max-width: 340px;
  margin: 0 auto;
}
.blk--parenthetical textarea { padding-left: 15%; font-size: 14px; color: var(--text-soft); }
.blk--dialogue textarea { padding-left: 12%; padding-right: 12%; font-size: 15px; }
.blk--transition { margin-top: 12px; }
.blk--transition textarea {
  text-align: right;
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.blk--note textarea { font-size: 13px; font-style: italic; color: var(--text-secondary); }

.script-side { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 16px; }
.side-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px;
}
.side-card h4 {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.side-stats div { display: flex; flex-direction: column; gap: 2px; }
.side-stats b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.side-stats span { font-size: 11px; color: var(--text-secondary); }
.scene-nav { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.scene-nav button {
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text-soft);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scene-nav button:hover { background: var(--primary-wash); color: var(--text); }
.scene-nav .is-active { background: var(--primary-wash); color: var(--text); font-weight: 500; }
.side-empty { font-size: 12px; color: var(--text-secondary); }

/* ---------- 打印 ---------- */
.print-only, .only-print { display: none; }
.print-head h2 { font-size: 20px; font-weight: 600; letter-spacing: .02em; margin-bottom: 4px; }
.print-head p { font-size: 12px; color: var(--text-soft); }
.print-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 18px;
  margin: 10px 0 16px;
  font-size: 12px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 12px;
}
.print-info-grid span { color: #555; }
.print-info-grid b { font-weight: 600; }

@media print {
  .site-nav, .site-footer, .toolbar, .filter-bar, .script-side,
  .no-print, .tbtn, .menu-wrap { display: none !important; }
  .print-only, .only-print { display: block !important; }
  .print-info-grid { display: grid !important; }
  .col-ops, .row-ops { display: none !important; }
  .sheet { min-width: 0 !important; }
  .tool-head { display: none !important; }
  .cs-form textarea { height: auto !important; min-height: 0 !important; }
  .script-doc { border: 0 !important; box-shadow: none !important; }
  .cell-input, .cell-area, .cell-select {
    border: 0 !important;
    background: transparent !important;
    -webkit-appearance: none;
    appearance: none;
    padding: 2px 0;
  }
  .cell-select { text-align-last: left; }
  select.cell-select::-ms-expand { display: none; }
  ::placeholder { color: transparent !important; }
  textarea:focus { background: transparent !important; }
  .project-bar, .hint, #metaWords { display: none !important; }
  .script-sub input { border-bottom: 0 !important; }
  .script-logline textarea { border: 0 !important; background: transparent !important; resize: none; }
  .cs-form { border: 0; box-shadow: none; padding: 0; }
  .cs-form input, .cs-form textarea { border: 0 !important; background: transparent !important; padding: 2px 0; }
  .wrap { max-width: none; padding: 0 !important; }
  .tool-head { margin-bottom: 12px !important; }
  .tool-head p, .tool-meta { display: none; }
  body { background: #fff; }
  .sheet-card, .script-doc, .stat-row, .cs-form {
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0;
  }
  .script-layout { display: block; }
  .script-doc { padding: 0; }
  .blk-grip { display: none; }
  .blk textarea, .cell-area { min-height: 0; }
  .progress { border: 1px solid #ccc; }
  tr, .blk { page-break-inside: avoid; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1024px) {
  .script-layout { grid-template-columns: 1fr; }
  .script-side { position: static; order: -1; }
  .side-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .script-doc { padding: 22px 18px 32px; }
  .stat-row { gap: 18px; padding: 14px 16px; }
  .blk--dialogue textarea { padding-left: 6%; padding-right: 6%; }
}

/* ---------- 窄屏修正（工具页） ---------- */
@media (max-width: 760px) {
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar .spacer { display: none; }
  .toolbar .sep, .toolbar .divider-line { display: none; }
  .toolbar .tbtn { padding: 9px 14px; }
  .menu-wrap .menu { left: auto; right: 0; }
  .stat-row { gap: 16px; padding: 16px 16px; }
  .stat-item { min-width: 64px; }
  .filter-bar { gap: 6px; }
  .filter-bar .spacer { display: none; }
  .filter-bar .search, .filter-bar input[type="search"] { width: 100%; }
  .sheet-card, .script-doc { border-radius: 14px; }
  .cs-field--wide { grid-column: span 1; }
}