:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #eef2ef;
  --line: #d9dedc;
  --text: #1d2424;
  --muted: #617070;
  --muted-strong: #3f4e4e;
  --accent: #176b68;
  --accent-2: #ab5f18;
  --danger: #b54736;
  --shadow: 0 12px 30px rgba(26, 32, 32, 0.08);
  --radius: 8px;
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfc;
}

.brand-block {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.view-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0;
}

.view-switch button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 900;
}

.view-switch button.is-active {
  border-color: var(--accent);
  background: #edf5f4;
  color: #155b59;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 27px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.25;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 24px;
}

.stat {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.filter-section + .filter-section {
  margin-top: 24px;
}

.section-title {
  margin-bottom: 10px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
}

.category-list,
.status-filter {
  display: grid;
  gap: 8px;
}

.category-list button,
.status-filter button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted-strong);
  text-align: left;
}

.category-list button:hover,
.status-filter button:hover,
.topic-card:hover {
  border-color: #b8c2c0;
}

.category-list button.is-active,
.status-filter button.is-active {
  border-color: color-mix(in srgb, var(--cat-color, var(--accent)) 72%, #ffffff);
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 12%, #ffffff);
  color: var(--text);
}

.category-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  flex: 0 0 auto;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.top-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 0 20px;
}

.search-box {
  display: grid;
  gap: 6px;
  width: min(420px, 100%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 104, 0.16);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(330px, 440px);
  gap: 18px;
  align-items: start;
}

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

.map-metric {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.map-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.map-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 26px;
  line-height: 1;
}

.map-layer-tabs,
.edge-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.map-layer-tabs button,
.edge-filter-bar button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 900;
}

.map-layer-tabs button.is-active {
  border-color: var(--accent);
  background: #edf5f4;
  color: #155b59;
}

.edge-filter-bar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.edge-filter-bar button.is-active {
  border-color: var(--edge-color, var(--accent));
  background: color-mix(in srgb, var(--edge-color, var(--accent)) 12%, #ffffff);
  color: var(--text);
}

.edge-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--edge-color, var(--accent));
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(330px, 420px);
  gap: 18px;
  align-items: start;
}

