:root {
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --ink: #17211f;
  --muted: #66736f;
  --line: #d9e2df;
  --teal: #0f766e;
  --teal-2: #14b8a6;
  --coral: #e76f51;
  --amber: #b7791f;
  --green: #2f855a;
  --blue: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.85), rgba(238,242,241,0.96)),
    repeating-linear-gradient(90deg, rgba(15,118,110,0.05) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, rgba(231,111,81,0.04) 0 1px, transparent 1px 48px);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

textarea {
  resize: vertical;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 12px 28px;
  border-bottom: 1px solid rgba(217, 226, 223, 0.85);
  background: rgba(247, 250, 249, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--coral));
  font-size: 14px;
  font-weight: 800;
}

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

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

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

.topnav a,
.logout-form button,
.icon-link,
.secondary-action,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.topnav a {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
}

.logout-form {
  margin: 0;
}

.logout-form button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
}

.logout-form button:hover {
  color: var(--ink);
  border-color: var(--teal);
}

.topnav a:hover {
  color: var(--ink);
  border-color: var(--line);
  background: white;
}

svg.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.page-shell {
  width: min(1320px, calc(100vw - 36px));
  margin: 26px auto 42px;
}

.auth-shell {
  display: grid;
  place-items: center;
  width: min(980px, calc(100vw - 36px));
  min-height: calc(100vh - 112px);
  margin: 0 auto;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.72fr);
  gap: 24px;
  width: 100%;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 38%),
    linear-gradient(315deg, rgba(231, 111, 81, 0.10), transparent 44%),
    rgba(255, 255, 255, 0.94);
}

.auth-intro,
.auth-panel {
  border-radius: 8px;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 420px;
  padding: 30px;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(15, 118, 110, 0.95), rgba(13, 97, 91, 0.86)),
    linear-gradient(35deg, rgba(231, 111, 81, 0.46), transparent 48%);
  color: white;
  position: relative;
}

.auth-intro::after {
  content: "";
  position: absolute;
  right: -56px;
  bottom: -78px;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
}

.auth-intro .eyebrow,
.auth-intro .muted-copy {
  color: rgba(255, 255, 255, 0.78);
}

.auth-intro h1 {
  max-width: 420px;
  margin-bottom: 14px;
  font-size: 34px;
}

.auth-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.30);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.auth-metrics {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.auth-metrics div {
  min-height: 78px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.auth-metrics strong,
.auth-metrics span {
  display: block;
}

.auth-metrics strong {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1;
}

.auth-metrics span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  font-weight: 700;
}

.auth-panel {
  padding: 28px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 226, 223, 0.72);
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.auth-form input {
  min-height: 46px;
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 2px;
}

.auth-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.app-shell {
  width: min(1500px, calc(100vw - 28px));
  height: calc(100vh - 116px);
  min-height: 640px;
  margin: 18px auto 30px;
}

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.workspace-grid {
  display: grid;
  gap: 18px;
}

.home-grid {
  grid-template-columns: minmax(0, 1.28fr) minmax(360px, 0.72fr);
  align-items: start;
}

.task-panel,
.object-card,
.recent-panel,
.account-panel,
.compare-panel,
.report-main,
.evaluation-panel,
.feedback-card,
.feedback-history {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head.compact {
  align-items: center;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 10px;
  font-size: 14px;
}

.status-pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  background: #e8fbf7;
  color: #0d615b;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.muted {
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface-2);
}

.active-config {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.api-status {
  color: #0d615b;
}

.api-status.warning {
  color: var(--amber);
}

.config-flash {
  animation: config-flash 0.9s ease-out;
}

label {
  display: grid;
  gap: 8px;
  color: #2f3d39;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.13);
}

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

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.full {
  margin-bottom: 14px;
}

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

.course-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: -2px 0 16px;
}

.topic-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 46%),
    linear-gradient(315deg, rgba(231, 111, 81, 0.10), transparent 52%),
    #fbfdfc;
  color: var(--ink);
  padding: 13px;
  text-align: left;
  cursor: pointer;
}

