:root {
  color-scheme: light;
  --bg: #efeae1;
  --ink: #1c1915;
  --muted: #5f584e;
  --line: #ddd4c6;
  --card: #fffdf8;
  --accent: #1f6b4a;
  --accent-dark: #164c35;
  --danger: #8c2f2a;
  --terminal: #121614;
  --terminal-text: #d7e0d6;
  --shadow: 0 12px 30px rgba(48, 38, 22, 0.06);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top left, rgba(31, 107, 74, 0.08), transparent 32rem),
    var(--bg);
  color: var(--ink);
}

.top {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 4px;
}

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

.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.7rem;
  line-height: 1.2;
}

h2 { font-size: 1.05rem; margin-bottom: 0; }

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 16px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 12px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.workspace {
  display: block;
}

.log-panel,
.result-panel {
  display: flex;
  flex-direction: column;
}

.log-panel { width: 100%; }

.log-panel #log-title { margin-bottom: 8px; }

.result-panel { width: 100%; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.controls .panel { padding: 12px 14px; }

.panel-head,
.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.panel-head { justify-content: space-between; margin-bottom: 14px; }

.controls .panel-head { margin-bottom: 8px; }

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}

.controls .field { margin-bottom: 8px; gap: 4px; }

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d2c8b8;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

textarea { min-height: 96px; max-height: 120px; resize: vertical; line-height: 1.4; }

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

select:disabled,
input:disabled,
textarea:disabled { background: #f6f3ee; color: #777; }

.hint,
.status {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.hint { margin-bottom: 14px; }

.controls .hint { margin-bottom: 8px; }

.status { min-height: 1.2em; margin: 0 0 8px; }

.status:empty { display: none; }

.button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}

.button:disabled { cursor: not-allowed; opacity: 0.65; }

#run-agent:disabled { cursor: wait; }

.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); }

.ghost {
  background: transparent;
  border-color: #d2c8b8;
  color: var(--ink);
}

.ghost:hover { background: #f6f1e8; }

.danger { color: var(--danger); border-color: #e4c4c1; }
.danger:hover { background: #fbf1ef; }

#agent-editor { margin-top: 10px; }

.log,
.result {
  overflow: auto;
}

.log {
  flex: none;
  height: 284px;
  min-height: 284px;
  max-height: 284px;
}

.result {
  height: auto;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.log {
  background: var(--terminal);
  color: var(--terminal-text);
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.log-line {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line .tag { color: #e2b15a; }

.log-line.action .body { color: #8fd0c6; }
.log-line.observation .body { color: #c5d2b8; }
.log-line.error .body { color: #ffb4a8; }
.log-line.status .body { color: #9aa89a; }

.placeholder { color: var(--muted); margin: 0; }
.log .placeholder { color: #8d978c; }

.result { padding-right: 4px; line-height: 1.5; }
.result h1, .result h2, .result h3, .result h4 { margin: 0.8em 0 0.35em; }
.result h1 { font-size: 1.35rem; }
.result h2 { font-size: 1.15rem; }
.result p { margin: 0.4em 0; }
.result ul, .result ol { margin: 0.4em 0; padding-left: 1.2rem; }
.result code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f3efe6;
  padding: 0.1em 0.3em;
  border-radius: 4px;
}
.result pre {
  background: #f3efe6;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
}
.result pre code { background: transparent; padding: 0; }
.result a { color: var(--accent-dark); }

@media (max-width: 900px) {
  .controls { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
  .log { height: 264px; min-height: 264px; max-height: 264px; }
  .log-line { grid-template-columns: 1fr; gap: 2px; }
}
