 :root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182230;
  --muted: #667085;
  --border: #d9e0ea;
  --border-strong: #b9c4d2;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --add-bg: #dcfce7;
  --add-text: #166534;
  --del-bg: #fee2e2;
  --del-text: #991b1b;
  --code-bg: #fbfcff;
}

* { box-sizing: border-box; }

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

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

.app {
  width: min(1440px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .04);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.segmented input:checked + span {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .22);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 14px;
  min-height: calc(100vh - 108px);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .05);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfcff;
}

.pane-title {
  font-size: 14px;
  font-weight: 700;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

textarea, .result-wrap {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  outline: none;
  resize: none;
  padding: 14px;
  background: var(--code-bg);
  color: var(--text);
  font: 13px/1.55 Consolas, Menlo, Monaco, "Courier New", monospace;
  tab-size: 2;
  overflow: auto;
}

textarea:focus { background: #fff; }

textarea::placeholder { color: #98a2b3; }

.result-wrap { white-space: pre-wrap; }

#result {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

del, ins {
  display: inline;
  border-radius: 3px;
  padding: 0 1px;
  text-decoration: none;
}

del {
  color: var(--del-text);
  background: var(--del-bg);
}

ins {
  color: var(--add-text);
  background: var(--add-bg);
}

.chunk-header {
  display: block;
  margin: 8px 0;
  color: #7c3aed;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .pane { min-height: 360px; }
}

@media (max-width: 760px) {
  .app { width: min(100vw - 20px, 1440px); padding-top: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented span { min-width: 58px; }
}
