:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --line: #d9e0dc;
  --line-strong: #b9c5bf;
  --ink: #1e2522;
  --muted: #65716c;
  --accent: #16766a;
  --accent-2: #315f9d;
  --warn: #b35c44;
  --ok-bg: #e6f4ec;
  --ok: #247043;
  --warn-bg: #fff0eb;
  --shadow: 0 12px 30px rgba(21, 31, 27, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

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

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

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 18px 14px;
}

.brand {
  display: grid;
  gap: 3px;
  margin-bottom: 22px;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong {
  margin-top: 8px;
  font-size: 15px;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 0 10px;
  color: #39433f;
  font-size: 13px;
  font-weight: 720;
}

.nav-link:hover,
.nav-link.active {
  background: #e7eeea;
  color: var(--ink);
}

.nav-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
}

.nav-link.active .nav-dot,
.nav-link:hover .nav-dot {
  background: var(--accent);
}

.content-shell {
  min-width: 0;
  padding: 22px;
}

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

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

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  max-width: 780px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.status-row {
  display: flex;
  max-width: 560px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chip {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  border: 1px solid rgba(36, 112, 67, 0.18);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.chip[data-state="warn"] {
  border-color: rgba(179, 92, 68, 0.22);
  background: var(--warn-bg);
  color: var(--warn);
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.single-grid {
  display: grid;
  gap: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.model-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(49, 95, 157, 0.16);
  border-radius: 8px;
  background: #eef4fb;
  color: var(--accent-2);
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 820;
  white-space: nowrap;
}

.panel-body {
  padding: 18px;
}

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

.model-card {
  display: grid;
  min-height: 150px;
  align-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.model-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.model-card h2 {
  margin: 0 0 7px;
  font-size: 17px;
  letter-spacing: 0;
}

.model-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 820;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field label {
  color: #44504b;
  font-size: 12px;
  font-weight: 820;
}

.field textarea,
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field textarea {
  min-height: 132px;
  resize: vertical;
  padding: 12px;
  font-size: 14px;
  line-height: 1.55;
}

.field input,
.field select {
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
}

.field textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(22, 118, 106, 0.1);
}

textarea::placeholder,
input::placeholder {
  color: #aab4af;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 4px;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 820;
}

.primary-btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.primary-btn:hover {
  background: #0f1513;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-btn:hover {
  border-color: var(--line-strong);
  background: #f8faf8;
}

.result {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.status-line {
  min-height: 21px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.status-line[data-state="error"] {
  color: var(--warn);
}

.status-line[data-state="ok"] {
  color: var(--ok);
}

.result audio,
.result video {
  width: 100%;
  min-height: 42px;
}

.result img {
  width: min(100%, 720px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101614;
}

.result video {
  border-radius: 8px;
  background: #101614;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.hidden {
  display: none;
}

.side-panel {
  display: grid;
  gap: 12px;
}

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

.metric {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.metric:last-child {
  border-bottom: 0;
}

.metric strong {
  color: var(--ink);
  font-size: 13px;
}

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

.runtime-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 9px;
  align-items: center;
  margin-bottom: 12px;
}

.runtime-controls select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.runtime-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.runtime-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

.runtime-table th,
.runtime-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 12px;
}

.runtime-table th {
  background: #f8faf8;
  color: #44504b;
  font-weight: 820;
}

.runtime-table td strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.runtime-table td span {
  display: inline-flex;
  margin-top: 3px;
  color: var(--muted);
}

.runtime-table tr:last-child td {
  border-bottom: 0;
}

.runtime-actions {
  display: flex;
  gap: 7px;
}

.runtime-actions .secondary-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-btn {
  color: var(--warn);
}

.state-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
  margin: 4px 7px 0 0;
}

.state-dot[data-state="ok"] {
  background: var(--ok);
}

.state-dot[data-state="warn"] {
  background: var(--warn);
}

.chat-panel {
  display: grid;
  min-height: calc(100vh - 148px);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

#chat {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.welcome {
  display: grid;
  min-height: 420px;
  place-content: center;
  gap: 14px;
  text-align: center;
}

.welcome h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.welcome p {
  max-width: 540px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.examples button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 11px;
  color: #3f4945;
  font-size: 13px;
  font-weight: 720;
}

.examples button:hover {
  border-color: var(--line-strong);
  background: #f8faf8;
}

.msg-row {
  display: grid;
  gap: 8px;
  animation: fadeIn 0.22s ease-out;
}

.msg-row + .msg-row {
  margin-top: 15px;
}

.role {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 13px;
  color: #27302c;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.user .content {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.typing::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 16px;
  margin-left: 3px;
  border-radius: 1px;
  background: var(--accent);
  animation: blink 0.72s infinite;
  vertical-align: text-bottom;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 13px 16px 16px;
}

.input-box {
  display: flex;
  min-height: 48px;
  flex: 1;
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
}

.input-box:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(22, 118, 106, 0.1);
}

.input-box textarea {
  width: 100%;
  max-height: 132px;
  min-height: 24px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.send-btn {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .side {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .page-grid,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .runtime-summary,
  .runtime-controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .status-row {
    justify-content: flex-start;
  }
}

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

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

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

  h1 {
    font-size: 23px;
  }

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