/* ===== CSS Variables & Reset ===== */
:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f1f3;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-tertiary: #888;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --accent-hover: #4338ca;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --sidebar-width: 220px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #252530;
  --text-primary: #e8e8ed;
  --text-secondary: #a0a0b0;
  --text-tertiary: #6b6b80;
  --accent: #818cf8;
  --accent-light: #1e1b4b;
  --accent-hover: #a5b4fc;
  --border: #2d2d3a;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding-top: 64px;
}

/* ===== Header ===== */

[data-theme="dark"] .header {
  background: rgba(15, 23, 42, 0.85);
}








/* ===== Mobile Tabs ===== */
.mobile-tabs {
  display: none;
  position: sticky;
  top: 64px;
  z-index: 99;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}

.mobile-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.mobile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Layout ===== */
.toolkit-layout {
  padding-top: 64px;
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 64px;
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.sidebar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}

.sidebar-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.sidebar-label {
  white-space: nowrap;
}

/* ===== Content Area ===== */
.content {
  flex: 1;
  padding: 32px;
  max-width: 800px;
}

/* ===== Tool Panels ===== */
.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 28px;
}

.panel-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.panel-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ===== Form Elements ===== */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

/* ===== Chip Selectors ===== */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  font-size: 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  user-select: none;
  background: var(--bg-secondary);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip input {
  display: none;
}

.chip.active,
.chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

.btn-regenerate {
  margin-top: 16px;
  width: 100%;
  justify-content: center;
  padding: 12px;
}

/* ===== Output Section ===== */
.output-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.output-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.output-actions {
  display: flex;
  gap: 8px;
}

/* ===== Title Results ===== */
.title-category {
  margin-bottom: 20px;
}

.title-category-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-left: 2px;
}

.title-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all var(--transition);
}

.title-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.title-text {
  font-size: 0.95rem;
  line-height: 1.5;
  flex: 1;
}

.copy-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== XHS Results ===== */
.xhs-results {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  line-height: 1.8;
}

