/*
 * Copyright (c) 2026 Sitong Fang
 * SPDX-License-Identifier: MIT
 */

:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --paper: #fffdf8;
  --surface: #f8faf9;
  --ink: #201f1c;
  --muted: #6c6a63;
  --line: #d9d4c5;
  --accent: #b23426;
  --teal: #1d6971;
  --gold: #aa7a24;
  --shadow: 0 18px 38px rgba(35, 31, 25, 0.12);
  --radius: 8px;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(178, 52, 38, 0.08), transparent 30%),
    linear-gradient(315deg, rgba(29, 105, 113, 0.12), transparent 32%),
    var(--bg);
  color: var(--ink);
}

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

button {
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  min-height: 78px;
  padding: 12px;
  line-height: 1.55;
}

.shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(420px, 1fr) minmax(280px, 360px);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.inspector,
.workspace {
  min-width: 0;
}

.brand,
.panel,
.workspace {
  border: 1px solid rgba(32, 31, 28, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
}

.brand h1,
.topbar h2,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

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

.brand p,
.mode-label,
.empty {
  color: var(--muted);
}

.brand p,
.mode-label {
  margin: 4px 0 0;
  font-size: 13px;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.panel.compact {
  padding: 14px;
}

.panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-heading button,
.button-row button,
.inline-control button {
  background: #fff;
  color: var(--ink);
}

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

.state-grid div {
  min-width: 0;
}

.state-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.state-grid dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.controls {
  display: grid;
  gap: 14px;
}

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 36px);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  font-size: 24px;
}

.status-pill {
  min-width: 92px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.status-pill[data-tone="ok"] {
  color: var(--teal);
  border-color: rgba(29, 105, 113, 0.45);
}

.status-pill[data-tone="bad"] {
  color: var(--accent);
  border-color: rgba(178, 52, 38, 0.45);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 20px;
}

.message {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: start;
}

.speaker {
  color: var(--muted);
  font-size: 13px;
  padding-top: 8px;
}

.message-body,
.tool-call {
  border-radius: var(--radius);
  padding: 12px 14px;
  line-height: 1.7;
}

.message.assistant .message-body {
  background: var(--surface);
  border: 1px solid var(--line);
}

.message.user .message-body {
  background: #22211e;
  color: #fff;
}

.tool-call {
  align-self: flex-start;
  margin-left: 76px;
  border: 1px solid rgba(29, 105, 113, 0.28);
  color: var(--teal);
  background: rgba(29, 105, 113, 0.06);
  font-size: 13px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
}

.composer button {
  min-width: 96px;
  height: 78px;
}

.metric-list,
.timeline-list,
.relations-list,
.source-list {
  display: grid;
  gap: 10px;
}

.metric-row {
  display: grid;
  grid-template-columns: 90px 1fr 42px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.metric-track {
  height: 6px;
  border-radius: 999px;
  background: #e5dfcf;
  overflow: hidden;
}

.metric-track i {
  display: block;
  height: 100%;
  background: var(--teal);
}

.timeline-item,
.source-item,
.relation-row {
  border-left: 3px solid var(--gold);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.55);
}

.timeline-item span,
.source-item span {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item p,
.source-item p {
  margin: 4px 0 0;
  line-height: 1.55;
}

.source-item div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.relation-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.relation-row strong {
  color: var(--accent);
  font-weight: 600;
}

.error {
  color: var(--accent);
}

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

  .inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .inspector .panel {
    margin-bottom: 0;
  }
}

@media (max-width: 760px) {
  .shell,
  .inspector {
    display: block;
    padding: 10px;
  }

  .workspace {
    min-height: 78vh;
    margin-bottom: 16px;
  }

  .message {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .tool-call {
    margin-left: 0;
  }

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

  .composer button {
    width: 100%;
    height: 44px;
  }
}
