*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:          #0a0a0a;
  --bg-card:     #111111;
  --bg-elevated: #1a1a1a;
  --border:      #222222;
  --border-mid:  #2e2e2e;
  --text:        #e8e8e8;
  --text-muted:  #555555;
  --text-dim:    #888888;
  --red:         #e53935;
  --red-glow:    rgba(229, 57, 53, 0.25);
  --red-dim:     rgba(229, 57, 53, 0.12);
  --green:       #4ade80;
  --green-dark:  #166534;
  --green-bg:    rgba(74, 222, 128, 0.16);
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── App shell ─────────────────────────────────── */
.dp-app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.dp-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.dp-pane--left {
  flex: 0 0 60%;
  border-right: 1px solid var(--border);
}

.dp-pane--right {
  flex: 1 1 40%;
  background: var(--bg-card);
}

/* ── Toolbars ──────────────────────────────────── */
.dp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  min-height: 52px;
}

.dp-toolbar__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dp-toolbar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dp-status {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.dp-status--active {
  color: var(--green);
}

/* ── Buttons ───────────────────────────────────── */
.dp-btn {
  background: var(--red);
  color: #fff;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, opacity 0.15s;
}

.dp-btn:hover:not(:disabled) { filter: brightness(1.12); }
.dp-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.dp-btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-mid);
}

.dp-btn--ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  filter: none;
}

/* ── Editor area ───────────────────────────────── */
.dp-editor-wrap {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  background: var(--bg);
}

.dp-dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 2px dashed var(--border-mid);
  margin: 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  z-index: 2;
}

.dp-dropzone.is-hidden { display: none; }
.dp-dropzone.is-dragover {
  border-color: var(--red);
  background: var(--red-dim);
}

.dp-dropzone__inner { text-align: center; }
.dp-dropzone__icon {
  font-size: 2rem;
  margin-bottom: 12px;
  color: var(--text-dim);
}
.dp-dropzone__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.dp-dropzone__hint {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.dp-editor {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 56px 96px;
  background: var(--bg-card);
  min-height: 100%;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  outline: none;
}

.dp-editor[contenteditable="true"]:focus {
  box-shadow: 0 0 0 1px var(--border-mid) inset;
}

::highlight(dp-saved-selection) {
  background-color: rgba(80, 130, 255, 0.45);
  color: #fff;
}

.dp-editor h1, .dp-editor h2, .dp-editor h3 { margin: 1.4em 0 0.6em; color: #fff; }
.dp-editor h1 { font-size: 1.6rem; }
.dp-editor h2 { font-size: 1.3rem; }
.dp-editor h3 { font-size: 1.1rem; }
.dp-editor p { margin: 0.8em 0; }
.dp-editor ul, .dp-editor ol { margin: 0.8em 0 0.8em 1.6em; }
.dp-editor li { margin: 0.3em 0; }
.dp-editor strong { color: #fff; }
.dp-editor em { color: var(--text); }

/* ── Clause list + processing state ─────────────── */
.dp-processing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}

.dp-clause { margin: 0 0 1.6em; }
.dp-clause:first-child { margin-top: 0; }
.dp-clause:first-child .dp-clause__title { margin-top: 0; }
.dp-clause__title {
  font-size: 1.1rem;
  color: #fff;
  margin: 0 0 0.4em;
}
.dp-clause__desc {
  margin: 0;
  color: var(--text);
}

/* ── Diff visuals ──────────────────────────────── */
.dp-editor del.dp-diff-del {
  background: var(--red-dim);
  color: var(--red);
  text-decoration: line-through;
  padding: 0 2px;
  border-radius: 2px;
}

.dp-editor ins.dp-diff-ins {
  background: var(--green-bg);
  color: var(--green);
  text-decoration: none;
  padding: 0 2px;
  border-radius: 2px;
}

.dp-editor .dp-diff-block {
  display: inline;
  position: relative;
}

.dp-editor .dp-pending {
  border-bottom: 1px dotted var(--text-dim);
}

.dp-diff-pill {
  position: absolute;
  z-index: 50;
  display: inline-flex;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  font-size: 0.78rem;
}

.dp-diff-pill button {
  border: 0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.dp-diff-pill__accept { background: var(--green); color: #052e16; }
.dp-diff-pill__reject { background: var(--bg-card); color: var(--text); border: 1px solid var(--border-mid) !important; }
.dp-diff-pill__accept:hover { filter: brightness(1.08); }
.dp-diff-pill__reject:hover { background: var(--bg-elevated); }

/* ── Inline diff action buttons ──────────────────── */
.dp-diff-actions {
  display: flex;
  gap: 8px;
  margin: 8px 0 16px;
}

.dp-diff-actions button {
  border: 0;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.dp-diff-actions__accept { background: var(--green); color: #052e16; }
.dp-diff-actions__reject { background: var(--bg-card); color: var(--text); border: 1px solid var(--border-mid) !important; }
.dp-diff-actions__accept:hover { filter: brightness(1.08); }
.dp-diff-actions__reject:hover { background: var(--bg-elevated); }

/* ── Chat panel ────────────────────────────────── */
.dp-chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dp-chat__hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 12px;
  border: 1px dashed var(--border-mid);
  border-radius: 8px;
  text-align: center;
}

.dp-chat__hint.is-hidden { display: none; }

.dp-cross-clause-banner {
  padding: 10px 14px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
}

.dp-cross-clause-banner.is-hidden { display: none; }

.dp-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dp-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.dp-msg--user {
  align-self: flex-end;
  background: var(--red);
  color: #fff;
}

.dp-msg--assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.dp-msg--error {
  align-self: stretch;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.dp-msg--thinking {
  color: var(--text-dim);
  font-style: italic;
}

.dp-msg__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  opacity: 0.7;
}

/* ── Composer ──────────────────────────────────── */
.dp-chat__composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.dp-chat__composer textarea {
  flex: 1 1 auto;
  resize: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
}

.dp-chat__composer textarea:focus:not(:disabled) {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-glow);
}

.dp-chat__composer textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dp-chat__composer .dp-btn {
  align-self: flex-end;
  padding: 10px 18px;
}
