:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #f0f3ee;
  --line: #d9dfd7;
  --ink: #17211c;
  --muted: #68746e;
  --accent: #1d766f;
  --accent-strong: #145c56;
  --accent-soft: #dcefed;
  --warn: #a05a12;
  --shadow: 0 18px 42px rgba(27, 41, 34, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

button,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.chat-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.app-header,
.display-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.app-header h1,
.display-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.app-header h1 {
  max-width: 300px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.app-header p,
.eyebrow {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.icon-button,
.composer button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 24px;
}

.icon-button:hover,
.composer button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 22px;
}

.message {
  display: grid;
  gap: 6px;
  margin: 0 0 16px;
}

.message-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.48;
  font-size: 14px;
}

.message.user {
  justify-items: end;
}

.message.user .bubble {
  background: var(--accent);
  color: #ffffff;
}

.message.assistant .bubble {
  background: var(--panel-soft);
  color: var(--ink);
}

.message.error .bubble {
  background: #fff4e8;
  color: #7c3f00;
  border: 1px solid #f3d0aa;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 150px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
  line-height: 1.45;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer button {
  width: 44px;
  height: 44px;
  align-self: end;
  border-radius: 8px;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-size: 30px;
  line-height: 1;
}

.composer button:disabled {
  cursor: progress;
  opacity: 0.55;
}

.display-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.display-header {
  background: rgba(246, 247, 244, 0.88);
}

.stream-state {
  min-width: 84px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  text-align: center;
  font-size: 12px;
}

.stream-state.live {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(380px, 1.22fr);
  gap: 18px;
  min-height: 0;
  overflow: hidden;
  padding: 18px;
}

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

.result-surface {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.preview-error {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 18px;
  color: var(--warn);
  text-align: center;
  line-height: 1.45;
}

.result-output {
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 22px;
  line-height: 1.58;
  font-size: 15px;
}

.result-output.empty {
  color: var(--muted);
}

.result-output pre {
  margin: 14px 0;
  padding: 14px;
  overflow-x: auto;
  border-radius: 8px;
  background: #101815;
  color: #eef8f4;
  line-height: 1.45;
}

.result-output code {
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  font-size: 0.92em;
}

.result-output p {
  margin: 0 0 12px;
}

.result-output a {
  color: var(--accent-strong);
}

.artifact-panel {
  display: grid;
  grid-template-rows: auto minmax(0, auto) minmax(0, 1fr);
  padding: 16px;
  overflow: hidden;
}

.artifact-panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.artifact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  max-height: 94px;
  overflow: auto;
  margin-bottom: 12px;
  padding-bottom: 2px;
}

.artifact-link {
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--panel-soft);
  text-decoration: none;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-preview {
  display: grid;
  place-items: center;
  min-height: 0;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.artifact-preview iframe,
.artifact-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border: 0;
  object-fit: contain;
}

.context-menu {
  position: fixed;
  z-index: 20;
  min-width: 138px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 34px rgba(23, 33, 28, 0.18);
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.context-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 46vh) minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
    overflow: auto;
  }

  .chat-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .result-layout {
    grid-template-columns: 1fr;
  }

  .artifact-panel {
    min-height: 260px;
  }
}
