:root {
  color-scheme: light;
  --paper: #f7f4ee;
  --ink: #18222c;
  --muted: #5e6872;
  --line: #d8d3c8;
  --panel: #ffffff;
  --teal: #0b7c77;
  --teal-soft: #d9f0ec;
  --coral: #d75a4a;
  --amber: #b7791f;
  --blue: #3867b7;
  --green: #3d7a45;
  --purple: #7160a8;
  --pending: #be6c1f;
  --shadow: 0 16px 40px rgba(24, 34, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(11, 124, 119, 0.08), transparent 340px),
    var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.app-header,
.app-shell,
.graph-section,
.bottom-grid,
.disclaimer {
  width: min(1480px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 18px;
  align-items: end;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 1.06;
}

.header-copy {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.status-strip {
  min-width: 260px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.status-strip strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.disclaimer {
  border: 2px solid #c84536;
  background: #fff8f5;
  color: #7d241b;
  padding: 12px 16px;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(420px, 1fr) minmax(280px, 360px);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.library-panel,
.workbench-panel,
.insight-panel,
.graph-section,
.association-panel,
.audit-panel,
.change-board,
.radar-wrap,
.effect-wrap {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.library-panel,
.workbench-panel,
.insight-panel,
.graph-section,
.association-panel,
.audit-panel {
  padding: 16px;
  min-width: 0;
}

.panel-heading,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 16px;
}

.count-pill,
.status-pill,
.effect-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--teal-soft);
  color: #075a56;
}

.status-pill.pending {
  background: #fff0df;
  color: var(--pending);
}

.search-box {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 124, 119, 0.14);
}

.herb-library {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 4px;
}

.herb-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  cursor: grab;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.herb-card:hover {
  transform: translateY(-2px);
  border-color: rgba(11, 124, 119, 0.5);
  box-shadow: 0 10px 24px rgba(24, 34, 44, 0.09);
}

.herb-card:active {
  cursor: grabbing;
}

.herb-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.herb-name {
  font-size: 19px;
  font-weight: 900;
}

.herb-meta {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.effect-chip {
  background: #eef5ff;
  color: var(--blue);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 10px;
}

.slot {
  min-height: 118px;
  border: 2px dashed #b8c7c5;
  background:
    linear-gradient(135deg, rgba(11, 124, 119, 0.08), rgba(215, 90, 74, 0.07)),
    #fbfcfb;
  display: grid;
  place-items: center;
  padding: 8px;
  position: relative;
}

.slot.drag-over {
  border-color: var(--teal);
  background: #eefaf8;
}

.slot-empty {
  color: #71807e;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.slot-herb {
  width: 100%;
  min-height: 98px;
  display: grid;
  align-content: center;
  gap: 5px;
  text-align: center;
  background: #fff;
  border: 1px solid rgba(11, 124, 119, 0.28);
  padding: 10px 8px;
}

.slot-herb strong {
  font-size: 19px;
}

.remove-slot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border: 0;
  background: var(--coral);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 34px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 800;
}

.ghost-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

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

.mobile-only {
  display: none;
}

.change-board {
  margin-top: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  align-items: start;
}

.delta-log {
  color: var(--muted);
}

.delta-token {
  display: inline-flex;
  margin: 0 6px 6px 0;
  padding: 4px 8px;
  background: #eef5ff;
  color: var(--blue);
  font-weight: 800;
}

.delta-token.down {
  background: #fff0df;
  color: var(--pending);
}

.delta-token.new {
  background: var(--teal-soft);
  color: #075a56;
}

.visual-band {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
  margin-top: 14px;
}

.radar-wrap,
.effect-wrap {
  padding: 14px;
}

#radarCanvas {
  width: 100%;
  max-width: 360px;
  height: auto;
  display: block;
  margin: 8px auto 0;
}

.effect-bars {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}

.effect-bar {
  display: grid;
  grid-template-columns: 88px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  background: #e8e4da;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.bar-source {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 12px;
}

.quick-symptoms {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.symptom-button {
  border: 1px solid #ccd7d6;
  background: #fff;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--ink);
}

.symptom-button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.path-results,
.association-cards,
.audit-list {
  display: grid;
  gap: 10px;
}

.path-card,
.association-card,
.audit-item {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.path-card strong,
.association-card strong {
  display: block;
  margin-bottom: 6px;
}

.path-line {
  color: var(--muted);
  font-size: 14px;
}

.graph-section {
  margin-top: 16px;
}

.graph-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: #fcfdfb;
}

.graph-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.legend {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 5px;
  border-radius: 999px;
  vertical-align: -1px;
  background: #c5cbd0;
}

.legend.active {
  background: var(--teal);
}

.legend.source-ok {
  background: var(--green);
}

.legend.source-pending {
  background: var(--amber);
}

.knowledge-graph {
  width: 100%;
  min-width: 900px;
  min-height: 520px;
  display: block;
  background:
    linear-gradient(90deg, rgba(11, 124, 119, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(11, 124, 119, 0.07) 1px, transparent 1px),
    #fcfdfb;
  background-size: 36px 36px;
}

.graph-edge {
  fill: none;
  stroke: #aab3ba;
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.36;
  pointer-events: stroke;
}

.graph-edge.active {
  stroke: var(--teal);
  stroke-width: 1.9;
  opacity: 0.58;
}

.node-circle {
  stroke: #fff;
  stroke-width: 3;
  fill: #cbd3d6;
}

.node-circle.active {
  fill: var(--teal);
}

.node-circle.herb {
  fill: var(--coral);
}

.node-circle.pending {
  stroke: var(--amber);
}

.node-circle.verified {
  stroke: var(--green);
}

.node-label {
  font-size: 13px;
  font-weight: 800;
  fill: var(--ink);
  text-anchor: middle;
}

.node-kind {
  font-size: 10px;
  fill: var(--muted);
  text-anchor: middle;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  margin-bottom: 28px;
}

.association-card .kind {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.audit-item {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.audit-item b {
  color: var(--ink);
}

.mini-workbench {
  display: none;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 12px;
  background: rgba(255, 255, 255, 0.68);
}

@media (max-width: 1180px) {
  .app-shell,
  .bottom-grid,
  .visual-band {
    grid-template-columns: 1fr;
  }

  .herb-library {
    max-height: none;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }

  .workbench-panel {
    order: 1;
  }

  .insight-panel {
    order: 2;
  }

  .library-panel {
    order: 3;
  }
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
  }

  body {
    background: var(--paper);
  }

  .app-header,
  .app-shell,
  .graph-section,
  .bottom-grid,
  .disclaimer {
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    overflow-wrap: anywhere;
  }

  .app-shell,
  .graph-section,
  .bottom-grid {
    margin-left: 10px;
    margin-right: 10px;
  }

  .app-header {
    display: block;
    padding: 18px 0 12px;
  }

  .app-header h1 {
    font-size: 34px;
    line-height: 1.08;
  }

  .header-copy {
    font-size: 14px;
  }

  .status-strip {
    margin-top: 14px;
    min-width: 0;
    padding: 10px 12px;
  }

  .status-strip strong {
    font-size: 24px;
  }

  .disclaimer {
    padding: 10px 12px;
    font-size: 14px;
  }

  .library-panel,
  .workbench-panel,
  .insight-panel,
  .graph-section,
  .association-panel,
  .audit-panel {
    width: 100%;
    max-width: 100%;
    padding: 12px;
  }

  .panel-heading,
  .section-title {
    align-items: center;
  }

  .mobile-only {
    display: inline-flex;
  }

  h2 {
    font-size: 18px;
  }

  h3 {
    font-size: 15px;
  }

  .slot-grid {
    grid-template-columns: repeat(5, 96px);
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }

  .slot {
    min-height: 100px;
    scroll-snap-align: start;
  }

  .slot-herb {
    min-height: 82px;
    padding: 8px 6px;
  }

  .slot-herb strong {
    font-size: 17px;
  }

  .change-board {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .visual-band {
    gap: 10px;
  }

  .radar-wrap,
  .effect-wrap {
    padding: 12px;
  }

  #radarCanvas {
    max-width: 300px;
  }

  .effect-bars {
    max-height: 260px;
  }

  .effect-bar {
    grid-template-columns: 72px 1fr 38px;
    gap: 8px;
    font-size: 14px;
  }

  .bar-source {
    font-size: 12px;
  }

  .herb-library {
    max-height: none;
    grid-template-columns: 1fr;
  }

  .herb-card {
    padding: 10px;
  }

  .herb-name {
    font-size: 18px;
  }

  .herb-meta {
    font-size: 12px;
  }

  .knowledge-graph {
    width: 100%;
    min-width: 0;
    min-height: 260px;
    height: 300px;
  }

  .graph-scroll {
    max-height: 340px;
    overflow-x: hidden;
  }

  .node-label {
    font-size: 12px;
  }

  .empty-graph-text {
    font-size: 28px;
  }

  .path-card,
  .association-card,
  .audit-item {
    padding: 10px;
  }

  .mini-workbench {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 12px;
    z-index: 50;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    min-height: 58px;
    padding: 9px 12px;
    border: 1px solid rgba(11, 124, 119, 0.28);
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    box-shadow: 0 12px 34px rgba(24, 34, 44, 0.22);
    opacity: 0;
    transform: translateY(90px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    text-align: left;
  }

  .mini-workbench.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .mini-count {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    height: 36px;
    background: var(--teal);
    color: #fff;
    font-weight: 900;
  }

  .mini-herbs {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 800;
  }

  .mini-action {
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
  }
}

@media (max-width: 430px) {
  .app-header h1 {
    font-size: 30px;
  }

  .slot-grid {
    grid-template-columns: repeat(5, 88px);
  }

  .effect-bar {
    grid-template-columns: 64px 1fr 34px;
  }
}
