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

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text2: #64748b;
  --text3: #94a3b8;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --amber: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --purple: #8b5cf6;
}

body {
  font-family: -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ===== Top navigation ===== */
.top-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav .left { display: flex; align-items: center; gap: 12px; }
.top-nav .logo { font-weight: 700; font-size: 15px; color: var(--accent); }
.top-nav .logo span { color: var(--text3); font-weight: 400; margin-left: 4px; }
.top-nav .breadcrumb { font-size: 12px; color: var(--text3); }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.top-nav .right { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text2); }
.orient-toggle {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.orient-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Session switcher */
.session-switcher {
  display: flex;
  gap: 4px;
}
.session-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.session-btn.active {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent2);
}
.session-btn:hover:not(.active) {
  border-color: var(--accent);
}
.divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* ===== Main layout ===== */
.main-layout {
  height: calc(100vh - 48px - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.content-row {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ===== Video column ===== */
.video-col {
  display: flex;
  flex-direction: column;
  background: #0f172a;
  position: relative;
}
.video-col.portrait {
  width: 380px;
  min-width: 320px;
  flex-shrink: 0;
}
.video-col.landscape {
  flex: 1;
}

.video-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Video.js overrides */
.video-js {
  width: 100% !important;
  height: 100% !important;
  border-radius: 8px;
  overflow: hidden;
}
.video-js .vjs-big-play-button { display: none; }

/* HUD overlay */
.hud-info {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.hud-info h2 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-info h2 .badge {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 600;
}
.hud-info .meta {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
}

/* Chart bar */
.chart-bar {
  height: 64px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(226,232,240,0.5);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}
.chart-bar .time-display {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text2);
  min-width: 80px;
}
.chart-bar .time-display .current {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.chart-area {
  flex: 1;
  height: 38px;
  position: relative;
}
.chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}
.viewer-count {
  min-width: 70px;
  text-align: right;
}
.viewer-count .num {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.viewer-count .label { font-size: 9px; color: var(--text3); }
.viewer-count .delta { font-size: 10px; font-weight: 600; }
.viewer-count .delta.up { color: var(--green); }
.viewer-count .delta.down { color: var(--red); }

/* ===== Right panel ===== */
.right-panel {
  flex: 1;
  display: flex;
  min-width: 0;
  border-left: 1px solid var(--border);
}
.panel-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}
.panel-col + .panel-col {
  border-left: 1px solid var(--border);
}
.panel-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.panel-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.panel-header .count-badge {
  font-size: 10px;
  color: var(--text3);
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 8px;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ===== Transcript lines ===== */
.t-line {
  padding: 5px 16px;
  font-size: 12.5px;
  line-height: 1.6;
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.t-line:hover { background: #f8fafc; }
.t-line .ts {
  color: var(--text3);
  font-size: 10px;
  font-family: 'SF Mono', 'Menlo', monospace;
  min-width: 36px;
  padding-top: 2px;
  flex-shrink: 0;
}
.t-line.active {
  background: #fffbeb;
  border-left: 3px solid var(--amber);
}
.t-line.active .ts {
  color: var(--amber);
  font-weight: 600;
}
.t-line.noise { opacity: 0.3; }
.t-line.noise:hover { opacity: 0.6; }
.t-line .t-text { flex: 1; }

/* Speaker badges */
.speaker-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.speaker-badge.host {
  background: #dbeafe;
  color: #2563eb;
}
.speaker-badge.guest {
  background: #fef3c7;
  color: #d97706;
}

/* ===== Comment lines ===== */
.c-line {
  padding: 5px 12px;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid #f8fafc;
}
.c-line:hover { background: #f0f9ff; }
.c-line.active {
  background: #eff6ff;
  border-left: 3px solid var(--accent);
}
.c-line .c-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
}
.c-line .c-user {
  font-weight: 600;
  color: var(--accent);
  font-size: 11px;
}
.c-line .c-time {
  font-size: 10px;
  color: var(--text3);
  font-family: 'SF Mono', 'Menlo', monospace;
}
.c-line .c-text { color: var(--text2); }
.c-line .c-likes {
  font-size: 10px;
  color: var(--text3);
  margin-top: 1px;
}

/* ===== Bottom analysis panel ===== */
.analysis-bottom {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: 20px;
  height: 220px;
  overflow-y: auto;
  flex-shrink: 0;
}
.analysis-block h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Keywords */
.kw-list { display: flex; flex-wrap: wrap; gap: 4px; }
.kw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.kw-chip:hover { border-color: var(--accent); background: #eff6ff; }
.kw-chip .count {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 5px;
  min-width: 16px;
  text-align: center;
}
.kw-chip.big {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.kw-chip.big .count { background: var(--accent2); }

/* Attribution timeline */
.attr-timeline {
  position: relative;
  padding-left: 14px;
}
.attr-connector {
  position: absolute;
  left: 3px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--border);
}
.attr-item {
  padding: 4px 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.attr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.attr-item .time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text2);
  min-width: 38px;
}
.attr-item .change { font-weight: 700; min-width: 44px; }
.attr-item .change.up { color: var(--green); }
.attr-item .change.down { color: var(--red); }
.attr-item .reason { color: var(--text2); }

/* Rhythm heatmap */
.rhythm-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 6px;
}
.heatmap {
  height: 16px;
  border-radius: 4px;
  display: flex;
  overflow: hidden;
  gap: 1px;
}
.heatmap .h-cell { flex: 1; border-radius: 2px; }
.heatmap-labels {
  font-size: 10px;
  color: var(--text3);
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  margin-bottom: 8px;
}
.heatmap-legend {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--text3);
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 3px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }
.insight-card {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fffbeb;
  border-radius: 6px;
  font-size: 11px;
  border: 1px solid #fde68a;
  color: var(--text2);
  line-height: 1.5;
}

/* ===== Footer ===== */
.footer-bar {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text3);
}
.footer-bar .brand { color: var(--accent); font-weight: 600; }
.footer-bar .cta { color: var(--accent); font-weight: 600; cursor: pointer; }

/* ===== Tools Showcase — 功能勾子 ===== */
.tools-showcase {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 20px 24px 24px;
  flex-shrink: 0;
}
.tools-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.tools-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: 0;
}
.tools-sub {
  font-size: 11px;
  color: var(--text3);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.tool-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(59,130,246,0.12);
  transform: translateY(-1px);
}
.tool-card:active {
  transform: translateY(0);
}

.tool-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.tool-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.tool-card-header > div {
  flex: 1;
  min-width: 0;
}
.tool-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.tool-desc {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
  margin-top: 2px;
}
.pro-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-preview {
  filter: blur(3px);
  user-select: none;
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}
.tool-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(248,250,252,0.7));
}

.fake-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fake-line {
  font-size: 10px;
  color: var(--text2);
  background: #f1f5f9;
  border-radius: 3px;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fake-line.short {
  font-size: 9px;
  color: var(--text3);
  background: #f8fafc;
}
.fake-line.accent {
  color: var(--accent);
  background: #eff6ff;
}

/* ===== QR Modal ===== */
.qr-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.qr-overlay.active {
  display: flex;
}

.qr-modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: qr-fade-in 0.2s ease-out;
}
@keyframes qr-fade-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.qr-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text3);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}
.qr-close:hover {
  background: #f1f5f9;
  color: var(--text);
}

.qr-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.qr-image {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.qr-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.qr-hint {
  font-size: 12px;
  color: var(--text3);
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .tool-grid { grid-template-columns: 1fr; }
}