.topic-card strong {
  font-size: 15px;
}

.topic-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.topic-card:hover {
  border-color: var(--teal);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.10);
  transform: translateY(-1px);
}

.chip {
  cursor: pointer;
}

.chip:hover {
  border-color: var(--coral);
  color: #9f341f;
  background: #fff1eb;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.toggle-grid.single {
  grid-template-columns: 1fr;
}

.toggle-grid label {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 0 10px;
  font-size: 13px;
}

.toggle-grid input {
  accent-color: var(--teal);
}

.custom-model-field input {
  margin-top: 8px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field-error {
  display: block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.success-box {
  border: 1px solid rgba(47, 133, 90, 0.28);
  border-radius: 8px;
  background: #effaf4;
  color: var(--green);
  padding: 12px;
  margin-bottom: 14px;
  font-weight: 800;
}

.password-card {
  grid-template-columns: minmax(0, 0.82fr) minmax(360px, 0.88fr);
}

.feedback-shell {
  width: min(1500px, calc(100vw - 36px));
  margin: 22px auto 42px;
}

.feedback-card,
.feedback-history {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.07), transparent 36%),
    rgba(255, 255, 255, 0.95);
}

.feedback-history {
  margin-top: 18px;
}

.feedback-head {
  align-items: center;
}

.feedback-form {
  display: grid;
  gap: 16px;
}

.feedback-type-field {
  display: grid;
  gap: 9px;
  color: #2f3d39;
  font-weight: 700;
}

.feedback-type-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.feedback-type-options label {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px 16px;
  cursor: pointer;
}

.feedback-type-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.feedback-type-options label:has(input:checked) {
  border-color: var(--teal);
  background: #e8fbf7;
  color: #0d615b;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.feedback-type-options strong {
  font-size: 16px;
}

.feedback-type-options small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.feedback-submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.feedback-submit-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.feedback-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.feedback-list article {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.feedback-list strong,
.feedback-list span {
  display: block;
}

.feedback-list strong {
  margin-bottom: 5px;
  color: var(--ink);
}

.feedback-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.feedback-list em {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef6ff;
  color: #1d4f8f;
  padding: 5px 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.empty-state.compact {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 120px;
  border: 1px dashed rgba(15, 118, 110, 0.25);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--muted);
  text-align: center;
}

.range-group,
.form-slider-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 250, 249, 0.78);
}

.range-group {
  margin: 14px 0;
  padding: 10px;
}

.range-group summary {
  cursor: pointer;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.range-stack {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.range-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  min-height: 0;
  margin: 0;
  font-size: 13px;
}

.range-control span {
  color: var(--ink);
  font-weight: 800;
}

.range-control output {
  justify-self: end;
  min-width: 34px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  background: #ecfbf7;
  color: var(--teal);
  padding: 2px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.range-control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 6px;
  margin: 2px 0 0;
  border-radius: 999px;
  outline: none;
  background:
    linear-gradient(90deg, var(--teal) 0 var(--range-value, 50%), rgba(15, 118, 110, 0.12) var(--range-value, 50%) 100%);
  appearance: none;
}

.range-control input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 3px 10px rgba(23, 33, 31, 0.22);
  appearance: none;
}

.range-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 3px 10px rgba(23, 33, 31, 0.22);
}

.form-slider-panel {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
}

.mini-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.mini-title strong {
  color: var(--ink);
}

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

.form-slider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}

.action-row,
.control-actions,
.chat-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.primary-action,
.secondary-action,
.icon-link {
  border-radius: 8px;
  cursor: pointer;
  transition: 0.16s ease;
}

.primary-action {
  min-height: 42px;
  border: 1px solid var(--teal);
  background: var(--teal);
  color: white;
  padding: 0 16px;
  font-weight: 800;
}

