:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #697586;
  --line: #d9e1e8;
  --accent: #1f6f5b;
  --blue: #235c9f;
  --red: #a82f3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

a {
  color: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

.layout {
  width: min(1180px, calc(100vw - 28px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.chat,
.side section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chat {
  min-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.bar {
  min-height: 76px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.top-actions a {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  background: #fff;
}

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

.selected-action {
  background: var(--blue);
}

.messages {
  padding: 16px;
  overflow: auto;
}

.bubble {
  max-width: 78%;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.user {
  margin-left: auto;
  background: #e6eef8;
}

.assistant {
  background: #edf5f1;
}

.system {
  max-width: 100%;
  background: #fff6df;
  color: #624b17;
}

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

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
}

.side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.side section {
  padding: 14px;
}

dl {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px 12px;
  margin: 14px 0 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

pre {
  margin: 12px 0 0;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
}

.admin-layout {
  width: min(1280px, calc(100vw - 28px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.admin-header,
.asset-shell,
.asset-list,
.asset-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-header {
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.asset-shell {
  min-height: calc(100vh - 122px);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}

.logs-shell {
  min-height: calc(100vh - 122px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.logs-bar {
  min-height: 76px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.logs-list {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.log-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.log-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.log-head strong {
  color: var(--ink);
  font-size: 14px;
}

.log-user,
.log-reply,
.log-assets,
.empty-state {
  margin: 10px 0 0;
  line-height: 1.45;
}

.log-user {
  padding: 10px;
  border-radius: 8px;
  background: #e6eef8;
}

.log-reply {
  padding: 10px;
  border-radius: 8px;
  background: #edf5f1;
}

.log-assets {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.log-meta {
  margin-top: 10px;
}

.asset-list {
  border-width: 0 1px 0 0;
  border-radius: 0;
  padding: 14px;
  overflow: auto;
}

.asset-list-title p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.asset-button {
  width: 100%;
  min-height: 62px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  display: grid;
  gap: 4px;
}

.asset-button span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.asset-button.selected {
  border-color: var(--accent);
  background: #edf5f1;
}

.asset-editor {
  border: 0;
  border-radius: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.editor-bar {
  min-height: 76px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.asset-editor textarea {
  min-height: 560px;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.55;
}

.editor-footer {
  min-height: 42px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.status-error {
  color: var(--red);
  font-weight: 750;
}

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

  .chat {
    min-height: 70vh;
  }

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

  .admin-header,
  .editor-bar,
  .logs-bar,
  .editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .asset-shell {
    grid-template-columns: 1fr;
  }

  .asset-list {
    border-width: 0 0 1px;
  }
}