.xhs-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.xhs-body {
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.xhs-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.xhs-tag {
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 12px;
}

.xhs-section {
  margin-bottom: 16px;
}

.xhs-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* ===== Script Results ===== */
.script-results {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  line-height: 1.8;
}

.script-section {
  margin-bottom: 20px;
}

.script-section:last-child {
  margin-bottom: 0;
}

.script-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.script-content {
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.script-pause {
  display: inline;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85em;
}

.script-golden {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 12px 16px;
  background: var(--accent-light);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

.script-meta {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

/* Clean mode - hide annotations */
.script-results.clean-mode .script-pause {
  display: none;
}

.script-results.clean-mode .script-section-label {
  display: none;
}

.script-results.clean-mode .script-meta {
  display: none;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  :root { --sidebar-width: 180px; }
  .content { padding: 24px; }
}

@media (max-width: 768px) {

  .mobile-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px;
    scrollbar-width: none;
  }
  .mobile-tabs::-webkit-scrollbar { display: none; }

  .mobile-tab {
    flex: 0 0 auto;
    padding: 12px 14px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .sidebar {
    display: none;
  }

  .toolkit-layout {
    flex-direction: column;
  }

  .content {
    padding: 20px 16px;
    max-width: 100%;
  }

  .panel-header h2 {
    font-size: 1.25rem;
  }

  .chip-group {
    gap: 6px;
  }

  .chip {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .btn-primary {
    width: 100%;
    padding: 14px;
  }

  .output-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .title-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .copy-btn {
    align-self: flex-end;
  }
}

@media (max-width: 480px) {
  .panel-header h2 { font-size: 1.15rem; }
  .xhs-results, .script-results { padding: 16px; }
}

/* ===== v2 新增：选题 & 违禁词 & 通用 ===== */
.usage-hint { font-size: 12.5px; color: var(--text-tertiary); margin-top: 8px; }
.quota-warn { color: #f59e0b !important; font-weight: 600; }
.form-textarea { width:100%; padding:11px 13px; border:1.5px solid var(--border); border-radius:10px; background: var(--bg-secondary); color: var(--text-primary); font-size:14px; font-family:inherit; resize:vertical; line-height:1.6; }
.form-textarea:focus { outline:none; border-color: var(--accent); }

/* loading */
.loading-box { text-align:center; padding:40px 20px; color: var(--text-tertiary); }
.spinner { width:36px; height:36px; border:3px solid var(--border-color,#e8e9f0); border-top-color: var(--accent); border-radius:50%; margin:0 auto 14px; animation: tk-spin .8s linear infinite; }
@keyframes tk-spin { to { transform: rotate(360deg); } }
.raw-fallback { white-space:pre-wrap; font-size:14px; line-height:1.8; background: var(--bg-secondary,#f7f8fa); padding:16px; border-radius:10px; }

/* 选题 */
.topic-cat { margin-bottom:26px; }
.topic-cat-title { font-size:16px; font-weight:700; margin-bottom:12px; padding-left:4px; }
.topic-card { border:1px solid var(--border-color,#e8e9f0); border-radius:12px; padding:14px 16px; margin-bottom:10px; transition: all .2s; background: var(--bg-secondary); }
.topic-card:hover { border-color: var(--accent); box-shadow:0 4px 16px rgba(79,70,229,.1); transform:translateY(-1px); }
.topic-head { display:flex; align-items:flex-start; gap:10px; margin-bottom:7px; }
.topic-idx { flex-shrink:0; width:22px; height:22px; background: var(--accent); color:#fff; border-radius:50%; font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center; margin-top:2px; }
.topic-title { flex:1; font-weight:700; font-size:14.5px; line-height:1.5; }
.topic-angle, .topic-reason { font-size:13px; color: var(--text-secondary); margin:3px 0 3px 32px; line-height:1.55; }
.topic-reason { color: var(--accent); }

/* 违禁词 */
.banned-ok { background: rgba(34,197,94,.1); color:#16a34a; padding:16px 18px; border-radius:12px; font-weight:600; font-size:14.5px; text-align:center; margin-bottom:16px; }
.banned-stat { display:flex; flex-wrap:wrap; gap:10px; align-items:center; background: var(--bg-secondary,#f7f8fa); padding:14px 16px; border-radius:12px; margin-bottom:16px; }
.stat-item { font-weight:700; font-size:14px; padding:5px 12px; border-radius:999px; }
.stat-high { background:rgba(239,68,68,.12); color:#dc2626; }
.stat-mid { background:rgba(245,158,11,.15); color:#d97706; }
.stat-low { background:rgba(234,179,8,.15); color:#a16207; }
.stat-tip { font-size:13px; color: var(--text-tertiary); width:100%; }
.banned-preview { border:1px solid var(--border-color,#e8e9f0); border-radius:12px; padding:16px; margin-bottom:18px; background: var(--bg-secondary); }
.banned-preview-title { font-size:13px; font-weight:700; margin-bottom:10px; color: var(--text-secondary); }
.banned-preview-text { font-size:14px; line-height:2; white-space:pre-wrap; word-break:break-word; }
mark.ban-high { background:rgba(239,68,68,.18); color:#dc2626; font-weight:700; border-radius:4px; padding:1px 3px; }
mark.ban-mid { background:rgba(245,158,11,.18); color:#d97706; font-weight:600; border-radius:4px; padding:1px 3px; }
mark.ban-low { background:rgba(234,179,8,.15); color:#a16207; border-radius:4px; padding:1px 3px; }
.hl-high { color:#dc2626; font-weight:600; }
.hl-mid { color:#d97706; font-weight:600; }
.hl-low { color:#a16207; font-weight:600; }
.banned-list-title { font-size:14px; font-weight:700; margin-bottom:10px; }
.ban-row { border:1px solid var(--border-color,#e8e9f0); border-left:4px solid; border-radius:8px; padding:11px 14px; margin-bottom:8px; }
.ban-row-high { border-left-color:#ef4444; }
.ban-row-mid { border-left-color:#f59e0b; }
.ban-row-low { border-left-color:#eab308; }
.ban-word { font-size:14px; margin-bottom:4px; }
.ban-level { font-size:12px; font-weight:600; margin-right:4px; }
.ban-sug { font-size:12.5px; color: var(--text-tertiary); line-height:1.5; }

@media (max-width: 768px) {
  .topic-angle, .topic-reason { margin-left:0; }
  .mobile-tabs { overflow-x:auto; }
  .mobile-tab { white-space:nowrap; font-size:13px; padding:10px 12px; }
}
