:root {
  --page: #f6f1e7;
  --paper: #fffaf2;
  --ink: #2f281f;
  --muted: #716657;
  --soft: #ece4d7;
  --line: #d8ccbc;
  --code-bg: #272119;
  --code-ink: #f6f1e7;
  --accent: #765132;
  --accent-deep: #51351f;
  --blue: #67513b;
  --good: #4f6f47;
  --bad: #9b4135;
  --warn: #8a5a20;
  --shadow: 0 18px 44px rgba(58, 44, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", Times, serif;
}

button,
input,
textarea,
pre {
  font: inherit;
}

button {
  border-radius: 8px;
}

.essay-shell {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.essay-section,
.proof-section,
.verification-section,
.examples-section {
  margin-top: 34px;
}

.essay-section {
  margin-top: 0;
}

.essay-editor,
.dafny-editor {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
}

.essay-editor {
  min-height: 220px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.72;
}

.essay-editor p {
  margin: 0 0 1.15em;
}

.essay-editor .essay-section-label {
  margin: 1.35em 0 0.45em;
}

.essay-editor ul {
  margin: 0 0 1.15em 1.35em;
  padding: 0;
}

.essay-editor li {
  margin: 0 0 0.34em;
  padding-left: 0.12em;
}

.essay-editor:focus {
  outline: none;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-bottom: 10px;
}

.section-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 11px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  border-color: #b6a68f;
  background: #fbf4e9;
}

.text-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.code-bubble {
  position: relative;
  overflow: hidden;
  border: 1px solid #41382d;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-ink);
  box-shadow: var(--shadow);
}

.contract-preview,
.code-fold-toggle,
.dafny-editor,
.details-block pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.56;
  tab-size: 2;
}

.contract-preview {
  min-height: 128px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  white-space: pre-wrap;
}

.code-fold-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 18px;
  border: 1px solid rgba(238, 244, 251, 0.22);
  border-radius: 999px;
  margin: 0 1px;
  padding: 0 7px 2px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  vertical-align: 1px;
}

.code-fold-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.code-bubble.is-busy .code-fold-toggle {
  cursor: wait;
  opacity: 0.64;
}

.dafny-editor {
  min-height: 480px;
  padding: 16px;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-ink);
}

.dafny-editor.is-hidden,
.contract-preview.is-hidden {
  display: none;
}

.tool-status {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-card {
  border: 1px solid var(--line);
  border-left: 4px solid #c6b8a4;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--paper);
  box-shadow: none;
}

.status-card.success {
  border-left-color: var(--good);
}

.status-card.failure {
  border-left-color: var(--bad);
}

.status-card.warning {
  border-left-color: var(--warn);
}

.status-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.details-block {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.details-block[hidden] {
  display: none;
}

.details-block summary {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

.details-block pre {
  max-height: 360px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  border-top: 1px solid var(--line);
  color: var(--code-ink);
  background: var(--code-bg);
}

.message-list,
.test-cases-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.case-bubble {
  flex: 0 1 275px;
  min-width: 0;
  max-width: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--paper);
  box-shadow: 0 8px 18px rgba(58, 44, 28, 0.05);
}

.case-bubble.pass {
  border-color: rgba(79, 111, 71, 0.3);
  background: #edf2e8;
  color: #3e5d37;
}

.case-bubble.fail {
  border-color: rgba(155, 65, 53, 0.3);
  background: #f8e9e5;
  color: #7f342b;
}

.case-bubble.pending {
  background: #f1eadf;
  color: var(--muted);
}

.case-line {
  max-width: 100%;
  display: grid;
  gap: 3px;
  margin: 0;
}

.case-example {
  min-width: 0;
  overflow: visible;
  white-space: normal;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.45;
}

.case-arrow,
.case-output {
  margin: 0;
  color: currentColor;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  font-weight: 650;
}

.case-output {
  overflow: visible;
  white-space: normal;
}

.case-bubble.fail {
  border-radius: 8px;
}

.case-bubble.fail .case-line {
  gap: 6px;
}

.case-expected {
  margin: 3px 0 0;
  color: currentColor;
  font-size: 11px;
  opacity: 0.7;
}

@media (max-width: 720px) {
  .essay-shell {
    width: min(100% - 22px, 880px);
    padding-top: 30px;
  }

  .section-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .text-button {
    width: 100%;
  }

  .text-button {
    flex: 1;
  }

  .test-cases-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .case-bubble {
    border-radius: 8px;
  }
}
