:root {
  color-scheme: light;
  --bg: #102436;
  --panel: rgba(248, 252, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --text-0: #15304a;
  --text-1: #2d4a63;
  --text-2: #71879a;
  --line: rgba(186, 211, 230, 0.82);
  --blue: #2f78d4;
  --blue-strong: #1f5fb4;
  --cyan: #43b5cf;
  --green: #1f9d73;
  --amber: #c77920;
  --red: #c84b4b;
  --shadow-lg: 0 20px 52px rgba(14, 42, 67, 0.18);
  --shadow-md: 0 12px 30px rgba(22, 55, 84, 0.12);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 14px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text-0);
  background: var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(120deg, rgba(9, 29, 47, 0.72), rgba(13, 42, 66, 0.46) 46%, rgba(239, 247, 252, 0.28)),
    url("../img/paint-fan-hero.png") center center / cover no-repeat;
  transform: scale(1.02);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 10%, rgba(67, 181, 207, 0.18), transparent 22%),
    radial-gradient(circle at 82% 12%, rgba(199, 121, 32, 0.12), transparent 18%),
    linear-gradient(180deg, rgba(8, 24, 38, 0.08), rgba(8, 24, 38, 0.38));
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  position: relative;
  z-index: 2;
  width: min(1760px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0;
}

.hero-shell {
  position: relative;
  min-height: 150px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid rgba(223, 236, 246, 0.44);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  background: rgba(8, 30, 48, 0.55);
}

.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 58%;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(95deg, rgba(7, 26, 43, 0.88), rgba(13, 48, 75, 0.64) 48%, rgba(255, 255, 255, 0.1));
}

.hero-content {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(720px, 1.45fr);
  gap: 20px;
  align-items: center;
  min-height: 150px;
  padding: 22px 24px;
}

.hero-copy {
  max-width: 720px;
  color: #f5fbff;
}

.eyebrow {
  margin: 0 0 7px;
  color: rgba(128, 215, 238, 0.94);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0 0 8px;
  font-size: clamp(25px, 2.4vw, 38px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 660px;
  margin: 0;
  color: rgba(235, 245, 252, 0.84);
  font-size: 14px;
  line-height: 1.6;
}

.status-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 1.05fr) minmax(140px, 0.9fr) minmax(190px, 1.15fr) minmax(210px, 1.25fr);
  gap: 8px;
  align-items: center;
}

.status-chip {
  min-width: 0;
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid rgba(205, 225, 239, 0.72);
  border-radius: 22px;
  background: rgba(247, 251, 255, 0.86);
  box-shadow: 0 10px 24px rgba(22, 55, 84, 0.1);
  backdrop-filter: blur(12px);
}

.status-chip span,
.profile-grid span,
.metric-control span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-2);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
}

.status-chip strong {
  display: block;
  overflow: hidden;
  color: var(--text-0);
  font-size: 13px;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip {
  position: relative;
  padding-right: 76px;
}

.chip-button {
  position: absolute;
  right: 10px;
  top: 50%;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-0);
  font-size: 12px;
  font-weight: 800;
  transform: translateY(-50%);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(520px, 1.34fr) minmax(360px, 0.98fr);
  gap: 14px;
  height: calc(100vh - 206px);
}

.left-column,
.right-column,
.center-column {
  min-height: 0;
}

.left-column,
.right-column {
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(190, 212, 229, 0.8) transparent;
}

.panel {
  position: relative;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(205, 225, 239, 0.86);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 42%);
}

.panel > * {
  position: relative;
}

.panel-head,
.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 0;
}

.panel-head h2,
.conversation-top h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

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

.compact-head > div:first-child {
  flex: 0 0 156px;
}

.compact-head h2 {
  font-size: 17px;
  line-height: 1.25;
  white-space: nowrap;
}

.metric-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.metric-actions .ghost-button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

select,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-0);
  font-weight: 700;
}

select {
  max-width: 220px;
  padding: 0 12px;
}

.ghost-button {
  padding: 0 14px;
}

.profile-grid,
.metric-grid,
.replay-strip,
.feature-strip,
.analysis-card,
.alert-list,
.mechanism-list,
.checklist,
.report-box {
  padding: 14px 16px 16px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.replay-strip,
.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 0;
}

.feature-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 0;
}

