:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #edf3ef;
  --ink: #18231f;
  --muted: #65746c;
  --line: #d9e2dc;
  --green: #1e7d5a;
  --green-dark: #0d5f43;
  --blue: #256f9c;
  --amber: #b86b14;
  --red: #b24a3f;
  --shadow: 0 16px 40px rgba(27, 42, 35, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #14221d;
  color: #f7fbf8;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d4f2df;
  color: #123327;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #b8c9c0;
  font-size: 12px;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dbe9e1;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  color: #93d2af;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-panel {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.strategy-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 10px 0;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.strategy-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: #dbe9e1;
  background: transparent;
}

.strategy-button.active {
  color: #133025;
  background: #d4f2df;
  font-weight: 700;
}

.hint {
  margin: 0;
  color: #b8c9c0;
  font-size: 12px;
  line-height: 1.6;
}

.compliance {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.compliance label {
  display: flex;
  gap: 8px;
  color: #dbe9e1;
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 26px;
}

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

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.18;
  letter-spacing: 0;
}

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

.topbar-actions,
.composer-actions,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.conversation-panel,
.analysis-panel,
.metric-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.conversation-panel {
  min-height: 720px;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.panel-head h2,
.analysis-panel h2 {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: 0;
}

.compact {
  align-items: flex-start;
}

.progress-ring {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green) 65deg, #e5ece8 0);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.quick-start {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 8px;
}

.quick-start button,
.chip-list li,
.keyword {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
}

.quick-start button {
  min-height: 34px;
  padding: 0 12px;
}

.chat-log {
  flex: 1;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 8px 0 16px;
}

.message {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.65;
  font-size: 14px;
}

.next-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 14px;
  padding: 14px;
  border: 1px solid #b9dccc;
  border-radius: 8px;
  background: #eef8f2;
}

.next-step strong,
.next-step span {
  display: block;
}

.next-step strong {
  margin: 5px 0;
}

.next-step span {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.next-step .ghost-button {
  flex: 0 0 auto;
}

.message.ai {
  background: var(--surface-soft);
}

.message.user {
  justify-self: end;
  color: #ffffff;
  background: var(--green);
}

.message strong {
  display: block;
  margin-bottom: 4px;
}

.composer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  max-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfdfb;
  outline: none;
  line-height: 1.55;
}

.composer textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 125, 90, 0.12);
}

.composer-actions {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.insight-column {
  display: grid;
  gap: 14px;
}

.metric-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.metric {
  min-height: 96px;
  padding: 14px;
  display: grid;
  gap: 6px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 34px;
  line-height: 1;
}

.analysis-panel {
  padding: 18px;
}

.contradiction-map {
  display: grid;
  grid-template-columns: 1fr 42px 1fr;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.map-node {
  min-height: 94px;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
}

.map-node span {
  color: var(--muted);
  font-size: 12px;
}

.map-node strong {
  margin-top: 6px;
  line-height: 1.35;
}

.improve {
  background: #eaf5ee;
}

.worsen {
  background: #fff2df;
}

.map-line {
  height: 2px;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.chip-list,
.risk-list,
.claim-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.chip-list li {
  padding: 9px 12px;
  line-height: 1.45;
  font-size: 13px;
}

.risk-list li {
  padding: 11px 12px;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  background: #fff8ed;
  color: #4a3720;
  font-size: 13px;
  line-height: 1.55;
}

.advisor-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.advisor-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.advisor-card.applied {
  border-color: #8cc7ad;
  background: #f2fbf5;
}

.advisor-card strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.advisor-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.advisor-card button {
  margin-top: 12px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-empty,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfb;
}

.history-empty {
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.history-card strong,
.history-card span {
  display: block;
}

.history-card p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.history-card blockquote {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 4px solid #b9dccc;
  background: #f6fbf8;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.history-card span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.history-card button {
  margin-top: 10px;
}

.grade {
  border-radius: 999px;
  padding: 4px 8px;
  color: #ffffff;
  background: var(--green);
  font-size: 12px;
}

.grade.warn {
  background: var(--amber);
}

.section-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.wide {
  width: 100%;
}

.feature-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.feature-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.feature-row strong,
.feature-row span {
  min-width: 0;
}

.status {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.medium {
  color: #6d3c04;
  background: #ffe1b3;
}

.status.low {
  color: #0f593e;
  background: #cdeed9;
}

.keyword-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.keyword {
  padding: 9px 12px;
}

.conflict-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  color: #ffffff;
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.conflict-badge.medium,
.conflict-badge.high {
  background: var(--amber);
}

.conflict-badge.high {
  background: var(--red);
}

.real-search-panel {
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr) 180px auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.real-search-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.real-search-panel input,
.real-search-panel select {
  min-height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
}

.api-help {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f5;
}

.api-help strong {
  display: block;
  margin-bottom: 4px;
}

.api-help p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.patent-search-note {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  color: #4a3720;
  background: #fff8ed;
  line-height: 1.55;
  font-size: 13px;
}

.patent-result-list,
.avoidance-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.patent-result-card,
.avoidance-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfb;
}

.avoidance-card.applied {
  border-color: #8cc7ad;
  background: #f2fbf5;
}

.patent-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.patent-result-card p,
.avoidance-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.avoidance-card button {
  margin-top: 12px;
}

.patent-result-card dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.patent-result-card dl div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
}

.patent-result-card dt {
  color: var(--green-dark);
  font-weight: 800;
}

.patent-result-card dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 900px) {
  .real-search-panel {
    grid-template-columns: 1fr;
  }
}

.draft-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.figure-panel {
  grid-column: 1 / -1;
}

.review-panel {
  grid-column: 1 / -1;
}

.iteration-panel,
.portfolio-panel {
  align-self: start;
}

.readiness-score {
  color: var(--green-dark);
  font-size: 28px;
}

.readiness-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e8e3;
  margin: 14px 0;
}

.readiness-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--green));
}

