:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --surface: #fffdf8;
  --ink: #1f2522;
  --muted: #6d746f;
  --line: #d8d2c5;
  --accent: #2f6f73;
  --accent-dark: #194f52;
  --green: #1f7a4d;
  --red: #a13b35;
  --amber: #946c20;
  --code: #151816;
  --code-muted: #94a39b;
  --shadow: 0 18px 48px rgba(31, 37, 34, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
  background: #eef7f4;
  transform: translateY(-1px);
}

button:active,
.file-button:active {
  transform: translateY(0);
}

button.primary,
#sendButton,
#applyButton,
#ingestButton {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button.primary:hover,
#sendButton:hover,
#applyButton:hover,
#ingestButton:hover {
  background: var(--accent-dark);
}

.file-button input {
  display: none;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 0.9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
  padding: 12px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.15);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42vw);
  min-height: 100svh;
}

.left-pane {
  min-width: 0;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.right-pane {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #202521;
  color: #f4f0e8;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100svh;
  position: sticky;
  top: 0;
}

.topbar,
.setup-band,
.workspace-grid,
.chat-panel {
  animation: rise 360ms ease both;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.topbar-actions,
.source-controls,
.diff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.setup-band {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.setup-copy h2,
.section-head h2,
.diff-header h2 {
  margin: 0;
  font-size: 1rem;
}

.setup-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 680px;
}

#pasteSource {
  grid-column: 1 / -1;
  min-height: 96px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
  gap: 16px;
  min-height: 420px;
}

.file-list,
.reader,
.chat-panel {
  min-width: 0;
}

.section-head,
.diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head span,
#pendingCount,
#selectedPatchPath {
  color: var(--muted);
  font-size: 0.8rem;
}

.right-pane .section-head span,
.right-pane #pendingCount {
  color: var(--code-muted);
}

#fileTree,
.patch-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.file-row,
.patch-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  justify-content: flex-start;
  background: transparent;
  text-align: left;
  min-height: 38px;
}

.file-row:last-child,
.patch-row:last-child {
  border-bottom: 0;
}

.file-row.active,
.patch-row.active {
  background: #e1efed;
  color: var(--accent-dark);
}

.patch-list {
  background: #161a17;
  border-color: #3c443e;
  max-height: 130px;
  overflow: auto;
}

.patch-row {
  color: #f4f0e8;
  border-color: #3c443e;
}

.patch-row.active {
  background: #263d3d;
  color: white;
}

#fileEditor {
  min-height: 375px;
}

.chat-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.chat-log {
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #dfece9;
}

.message.assistant {
  align-self: flex-start;
  background: #f1eadc;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}

#chatInput {
  min-height: 74px;
}

.voice-status {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 8px;
}

.diff-header {
  margin-bottom: 0;
}

.diff-header .eyebrow {
  color: #a5d4cf;
}

.diff-view {
  flex: 1;
  min-height: 260px;
  margin: 0;
  overflow: auto;
  border: 1px solid #3c443e;
  border-radius: 6px;
  background: #111411;
  color: #e9e5dd;
  padding: 14px;
  font: 0.82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.diff-add {
  color: #8ee0ad;
}

.diff-remove {
  color: #ff9b95;
}

.diff-meta {
  color: #9ab3ff;
}

.manual-patch {
  min-height: 240px;
}

#patchEditor {
  min-height: 170px;
  background: #151816;
  border-color: #3c443e;
  color: #f4f0e8;
}

#updatePatchButton {
  margin-top: 8px;
}

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

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

  .right-pane {
    position: static;
    max-height: none;
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .left-pane,
  .right-pane {
    padding: 18px;
  }

  .topbar,
  .setup-band,
  .workspace-grid,
  .chat-compose {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .source-controls,
  .diff-actions {
    justify-content: stretch;
  }

  button,
  .file-button {
    width: 100%;
  }

  .message {
    max-width: 100%;
  }
}

