:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e7ecf1;
  --muted: #9aa7b5;
  --accent: #3d9cfd;
  --border: #2b3642;
  --ok: #3ecf8e;
  --warn: #e6b84d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1d3a55 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #24301f 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: 0.02em;
}

.sub {
  margin: 0;
  color: var(--muted);
}

.card {
  margin-top: 1.25rem;
  padding: 1.1rem 1.2rem;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.card h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #12181f;
  color: var(--text);
}

.set-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.set-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: #12181f;
}

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

.set-chip .set-apply {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem 0.3rem 0.75rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.set-chip .set-apply:hover {
  background: #1c2632;
}

.set-count {
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #0d1218;
  color: var(--muted);
  font-size: 0.7rem;
}

.set-chip .set-del {
  padding: 0 0.5rem;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.set-chip .set-del:hover {
  background: #3a2020;
  color: #e07a6a;
}

.set-save-row {
  align-items: center;
}

.set-save-row input {
  flex: 1;
  width: auto;
  min-width: 12rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

button {
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #232d38;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #3e4d5d;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #041018;
  font-weight: 600;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.symbols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.symbols label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #12181f;
  cursor: pointer;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border);
}

.ready {
  color: var(--ok);
}

.missing {
  color: var(--warn);
}

.score-table td,
.score-table th {
  white-space: nowrap;
}

.as-of-row {
  align-items: center;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.inline-field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.inline-field input[type="date"] {
  width: auto;
  padding: 0.45rem 0.6rem;
  color-scheme: dark;
}

.mode-banner {
  margin: 0 0 0.6rem;
  padding: 0.45rem 0.7rem;
  border-left: 3px solid var(--warn);
  border-radius: 4px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  font-size: 0.85rem;
}

.rsi-hot {
  color: #e07a6a;
}

.rsi-cold {
  color: #5fd0d6;
}

.range {
  margin-top: 0.5rem;
}

.chart {
  margin: 0 0 1rem;
}

.chart figcaption {
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
  background: #12181f;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-guide {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.6;
}

.chart-axis,
.chart-guide-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.range-subhead {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
}

.range-shade {
  fill: var(--accent);
  opacity: 0.08;
}

.candle-chart figcaption {
  font-size: 0.85rem;
}

.candle-chart .up {
  color: #4ee0a0;
}

.candle-chart .down {
  color: #e07a6a;
}

.range-matrix td {
  text-align: center;
  line-height: 1.25;
}

.range-matrix td:first-child {
  text-align: left;
}

.range-detail td,
.range-detail th {
  white-space: nowrap;
}

.score-strong {
  color: #4ee0a0;
}

.score-good {
  color: #7fd47f;
}

.score-neutral {
  color: var(--text);
}

.score-weak {
  color: var(--warn);
}

.score-bad {
  color: #e07a6a;
}

.link-btn {
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  background: transparent;
}

.ref-cell {
  color: var(--muted);
}

.score-footnote {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.dq {
  display: inline-block;
  width: 13px;
  height: 13px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  background: var(--warn);
  color: #1a1a1a;
  cursor: help;
  vertical-align: super;
}

.dq-note {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--warn);
}

.score-breakdown tr.ref-row td {
  color: var(--muted);
}

.score-detail td {
  padding: 0.5rem 0.75rem 0.9rem;
  background: #0f151c;
}

.score-breakdown {
  font-size: 0.85rem;
}

.score-breakdown .detail-text {
  white-space: normal;
  min-width: 22rem;
  color: var(--muted);
}

.score-breakdown tr.penalty td {
  color: #e0a48a;
}

.score-breakdown tr.total-row td {
  border-top: 1px solid var(--border);
}

.result {
  min-height: 4rem;
  padding: 1rem 1.1rem;
  border-radius: 8px;
  background: #12181f;
  border: 1px solid var(--border);
  line-height: 1.65;
  overflow-x: auto;
}

.result > *:first-child {
  margin-top: 0;
}

.result > *:last-child {
  margin-bottom: 0;
}

.result h1,
.result h2,
.result h3 {
  margin: 1.25rem 0 0.55rem;
  line-height: 1.3;
  color: #f2f6fa;
}

.result h1 {
  font-size: 1.25rem;
}

.result h2 {
  font-size: 1.1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.result h3 {
  font-size: 1rem;
  color: #c9d4e0;
}

.result p {
  margin: 0.55rem 0;
}

.result ul,
.result ol {
  margin: 0.45rem 0 0.75rem;
  padding-left: 1.35rem;
}

.result li {
  margin: 0.35rem 0;
}

.result strong {
  color: #fff;
  font-weight: 650;
}

.result blockquote {
  margin: 0.75rem 0;
  padding: 0.55rem 0.85rem;
  border-left: 3px solid var(--accent);
  background: #18212b;
  color: var(--muted);
}

.result table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 0.75rem 0;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.result th,
.result td {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  vertical-align: top;
}

.result th {
  background: #1a2430;
  white-space: nowrap;
}

.result code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: #1a2430;
}

.result pre {
  overflow-x: auto;
  padding: 0.75rem;
  border-radius: 8px;
  background: #0d1218;
  border: 1px solid var(--border);
}

.result pre code {
  padding: 0;
  background: transparent;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history button {
  text-align: left;
  width: 100%;
}

.hidden {
  display: none !important;
}

.chat-panel {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.chat-panel h3 {
  margin: 0 0 0.35rem;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  margin: 0.75rem 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: #0d1218;
  border: 1px solid var(--border);
}

.chat-log:empty::before {
  content: "还没有追问，直接在下方输入问题。";
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-bubble {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  line-height: 1.55;
}

.chat-bubble.user {
  align-self: flex-end;
  max-width: 92%;
  background: #1a3348;
  white-space: pre-wrap;
}

.chat-bubble.assistant {
  align-self: stretch;
  background: #12181f;
}

.chat-bubble .role {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-fresh-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0.75rem 0;
  font-size: 0.92rem;
  cursor: pointer;
}

.chat-fresh-toggle input {
  width: auto;
}

.chat-tag {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}

.chat-tag.fresh {
  border-color: #2f6b4f;
  color: var(--ok);
  background: #143024;
}

.chat-tag.report-only {
  border-color: #5a4a2a;
  color: var(--warn);
  background: #2a2414;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
}

.chat-compose textarea {
  resize: vertical;
  min-height: 4.5rem;
}

@media (max-width: 640px) {
  .chat-compose {
    grid-template-columns: 1fr;
  }
}
