:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --panel: #ffffff;
  --ink: #22303a;
  --muted: #60707c;
  --accent: #1f7a6d;
  --warn: #a33b2e;
  --line: #e5ddd0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #14332f;
  color: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.subtitle { margin: 0.2rem 0 0; color: #cfe3dd; }

.health-badge {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: #5b6670;
  font-size: 0.9rem;
  white-space: nowrap;
}

.health-online { background: #1f7a3a; }
.health-offline { background: var(--warn); }
.health-unknown { background: #5b6670; }

.alert {
  margin: 0.75rem 1.25rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid #e8b4ac;
  background: #fdecea;
  color: #7a241b;
  border-radius: 0.5rem;
}

.hidden { display: none; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 5fr) minmax(320px, 6fr);
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
}

.panel h2 { margin-top: 0; }
.panel h3 { margin-bottom: 0.35rem; }

.stage {
  width: 100%;
  height: 380px;
  background: linear-gradient(#dfe9e6, #f6f4ee);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
}

.stage canvas { width: 100% !important; height: 100% !important; display: block; }

.hint { color: var(--muted); font-size: 0.9rem; }
code { background: #efe9dc; padding: 0 0.3rem; border-radius: 0.25rem; }

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.file-button, button, select {
  font: inherit;
}

.file-button, button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 0.45rem;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

button:hover, .file-button:hover { filter: brightness(0.94); }

select, input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

#modelSelect { min-width: min(100%, 22rem); flex: 1; }

.box {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin: 0.75rem 0;
  background: #fffdf8;
}

.chat-log {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  min-height: 220px;
  max-height: 46vh;
  overflow: auto;
  padding: 0.6rem;
  background: #fbfaf7;
}

.chat-item { margin: 0.45rem 0; }
.chat-item .role { font-size: 0.78rem; color: var(--muted); }
.chat-item .body { white-space: pre-wrap; word-break: break-word; }

.chat-form { margin-top: 0.6rem; }
.chat-form .row input { flex: 1; min-width: 12rem; }
.check { display: block; margin-top: 0.4rem; font-size: 0.9rem; color: var(--muted); }

.motion-list, .memory-list {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.motion-item, .memory-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.4rem 0.55rem;
  background: #fbfaf7;
}

.motion-item select { flex: 1; min-width: 9rem; }

.app-footer {
  padding: 0 1.25rem 1.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; }
}