.map-board,
.map-detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-board {
  overflow: auto;
  min-height: 640px;
  background:
    linear-gradient(90deg, rgba(23, 107, 104, 0.04) 0, rgba(23, 107, 104, 0.04) 1px, transparent 1px, transparent 220px),
    linear-gradient(#ffffff, #f7f9f8);
}

.industry-svg {
  display: block;
  min-width: 100%;
}

.map-layer-band {
  fill: rgba(238, 242, 239, 0.66);
  stroke: var(--line);
  stroke-width: 1;
}

.map-layer-label {
  fill: #7a4630;
  font-size: 13px;
  font-weight: 900;
}

.map-layer-subtitle {
  fill: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
}

.map-edge {
  fill: none;
  stroke-width: 1.7;
  opacity: 0.34;
}

.map-edge.is-strong {
  stroke-width: 2.5;
  opacity: 0.48;
}

.map-edge.is-focus {
  stroke-width: 3;
  opacity: 0.92;
}

.map-edge.is-trend {
  stroke-dasharray: 6 5;
}

.map-edge.is-faded,
.map-node.is-faded {
  opacity: 0.12;
}

.map-node {
  cursor: pointer;
}

.map-node rect {
  fill: #ffffff;
  stroke: var(--node-color, var(--accent));
  stroke-width: 1.2;
  filter: drop-shadow(0 2px 4px rgba(29, 36, 36, 0.08));
}

.map-node:hover rect,
.map-node.is-selected rect {
  stroke-width: 2.4;
}

.map-node.is-trend rect {
  fill: #fff8ea;
  stroke: #ab5f18;
  stroke-dasharray: 5 4;
}

.map-node-title {
  fill: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.map-node-meta {
  fill: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}

.map-node-count {
  fill: #edf5f4;
  stroke: var(--accent);
  stroke-width: 1;
}

.map-node-count-text {
  fill: var(--accent);
  font-size: 10px;
  font-weight: 900;
}

.map-detail-panel {
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 18px;
}

.map-detail-empty {
  padding: 8px;
}

.map-detail-empty h3,
.map-detail-header h3 {
  margin-bottom: 9px;
}

.map-detail-empty p,
.map-detail-header p {
  margin-bottom: 0;
  color: var(--muted-strong);
  line-height: 1.6;
}

.map-detail-header {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.map-detail-section {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.map-detail-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.map-detail-section h4 {
  margin: 0 0 10px;
  color: var(--muted-strong);
  font-size: 13px;
}

.topic-chip-list,
.map-mini-list,
.node-chip-list {
  display: grid;
  gap: 8px;
}

.topic-chip,
.map-mini-item,
.node-chip-list button {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  text-align: left;
}

.topic-chip:hover,
.map-mini-item:hover,
.node-chip-list button:hover {
  border-color: var(--accent);
  background: #edf5f4;
}

.topic-chip strong,
.map-mini-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.topic-chip span,
.map-mini-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.list-column,
.detail-panel {
  min-width: 0;
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

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

.topic-card {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--cat-color, var(--accent));
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  box-shadow: none;
}

.topic-card.is-active {
  border-color: color-mix(in srgb, var(--cat-color, var(--accent)) 58%, #ffffff);
  border-left-color: var(--cat-color, var(--accent));
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topic-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.date-pill,
.status-pill,
.type-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.date-pill {
  padding: 7px 9px;
  background: #edf1f4;
  color: var(--muted-strong);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 9px;
  background: #fff5ec;
  color: var(--accent-2);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.type-pill {
  padding: 7px 9px;
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 12%, #ffffff);
  color: var(--muted-strong);
}

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

.tag {
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #dce2e0;
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.15;
}

.card-actions,
.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-link,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.action-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.action-link:hover,
.action-button:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.detail-panel {
  position: sticky;
  top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-header {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.detail-section {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-section h4 {
  margin: 0 0 8px;
  color: var(--muted-strong);
  font-size: 13px;
}

.detail-section p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.55;
}

.company-row,
.mini-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.company {
  padding: 6px 9px;
  border-radius: var(--radius);
  background: #edf5f4;
  color: #155b59;
  font-size: 13px;
  font-weight: 800;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.mini-item {
  min-width: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.mini-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

audio {
  width: 100%;
  margin-top: 8px;
}

.audio-now {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.audio-dock {
  position: fixed;
  right: 22px;
  bottom: 18px;
  left: 302px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, #ffffff);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(18, 27, 27, 0.18);
  backdrop-filter: blur(10px);
}

.audio-dock[hidden] {
  display: none;
}

.dock-play {
  min-width: 62px;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.dock-main {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.dock-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dock-progress {
  position: relative;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe7e4;
  outline: none;
  cursor: pointer;
}

.dock-progress:focus {
  box-shadow: 0 0 0 3px rgba(23, 107, 104, 0.16);
}

.dock-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.12s linear;
}

.dock-time {
  min-width: 116px;
  color: var(--muted-strong);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: right;
}

.empty-state,
.error-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.error-state {
  border-color: #e0b2a9;
  color: var(--danger);
}

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

  .side-panel {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .category-list,
  .status-filter {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .map-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-board {
    min-height: 560px;
  }

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

  .detail-panel {
    position: static;
  }

  .audio-dock {
    right: 16px;
    left: 16px;
  }
}

@media (max-width: 680px) {
  .workspace,
  .side-panel {
    padding: 16px;
  }

  .top-bar,
  .card-header,
  .list-meta {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 24px;
  }

  .content-grid {
    gap: 14px;
  }

  .mini-grid,
  .stats-grid,
  .map-summary {
    grid-template-columns: 1fr;
  }

  .map-board {
    min-height: 520px;
  }

  .map-layer-tabs button,
  .edge-filter-bar button {
    flex: 1 1 145px;
  }

  .action-link,
  .action-button {
    flex: 1 1 145px;
  }

  .audio-dock {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
  }

  .dock-time {
    grid-column: 2;
    min-width: 0;
    text-align: left;
  }
}