.profile-grid article,
.metric-control,
.replay-strip article,
.feature-strip article,
.analysis-card,
.alert-card,
.mechanism-card,
.report-box {
  border: 1px solid rgba(211, 227, 239, 0.9);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
}

.profile-grid article {
  min-width: 0;
  padding: 13px 14px;
}

.profile-grid strong,
.replay-strip strong,
.feature-strip strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.rpm-inline {
  display: inline-flex !important;
  align-items: baseline;
  gap: 4px;
  color: var(--text-0);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.rpm-inline span {
  display: inline;
  margin: 0;
  color: inherit;
  font: inherit;
  line-height: inherit;
}

.replay-strip article,
.feature-strip article {
  min-width: 0;
  padding: 10px 11px;
}

.replay-strip span,
.feature-strip span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.replay-strip strong {
  font-size: 13px;
}

.feature-strip strong {
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric-control {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
}

.metric-control strong {
  font-size: 19px;
  color: var(--blue-strong);
  line-height: 1.08;
  white-space: nowrap;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.analysis-card {
  display: grid;
  gap: 12px;
  margin: 14px 16px 16px;
  padding: 14px;
}

.spectrum-chart {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: 10px;
  height: 150px;
  padding: 14px 12px 8px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(228, 239, 248, 0.85), rgba(247, 251, 255, 0.68)),
    repeating-linear-gradient(0deg, rgba(114, 141, 162, 0.18) 0 1px, transparent 1px 28px);
}

.bearing-frequency-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.bearing-frequency-grid article {
  min-width: 0;
  padding: 10px 9px;
  border: 1px solid rgba(211, 227, 239, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.bearing-frequency-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bearing-frequency-grid strong {
  display: block;
  color: var(--blue-strong);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.spectrum-chart span {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: var(--h);
  min-height: 20px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #58b0ef, #2f78d4);
}

.spectrum-chart span:nth-child(3),
.spectrum-chart span:nth-child(4),
.spectrum-chart span:nth-child(5) {
  background: linear-gradient(180deg, #f0a04c, #c77920);
}

.spectrum-chart b {
  position: absolute;
  bottom: -22px;
  color: var(--text-2);
  font-size: 10px;
  white-space: nowrap;
}

.analysis-card p {
  margin: 8px 0 0;
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.75;
}

.alert-list,
.mechanism-list {
  display: grid;
  gap: 10px;
}

.alert-card,
.mechanism-card {
  padding: 14px 15px;
}

.alert-card {
  border-left: 5px solid var(--green);
}

.alert-card.watch {
  border-left-color: var(--amber);
}

.alert-card.risk {
  border-left-color: var(--red);
}

.alert-card strong,
.mechanism-card strong {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 15px;
}

.alert-card strong span {
  color: var(--text-2);
  font-size: 12px;
}

.alert-card p,
.mechanism-card p {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.65;
}

.conversation-panel {
  display: flex;
  height: 100%;
  margin-bottom: 0;
  flex-direction: column;
}

.conversation-top {
  align-items: flex-start;
}

.quick-actions {
  display: flex;
  max-width: 54%;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.quick-actions button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(205, 223, 237, 0.9);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(247, 252, 255, 0.98), rgba(236, 245, 253, 0.94));
  color: var(--text-1);
  font-size: 12px;
  font-weight: 800;
}

.chat-stream {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 14px 16px;
}

.bubble {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 24px rgba(55, 98, 140, 0.08);
  font-size: 14px;
  line-height: 1.75;
}

.bubble.assistant {
  align-self: flex-start;
  border: 1px solid rgba(198, 219, 234, 0.92);
  background: linear-gradient(160deg, rgba(246, 251, 255, 0.98), rgba(235, 244, 252, 0.94));
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(160deg, var(--blue), var(--blue-strong));
  color: #fff;
}

.bubble small {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-weight: 800;
}

.bubble.user small {
  color: rgba(255, 255, 255, 0.78);
}

.plain-message {
  white-space: pre-wrap;
}

.markdown-body {
  color: var(--text-1);
}

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

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

.markdown-body p {
  margin: 7px 0;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 10px 0 6px;
  color: var(--text-0);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
}

.markdown-body strong {
  color: var(--text-0);
  font-weight: 900;
}

.markdown-body em {
  color: var(--blue-strong);
  font-style: normal;
  font-weight: 800;
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(222, 235, 246, 0.9);
  color: #26455f;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.92em;
}

.markdown-body ul,
.markdown-body ol {
  margin: 7px 0;
  padding-left: 20px;
}

.markdown-body li {
  margin: 3px 0;
}

.md-table-wrap {
  width: 100%;
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid rgba(197, 218, 234, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
}

.markdown-body table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.55;
  white-space: normal;
}

.markdown-body th,
.markdown-body td {
  padding: 8px 10px;
  border-right: 1px solid rgba(210, 225, 238, 0.9);
  border-bottom: 1px solid rgba(210, 225, 238, 0.9);
  text-align: left;
  vertical-align: top;
}

.markdown-body th:last-child,
.markdown-body td:last-child {
  border-right: 0;
}

.markdown-body tbody tr:last-child td {
  border-bottom: 0;
}

.markdown-body th {
  background: rgba(232, 241, 248, 0.92);
  color: var(--text-2);
  font-weight: 900;
}

.markdown-body tbody tr:nth-child(even) td {
  background: rgba(246, 250, 253, 0.72);
}

.md-risk {
  display: inline-block;
  padding: 0 5px;
  border-radius: 6px;
  font-weight: 900;
}

.md-risk.high {
  background: rgba(200, 75, 75, 0.13);
  color: var(--red);
}

.md-risk.watch {
  background: rgba(199, 121, 32, 0.15);
  color: var(--amber);
}

.md-risk.normal {
  background: rgba(31, 157, 115, 0.13);
  color: var(--green);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(208, 224, 237, 0.88);
}

.composer textarea {
  width: 100%;
  min-height: 70px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: none;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-0);
}

.send-button {
  min-height: 70px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(180deg, #58b0ef, #2f78d4);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 16px 26px rgba(47, 120, 212, 0.26);
}

.auth-modal.hidden {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 28, 44, 0.46);
  backdrop-filter: blur(8px);
}

.auth-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 1px solid rgba(198, 219, 234, 0.92);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 30px 70px rgba(31, 67, 104, 0.24);
}

.auth-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-head h2 {
  margin: 0 0 8px;
}

.auth-head p:last-child {
  margin: 0;
  color: var(--text-2);
  line-height: 1.65;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--text-1);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  max-width: none;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-0);
}

.login-preview {
  min-height: 82px;
  padding: 13px 15px;
  border: 1px solid rgba(211, 227, 239, 0.9);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(247, 252, 255, 0.98), rgba(236, 245, 253, 0.94));
  color: var(--text-1);
  line-height: 1.65;
}

