:root {
  color-scheme: light;
  --bg: #f6efe3;
  --bg-pattern: rgba(225, 184, 121, 0.13);
  --card: rgba(255, 250, 243, 0.82);
  --card-strong: #fffaf4;
  --card-soft: #fcf6ef;
  --line: rgba(130, 95, 54, 0.12);
  --text: #2e2115;
  --muted: #7e6850;
  --accent: #b06126;
  --accent-strong: #8e4d1d;
  --danger: #b54a45;
  --success: #2e9c65;
  --shadow: 0 24px 60px rgba(124, 88, 45, 0.12);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.2)),
    repeating-linear-gradient(
      90deg,
      transparent 0 22px,
      var(--bg-pattern) 22px 42px,
      transparent 42px 72px
    ),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  position: relative;
  padding: 30px;
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 210, 145, 0.35), transparent 24%),
    radial-gradient(circle at 78% 16%, rgba(255, 208, 170, 0.25), transparent 20%);
}

.workspace {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.2fr);
  gap: 18px;
  grid-template-areas:
    "hero health"
    "config results"
    "config logs";
}

.card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hero-card,
.health-card,
.config-card,
.results-card,
.logs-card {
  padding: 24px;
  min-width: 0;
}

.hero-card {
  grid-area: hero;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 210px;
  overflow: hidden;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.hero-badge {
  display: inline-flex;
  margin: 0 0 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #f2e4d2;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.hero-card h1 {
  margin: 0 0 12px;
  font-size: clamp(42px, 4vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero-text {
  margin: 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.hero-orb {
  align-self: flex-end;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent 38%),
    linear-gradient(180deg, rgba(245, 198, 162, 0.55), rgba(232, 181, 143, 0.2));
  transform: translate(58px, 58px);
}

.health-card {
  grid-area: health;
  min-height: 210px;
}

.health-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 18px;
}

.health-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(181, 74, 69, 0.12);
}

.health-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(46, 156, 101, 0.14);
}

.health-dot.warn {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(176, 97, 38, 0.12);
}

.health-text {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.health-list {
  margin: 0;
  display: grid;
  gap: 12px;
}

.health-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.health-list dt {
  color: var(--muted);
}

.health-list dd {
  margin: 0;
  font-weight: 700;
}

.config-card {
  grid-area: config;
}

.results-card {
  grid-area: results;
}

.logs-card {
  grid-area: logs;
}

.card-title {
  margin-bottom: 18px;
}

.card-title h2,
.section-head h3,
.result-head h3,
.dialog-head h2 {
  margin: 0;
  font-size: 20px;
}

.card-title p,
.section-head p,
.dialog-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.field-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.66);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(176, 97, 38, 0.45);
  box-shadow: 0 0 0 4px rgba(176, 97, 38, 0.08);
}

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

.meta-box,
.summary-item,
.stat-card {
  min-width: 0;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.meta-box span,
.summary-item span,
.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.meta-box strong,
.summary-item strong,
.stat-card strong {
  display: block;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 16px;
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(148, 92, 35, 0.12);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff8f2;
}

.btn-muted {
  background: #e9dfd1;
  color: #927d63;
}

.btn-light,
.btn-soft {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #f5d9d7;
  color: var(--danger);
}

.tip-text {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(176, 97, 38, 0.16);
  background: rgba(255, 243, 232, 0.82);
  color: var(--accent-strong);
  line-height: 1.7;
}

.dictionary-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid var(--line);
}

.section-head,
.result-head,
.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.dictionary-summary,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 16px;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.hotword-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hotword-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.hotword-card header,
.hotword-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.hotword-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.hotword-card p,
.hotword-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f2e4d2;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.badge.disabled {
  background: #ece6dd;
  color: var(--muted);
}

.result-panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  padding: 18px;
}

.result-panel + .result-panel {
  margin-top: 16px;
}

.result-panel.compact .result-body {
  height: 180px;
}

.result-panel.large .result-body {
  height: clamp(280px, 42vh, 420px);
  overflow-y: auto;
  padding-right: 8px;
}

.result-head {
  margin-bottom: 12px;
}

.result-head span {
  color: var(--muted);
}

.result-body {
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.result-body p {
  margin: 0 0 12px;
}

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

.result-body::-webkit-scrollbar {
  width: 8px;
}

.result-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(126, 104, 80, 0.28);
}

.result-body.empty,
.empty-state {
  color: var(--muted);
}

.highlight {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  background: #f3d5af;
  color: #6b3b14;
}

.log-output {
  margin: 0;
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: #2a221b;
  color: #f6ede3;
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dialog {
  border: 0;
  background: transparent;
  padding: 0;
}

.dialog::backdrop {
  background: rgba(48, 35, 21, 0.25);
  backdrop-filter: blur(8px);
}

.dialog-card {
  width: min(520px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 28px;
  background: #fff9f2;
  box-shadow: var(--shadow);
}

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

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.icon-button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  cursor: pointer;
}

.icon-button-soft {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.82);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.icon-glyph {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  fill: none;
}

.error-text {
  margin: 14px 0 0;
  color: var(--danger);
}

#sessionState[data-state="idle"] {
  color: var(--muted);
}

#sessionState[data-state="connecting"],
#sessionState[data-state="finishing"] {
  color: var(--accent);
}

#sessionState[data-state="streaming"],
#sessionState[data-state="task-started"] {
  color: var(--success);
}

#sessionState[data-state="task-failed"] {
  color: var(--danger);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "health"
      "config"
      "results"
      "logs";
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 14px;
  }

  .hero-card,
  .health-card,
  .config-card,
  .results-card,
  .logs-card,
  .dialog-card {
    padding: 18px;
  }

  .hero-orb {
    display: none;
  }

  .meta-grid,
  .diagnostic-grid,
  .dictionary-summary,
  .stats-grid,
  .dialog-grid {
    grid-template-columns: 1fr;
  }

  .action-row,
  .section-head,
  .result-head,
  .dialog-head,
  .dialog-actions,
  .hotword-card header,
  .hotword-meta {
    flex-direction: column;
  }
}
