/* ============ 直播话术整理台 · 实时版 · 纸面编辑风 ============ */

:root {
  --paper: #f6f1e7;
  --paper-deep: #efe7d7;
  --card: #fffdf7;
  --ink: #221d18;
  --ink-soft: #6f6558;
  --line: #2a241d;
  --accent: #d8402a;        /* 直播间红 */
  --accent-deep: #ad2f1e;
  --amber: #e2a23c;
  --ok: #2e7d4f;
  --err: #b3261e;
  --serif: Georgia, "Nimbus Roman", "Songti SC", "STZhongsong", "SimSun", serif;
  --sans: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: Consolas, "JetBrains Mono", monospace;
  --shadow: 5px 5px 0 rgba(34, 29, 24, .92);
  --shadow-sm: 3px 3px 0 rgba(34, 29, 24, .9);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 通用隐藏类：JS 切换显示用（!important 压过组件自身的 display 规则） */
.hidden { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(226, 162, 60, .16), transparent 60%),
    radial-gradient(900px 420px at -10% 30%, rgba(216, 64, 42, .07), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E"),
    var(--paper);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 整屏工作台，各面板内部滚动 */
}

::selection { background: var(--amber); color: var(--ink); }

/* ---------- 顶栏 ---------- */

.topbar {
  background: var(--ink);
  color: #f4ecdd;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--accent);
  flex: none;
  z-index: 50;
}

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

.live-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
  box-shadow: 0 0 0 0 rgba(216, 64, 42, .55);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(216, 64, 42, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(216, 64, 42, 0); }
  100% { box-shadow: 0 0 0 0 rgba(216, 64, 42, 0); }
}

.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }

.brand-en {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11px;
  letter-spacing: .32em;
  color: #b7a98e;
  white-space: nowrap;
}

.brand-ver {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .05em;
  color: #8a7f6b;
  white-space: nowrap;
}

.top-actions { display: flex; align-items: center; gap: 14px; }

.rec-badge {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  color: #ffd9d2;
  background: rgba(216, 64, 42, .28);
  border: 1px solid rgba(216, 64, 42, .6);
  border-radius: 8px;
  padding: 3px 10px;
  animation: pulse 2s infinite;
}