.auth-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth-submit {
  min-height: 44px;
}

.checklist {
  margin: 0;
  list-style: none;
  counter-reset: step;
}

.checklist li {
  counter-increment: step;
  position: relative;
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  padding: 12px 14px 12px 46px;
  border: 1px solid rgba(211, 227, 239, 0.9);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
}

.checklist li::before {
  content: counter(step);
  position: absolute;
  top: 13px;
  left: 14px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: rgba(31, 157, 115, 0.14);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.checklist input {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 18px;
  height: 18px;
}

.checklist strong {
  padding-right: 28px;
  font-size: 14px;
}

.checklist span {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.6;
}

.checklist li.done {
  opacity: 0.62;
}

.report-box {
  margin: 14px 16px 16px;
  min-height: 180px;
  padding: 14px 15px;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
}

@media (max-width: 1320px) {
  .hero-content,
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .conversation-panel {
    min-height: 620px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1760px);
    padding: 12px 0;
  }

  .hero-content,
  .panel-head,
  .conversation-top,
  .composer {
    grid-template-columns: 1fr;
  }

  .hero-content {
    padding: 18px;
  }

  .status-grid,
  .profile-grid,
  .metric-grid,
  .replay-strip,
  .feature-strip,
  .bearing-frequency-grid {
    grid-template-columns: 1fr;
  }

  .status-chip {
    border-radius: 22px;
  }

  .account-chip {
    padding-right: 76px;
  }

  .quick-actions {
    max-width: none;
    justify-content: flex-start;
  }

  select {
    max-width: none;
    width: 100%;
  }

  .send-button {
    min-height: 44px;
  }
}