.submit-verdict {
  padding: 12px;
  border-radius: 8px;
  background: #eef8f2;
  color: var(--green-dark);
  line-height: 1.55;
  font-weight: 700;
}

.gap-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.gap-list li {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfdfb;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.full-button {
  width: 100%;
}

.portfolio-summary {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #eef8f2;
  color: var(--green-dark);
  line-height: 1.55;
  font-weight: 700;
}

.portfolio-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.portfolio-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.portfolio-card strong {
  display: block;
  margin-bottom: 6px;
}

.portfolio-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.portfolio-card.recommended {
  border-color: #8cc7ad;
  background: #f2fbf5;
}

.figure-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.figure-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
}

.figure-tab.active {
  color: #ffffff;
  border-color: var(--green);
  background: var(--green);
}

.figure-canvas {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.figure-canvas svg {
  display: block;
  min-width: 860px;
  width: 100%;
  height: auto;
}

.draft-doc {
  margin-top: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  line-height: 1.75;
}

.draft-selection-mark {
  padding: 2px 3px;
  border-radius: 4px;
  background: #ffe1b3;
}

.selected-fragment {
  margin: 14px 0;
  min-height: 48px;
  padding: 12px;
  border: 1px dashed #b9dccc;
  border-radius: 8px;
  background: #f6fbf8;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.review-input {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.review-input textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfdfb;
  outline: none;
  line-height: 1.55;
}

.review-input textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 125, 90, 0.12);
}

.feedback-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.feedback-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.feedback-card strong {
  display: block;
  color: var(--green-dark);
  font-size: 12px;
}

.feedback-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.feedback-card span {
  color: var(--ink);
  font-weight: 800;
}

.draft-doc h3 {
  margin: 18px 0 6px;
  font-size: 16px;
}

.draft-doc h3:first-child {
  margin-top: 0;
}

.claim-list {
  counter-reset: claim;
  list-style: none;
}

.claim-list li {
  counter-increment: claim;
  position: relative;
  padding: 12px 12px 12px 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
}

.claim-list li::before {
  content: counter(claim);
  position: absolute;
  left: 12px;
  top: 14px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.timeline,
.oa-flow {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.timeline-item,
.flow-step {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.timeline-item strong,
.flow-step strong {
  display: block;
  margin-bottom: 6px;
}

.timeline-item p,
.flow-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace-grid,
  .draft-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .composer-actions,
  .panel-head,
  .next-step {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button,
  .next-step button,
  .composer-actions button {
    width: 100%;
  }

  .metric-board {
    grid-template-columns: 1fr;
  }

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

  .map-line {
    width: 2px;
    height: 28px;
    justify-self: center;
  }

  .feature-row {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }
}