.primary-action:hover {
  background: #0d615b;
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary-action.is-busy {
  background: #0d615b;
}

.secondary-action {
  min-height: 42px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.secondary-action:hover,
.icon-link:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.secondary-action.small {
  width: 100%;
  min-height: 38px;
}

.icon-link {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: white;
}

.icon-link.danger-icon {
  color: var(--danger);
}

.icon-link.danger-icon:hover {
  border-color: rgba(180, 35, 24, 0.45);
  color: var(--danger);
  background: #fff1ef;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.knowledge-map {
  position: relative;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 49%, rgba(15,118,110,0.18) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(231,111,81,0.16) 50%, transparent 51%),
    #fbfdfc;
  overflow: hidden;
}

.knowledge-map::before,
.knowledge-map::after {
  content: "";
  position: absolute;
  inset: 24px 34px;
  border: 1px dashed rgba(15, 118, 110, 0.28);
  transform: rotate(-18deg);
}

.knowledge-map::after {
  inset: 46px 70px;
  border-color: rgba(231, 111, 81, 0.28);
  transform: rotate(18deg);
}

.knowledge-map span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  min-width: 74px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
  text-align: center;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(23, 33, 31, 0.08);
}

.json-preview,
.summary-pre {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: #23302d;
  padding: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.recent-list {
  display: grid;
  gap: 10px;
}

.recent-list.grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.recent-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.recent-item:hover {
  border-color: var(--teal);
}

.recent-item span,
.muted-copy,
.text-link {
  color: var(--muted);
}

.text-link {
  font-weight: 800;
}

.error-box {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--danger);
  padding: 12px;
  margin-bottom: 14px;
}

.lab-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 310px;
  gap: 14px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

.control-panel,
.chat-panel,
.state-panel {
  min-height: 0;
}

.control-panel,
.state-panel {
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 100px);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.messages {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.message {
  width: min(780px, 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px 14px;
}

.message.user {
  justify-self: end;
  border-color: rgba(37, 99, 235, 0.22);
  background: #f0f6ff;
}

.message.assistant {
  justify-self: start;
  border-color: rgba(15, 118, 110, 0.18);
  background: #f4fffc;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message-body {
  line-height: 1.72;
  word-break: break-word;
}

.message-body p {
  margin: 0 0 10px;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  margin: 12px 0 8px;
  color: var(--ink);
  line-height: 1.35;
}

.message-body h3 {
  font-size: 18px;
}

.message-body h4,
.message-body h5,
.message-body h6 {
  font-size: 16px;
}

.message-body ul {
  margin: 0 0 12px 1.1em;
  padding: 0;
}

.message-body li {
  margin: 4px 0;
}

.message-body strong {
  color: #0f4f49;
}

.message-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(15, 118, 110, 0.08);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.94em;
}

.message-body mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 2px 0;
}

.message-body mjx-container[display="true"] {
  display: block;
  margin: 12px 0;
  padding: 8px 0;
  text-align: center;
}

.message-body mjx-container svg {
  width: auto;
  height: auto;
  max-width: none;
  stroke-width: initial;
}

.thinking-message {
  border-color: rgba(231, 111, 81, 0.24);
  background:
    linear-gradient(90deg, rgba(232, 251, 247, 0.92), rgba(255, 241, 235, 0.88));
}

.thinking-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.thinking-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(15, 118, 110, 0.20);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--coral);
  animation: thinking-dot 1.1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 0.32s;
}

.thinking-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.typewriter-active::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.1em;
  margin-left: 3px;
  background: var(--teal);
  vertical-align: -0.18em;
  animation: caret-blink 0.8s steps(1) infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes thinking-dot {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes caret-blink {
  0%, 45% {
    opacity: 1;
  }
  46%, 100% {
    opacity: 0;
  }
}

@keyframes config-flash {
  0% {
    background: rgba(20, 184, 166, 0.18);
  }
  100% {
    background: transparent;
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(247, 250, 249, 0.9);
}

.composer-tools {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.formula-toggle {
  width: auto;
  min-height: 34px;
}

.composer textarea {
  min-height: 72px;
  max-height: 180px;
}

.send {
  align-self: stretch;
  min-height: 72px;
}

.formula-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(15, 118, 110, 0.20);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06), transparent 45%),
    #fbfdfc;
  padding: 12px;
}

