:root {
  color-scheme: light;
  --ink: #17242b;
  --muted: #667782;
  --line: #d7e4e7;
  --panel: #ffffff;
  --soft: #eef8f4;
  --green: #2d9b78;
  --blue: #2b6f9f;
  --red: #c4514a;
  --yellow: #f5c84c;
  --dark: #1d313a;
  --shadow: 0 18px 38px rgba(31, 55, 66, 0.11);
  --soft-shadow: 0 10px 24px rgba(31, 55, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.42)),
    linear-gradient(135deg, #eef8f4 0%, #f9fbf1 48%, #eef6fb 100%);
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.type-panel {
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)),
    var(--dark);
  color: #f8fbfc;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--yellow), #ffe08a);
  color: var(--dark);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(245, 200, 76, 0.18);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.relation-card h2,
.relation-card p,
.example-card p,
.rule-card h2,
.thought-veil p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
}

.brand p {
  margin-top: 4px;
  color: #bed0d7;
  font-size: 12px;
}

.select-field {
  display: grid;
  gap: 8px;
  color: #d7e2e7;
  font-weight: 800;
  font-size: 13px;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  padding: 13px;
  line-height: 1.7;
}

select:focus,
textarea:focus {
  border-color: rgba(43, 111, 159, 0.58);
  box-shadow: 0 0 0 4px rgba(43, 111, 159, 0.11);
}

.relation-card,
.example-card,
.rule-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.eyebrow {
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 11px;
  font-weight: 900;
}

.type-panel .eyebrow {
  color: #9ee6cc;
}

.relation-card h2 {
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.45;
}

.relation-card p,
.example-card p {
  margin-top: 10px;
  color: #d4e0e5;
  line-height: 1.7;
  font-size: 13px;
}

.example-card button {
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
  color: var(--dark);
  background: linear-gradient(135deg, var(--yellow), #ffe08a);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(245, 200, 76, 0.2);
  font-size: 13px;
}

.rule-card {
  margin-top: auto;
}

.rule-card h2 {
  font-size: 14px;
}

.rule-card ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: #d4e0e5;
  line-height: 1.8;
  font-size: 13px;
}

.chat-shell {
  min-width: 0;
  padding: 22px 24px;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto;
  gap: 16px;
}

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

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(18px, 2.05vw, 25px);
  line-height: 1.25;
  white-space: nowrap;
}

.guard-badge {
  border: 1px solid rgba(45, 155, 120, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  padding: 9px 14px;
  color: #23604b;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: var(--soft-shadow);
}

.conversation,
.insight-panel,
.composer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.conversation {
  min-height: 330px;
  max-height: 50vh;
  overflow: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(238, 248, 244, 0.6), rgba(255, 255, 255, 0.86)),
    rgba(255, 255, 255, 0.9);
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #223844, #1d313a);
  color: #ffffff;
  font-weight: 900;
}

.message.user .avatar {
  background: linear-gradient(135deg, var(--green), #44b28f);
}

.bubble {
  max-width: min(760px, 86%);
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e0ebe8;
  padding: 13px 15px;
  line-height: 1.75;
  box-shadow: 0 8px 18px rgba(31, 55, 66, 0.06);
}

.message.user .bubble {
  background: #edf7fb;
  border-color: #d8e9f1;
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 8px;
}

.bubble ol,
.bubble ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.bubble li + li {
  margin-top: 6px;
}

.response-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.72fr) minmax(0, 1.28fr);
  gap: 14px;
}

.insight-panel {
  min-height: 214px;
  overflow: hidden;
  position: relative;
}

.panel-head {
  min-height: 50px;
  padding: 13px 15px;
  border-bottom: 1px solid rgba(215, 228, 231, 0.82);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 900;
}

.panel-head strong {
  color: var(--blue);
  font-size: 13px;
  white-space: nowrap;
}

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

.panel-content {
  padding: 15px;
  line-height: 1.75;
}

.panel-content ol,
.panel-content ul {
  margin: 0;
  padding-left: 21px;
}

.panel-content li + li {
  margin-top: 8px;
}

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

.thought-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 250, 249, 0.92));
}

.thought-card.locked .thought-body {
  display: none;
}

.thought-veil {
  min-height: 164px;
  padding: 20px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(135deg, rgba(238, 248, 244, 0.72), rgba(239, 246, 251, 0.78));
}

.thought-card:not(.locked) .thought-veil {
  display: none;
}

.thought-veil p {
  max-width: 220px;
  line-height: 1.6;
}

.panel-head button {
  border: 1px solid rgba(43, 111, 159, 0.22);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 13px;
  color: #27566f;
  background: #ffffff;
  font-weight: 900;
}

.visual {
  background: rgba(251, 253, 248, 0.92);
}

.visual-map {
  padding: 15px;
  display: grid;
  gap: 12px;
}

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

.map-node {
  min-height: 48px;
  border: 1px solid rgba(39, 86, 111, 0.12);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 900;
  line-height: 1.45;
  box-shadow: 0 8px 18px rgba(31, 55, 66, 0.06);
}

.map-node.root {
  border-color: rgba(45, 155, 120, 0.26);
  background: linear-gradient(135deg, #ddf7ea, #f6fff9);
  color: #145b42;
}

.map-row .map-node:nth-child(1) {
  background: linear-gradient(135deg, #e8f1ff, #f7fbff);
  color: #285984;
}

.map-row .map-node:nth-child(2) {
  background: linear-gradient(135deg, #fff2c7, #fffaf0);
  color: #735516;
}

.map-row .map-node:nth-child(3) {
  background: linear-gradient(135deg, #f0e8ff, #fbf8ff);
  color: #5a4382;
}

.map-row .map-node:nth-child(4) {
  background: linear-gradient(135deg, #ffe6df, #fff8f5);
  color: #884434;
}

.map-node.warn {
  border-color: rgba(196, 81, 74, 0.24);
  background: linear-gradient(135deg, #ffe6df, #fff8f5);
  color: #884434;
}

.composer {
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.composer textarea {
  min-height: 96px;
  border-color: #cfdde0;
  background: #fbfdfc;
}

.composer-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.composer-actions button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
}

#clearBtn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.primary-action {
  border: 0;
  background: linear-gradient(135deg, var(--blue), #3489b7);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(43, 111, 159, 0.2);
}

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

  .type-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand,
  .rule-card {
    grid-column: 1 / -1;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h2 {
    white-space: normal;
  }
}

@media (max-width: 620px) {
  .chat-shell,
  .type-panel {
    padding: 16px;
  }

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

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