.key-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  cursor: help;
}
.key-dot.on  { background: #7bd39a; box-shadow: 0 0 6px #7bd39a; }
.key-dot.off { background: #8a8074; box-shadow: 0 0 0 2px rgba(244, 236, 221, .18); }

/* ---------- 按钮 ---------- */

button { font-family: inherit; cursor: pointer; }

.btn-accent, .btn-dark, .btn-ghost, .btn-ghost-light {
  border-radius: 10px;
  font-size: 13px;
  padding: 7px 14px;
  border: 2px solid var(--line);
  transition: transform .06s ease, box-shadow .06s ease, background .15s;
  white-space: nowrap;
}
.btn-accent:active, .btn-dark:active, .btn-ghost:active, .btn-ghost-light:active {
  transform: translate(2px, 2px);
  box-shadow: none !important;
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.btn-accent:hover { background: var(--accent-deep); }
.btn-accent:disabled { background: #c9bfae; border-color: #a49a89; box-shadow: none; cursor: not-allowed; }
.btn-dark {
  background: var(--ink);
  color: #f4ecdd;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px dashed #b7ab98;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); background: rgba(255, 253, 247, .6); }
.btn-ghost.danger:hover { color: var(--err); border-color: var(--err); }
.btn-ghost-light {
  background: transparent;
  color: #d9cdb6;
  border: 1.5px solid #5a5245;
}
.btn-ghost-light:hover { color: #fff; border-color: #b7a98e; }

/* ---------- 工作台布局 ---------- */

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 18px 16px;
}

.pane {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pane-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 8px;
  border-bottom: 2px solid rgba(42, 36, 29, .14);
  flex-wrap: wrap;
}

.pane-head h2 { display: flex; align-items: baseline; gap: 10px; font-weight: 800; }

.ph-cn { font-size: 15px; letter-spacing: .04em; }

.ph-en {
  font-family: var(--serif);
  font-style: italic;
  font-size: 10px;
  letter-spacing: .3em;
  color: #a4977f;
}

/* ---------- 上：实时转写 ---------- */

.transcript-pane { flex: 0 0 34%; min-height: 170px; }

.mic-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.mic-controls select {
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 8px;
  border: 1.5px solid #b7ab98;
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
}

.mic-status { font-size: 12px; color: var(--ink-soft); }

#transcript {
  flex: 1;
  min-height: 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 12px 18px;
  font-size: 14px;
  line-height: 1.85;
  font-family: var(--sans);
  color: var(--ink);
}
#transcript:focus { background: rgba(226, 162, 60, .05); }

.transcript-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 10px;
  border-top: 1.5px dashed rgba(42, 36, 29, .16);
  flex-wrap: wrap;
}

.interim { font-size: 12.5px; color: #9a8d79; font-style: italic; min-height: 1em; }

.spacer { flex: 1; }

.muted { color: var(--ink-soft); font-size: 12px; }

/* ---------- 下：列表 + 详情 ---------- */

.bottom {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 330px) 1fr;
  gap: 14px;
}

/* --- 左：商品列表 --- */

.org-status { font-size: 12px; color: var(--accent); font-weight: 700; }
.org-status .spin {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid rgba(216, 64, 42, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin-right: 5px;
  animation: rot .8s linear infinite;
  vertical-align: -1px;
}
@keyframes rot { to { transform: rotate(360deg); } }

.prod-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }

.prod-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background .12s, border-color .12s;
}
.prod-item:hover { background: rgba(226, 162, 60, .09); }
.prod-item.active {
  background: #fdf4e3;
  border-color: var(--amber);
  box-shadow: var(--shadow-sm);
}

.prod-item input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.p-idx {
  font-family: var(--mono);
  font-size: 11px;
  color: #a4977f;
  flex: none;
}

.p-nm {
  font-size: 13.5px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-new {
  flex: none;
  font-size: 10.5px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
  padding: 1px 6px;
  animation: pulse 2s infinite;
}

.p-price {
  flex: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent-deep);
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-del {
  flex: none;
  border: 0;
  background: transparent;
  color: #c4b8a4;
  font-size: 13px;
  border-radius: 6px;
  padding: 0 5px;
  visibility: hidden;
}
.prod-item:hover .p-del { visibility: visible; }
.p-del:hover { color: var(--err); background: rgba(179, 38, 30, .1); }

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: #a4977f;
  font-size: 14px;
  padding: 26px 18px;
}
.empty small { font-size: 12px; line-height: 1.7; max-width: 260px; }
#productsEmpty { display: none; }
#productsEmpty.show { display: flex; }

.list-foot {
  flex: none;
  border-top: 2px solid rgba(42, 36, 29, .14);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.auto-label {
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}
.auto-label input { accent-color: var(--accent); width: 14px; height: 14px; }

.list-export { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#exportSel { flex: 1; min-width: 140px; }

/* --- 右：商品详情 --- */

.detail-pane { position: relative; }

.detail { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.d-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 8px;
  border-bottom: 2px solid rgba(42, 36, 29, .14);
  flex-wrap: wrap;
}

.d-idx {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: #a4977f;
}

.d-name {
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  border: 0;
  border-bottom: 2px dashed #c9bda9;
  background: transparent;
  outline: none;
  padding: 2px 4px;
  min-width: 140px;
  max-width: 46%;
  color: var(--ink);
}
.d-name:focus { border-bottom-color: var(--accent); }

.d-price {
  font-family: var(--mono);
  font-size: 13px;
  border: 1.5px solid #c9bda9;
  border-radius: 8px;
  background: transparent;
  outline: none;
  padding: 4px 8px;
  width: 130px;
  color: var(--accent-deep);
}
.d-price:focus { border-color: var(--accent); }

.d-meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px 4px;
  flex-wrap: wrap;
}

.hl-chip {
  font-size: 12px;
  background: var(--paper-deep);
  border: 1.5px solid #d8c9ae;
  border-radius: 999px;
  padding: 2px 10px;
  outline: none;
  color: var(--ink);
}
.hl-chip:focus { border-color: var(--amber); }
.hl-add {
  font-size: 12px;
  color: var(--ink-soft);
  background: transparent;
  border: 1.5px dashed #b7ab98;
  border-radius: 999px;
  padding: 2px 10px;
}
.hl-add:hover { color: var(--ink); border-color: var(--ink-soft); }

.d-tabs {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
}

.d-tab {
  font-size: 13px;
  font-weight: 700;
  background: var(--paper-deep);
  color: var(--ink-soft);
  border: 2px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  padding: 7px 14px;
}
.d-tab.active {
  background: var(--card);
  color: var(--ink);
  border-color: rgba(42, 36, 29, .25);
  position: relative;
  top: 2px;
  padding-bottom: 9px;
}

.d-body {
  flex: 1;
  min-height: 0;
  margin: 0 16px 14px;
  border: 2px solid rgba(42, 36, 29, .25);
  border-radius: 0 12px 12px 12px;
  background: #fffefa;
  display: flex;
  flex-direction: column;
}

.d-text {
  flex: 1;
  min-height: 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.9;
  font-family: var(--sans);
  color: var(--ink);
}

/* ---------- 设置弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(34, 29, 24, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px 22px 20px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h3 { font-size: 17px; }

.field { margin-bottom: 12px; flex: 1; min-width: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; }
.field label small { color: var(--ink-soft); font-weight: 400; }
.field input {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1.5px solid #c9bda9;
  border-radius: 9px;
  background: #fffefa;
  outline: none;
  color: var(--ink);
}
.field input:focus { border-color: var(--accent); }
.field-row { display: flex; gap: 12px; }

.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }

.hint {
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--paper-deep);
  border-radius: 9px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.hint code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(42, 36, 29, .08);
  border-radius: 4px;
  padding: 1px 5px;
}

.modal-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Toast ---------- */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: min(420px, 86vw);
}

.toast {
  background: var(--ink);
  color: #f4ecdd;
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  transition: opacity .4s;
  word-break: break-all;
}
.toast.ok { border-left-color: #7bd39a; }
.toast.err { border-left-color: var(--accent); }

/* ---------- 窄屏 ---------- */

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { overflow: visible; }
  .transcript-pane { flex: none; height: 260px; }
  .bottom { grid-template-columns: 1fr; }
  .list-pane { max-height: 340px; }
  .detail-pane { min-height: 420px; }
  .brand-en { display: none; }
}