.formula-panel[hidden] {
  display: none;
}

.formula-panel-head,
.formula-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.formula-panel-head {
  justify-content: space-between;
}

.formula-panel-head strong {
  color: var(--ink);
}

.formula-panel-head span,
.formula-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
}

.formula-grid button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.formula-grid button:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: #ecfbf7;
}

.formula-custom {
  gap: 7px;
}

.formula-custom textarea {
  min-height: 58px;
  max-height: 130px;
}

.formula-actions .secondary-action.small {
  width: auto;
}

.formula-preview {
  display: grid;
  gap: 7px;
  border: 1px dashed rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

#formula-preview {
  min-height: 44px;
  overflow-x: auto;
  color: var(--ink);
}

.mini-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.kv-list {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 0;
}

.kv-list dt {
  color: var(--muted);
  font-weight: 800;
}

.kv-list dd {
  margin: 0;
  word-break: break-word;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list span {
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 999px;
  background: #e8fbf7;
  color: #0d615b;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.tag-list.amber span {
  border-color: rgba(183, 121, 31, 0.24);
  background: #fff8e6;
  color: var(--amber);
}

.tag-list.danger span {
  border-color: rgba(180, 35, 24, 0.2);
  background: #fff1ef;
  color: var(--danger);
}

.state-meter {
  height: 10px;
  border-radius: 999px;
  background: #edf2f0;
  margin-bottom: 18px;
  overflow: hidden;
}

.state-meter div {
  height: 100%;
  max-width: 100%;
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.quota-meter div {
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--coral));
}

.metric-grid,
.summary-grid {
  display: grid;
  gap: 10px;
}

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

.metric-grid span,
.summary-grid div {
  display: grid;
  gap: 4px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.metric-grid strong,
.summary-grid strong {
  color: var(--teal);
  font-size: 22px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.summary-grid span {
  color: var(--muted);
  font-weight: 800;
}

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

.report-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

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

.report-columns div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.report-columns ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

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

.score-row span {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
}

.score-row strong {
  color: var(--teal);
  font-size: 24px;
}

.evaluation-form {
  display: grid;
  gap: 12px;
}

.evaluation-form label {
  font-size: 13px;
}

.mode-table {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.mode-row {
  display: grid;
  grid-template-columns: 1.4fr 0.45fr 0.6fr 1fr 0.7fr 1.4fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.mode-row.head {
  background: #17211f;
  color: white;
  font-weight: 800;
}

.mode-row .bar {
  display: block;
  height: 7px;
  max-width: 100%;
  margin-top: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.wide {
  margin-top: 18px;
}

@media (max-width: 1180px) {
  .app-shell {
    height: auto;
    min-height: 0;
  }

  .home-grid,
  .report-layout,
  .lab-layout,
  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    min-height: 300px;
  }

  .lab-layout {
    height: auto;
  }

  .control-panel,
  .state-panel {
    max-height: none;
  }

  .chat-panel {
    height: min(760px, calc(100vh - 120px));
    min-height: 560px;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }

  .topnav {
    width: 100%;
    overflow-x: auto;
  }

  .page-shell,
  .app-shell,
  .auth-shell,
  .feedback-shell {
    width: calc(100vw - 20px);
    margin-top: 12px;
  }

  .auth-card {
    padding: 10px;
  }

  .auth-intro,
  .auth-panel {
    padding: 20px;
  }

  .auth-intro h1 {
    font-size: 28px;
  }

  .auth-metrics {
    grid-template-columns: 1fr;
  }

  .form-grid.two,
  .form-grid.three,
  .form-slider-grid,
  .toggle-grid,
  .feedback-type-options,
  .summary-grid,
  .report-columns,
  .score-row,
  .mode-row {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .send {
    min-height: 46px;
  }
}
