:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --border: #cfd5dd;
  --border-strong: #aeb7c2;
  --text: #20242a;
  --muted: #66707c;
  --accent: #2e4f75;
  --accent-soft: #e8eef5;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.7), transparent 38%),
    linear-gradient(180deg, #f5f6f8, #eceff3);
}

a {
  color: var(--accent);
}

a:hover {
  color: #223c59;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button,
input,
select {
  min-height: 2.2rem;
  padding: 0.42rem 0.62rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff, #f2f4f7);
}

button:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffffff, #edf1f5);
}

button:disabled,
input:disabled,
select:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

input[type="checkbox"] {
  min-height: auto;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border-radius: 4px;
}

input[type="range"] {
  padding: 0;
}

.page-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.masthead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text);
}

.brand-link img {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.window {
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.window-title {
  padding: 0.78rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #334155;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--border);
}

.window-body {
  padding: 1rem;
}

.plain-section {
  margin-bottom: 18px;
}

.plain-section-copy {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.intro-block h1,
.window-body h1 {
  margin: 0 0 10px;
  font-size: 2rem;
  line-height: 1.1;
  font-family: Georgia, "Times New Roman", serif;
}

.window-body h2,
.window-body h3 {
  margin: 0 0 8px;
  line-height: 1.25;
  font-family: Georgia, "Times New Roman", serif;
}

.window-body p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.crumb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.94rem;
  color: var(--muted);
}

.definition-block {
  display: grid;
  gap: 8px;
}

.equation-box {
  margin-top: 8px;
  padding: 10px 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.step-list-plain {
  margin: 0;
  padding-left: 1.2rem;
}

.step-item {
  margin: 0 0 14px;
}

.clause-editor-card {
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 16px;
}

.pane {
  min-width: 0;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.control-grid label,
.control-grid .inline-note {
  display: grid;
  gap: 6px;
  align-content: start;
  font-size: 0.9rem;
}

.control-grid span,
.control-grid .inline-note {
  font-weight: 600;
}

.button-compact {
  justify-self: start;
  align-self: end;
  min-height: 1.9rem;
  padding: 0.24rem 0.5rem;
  font-size: 0.84rem;
}

.graph-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fcfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.graph-edge {
  stroke: #9aa4b0;
  stroke-width: 1.6;
}

.graph-node {
  cursor: move;
}

.graph-node-circle {
  stroke: #1f2937;
  stroke-width: 1.1;
}

.graph-node-label {
  fill: #f8fafc;
  font-size: 0.82rem;
  font-weight: 700;
}

.matrix-wrap,
.formula-editor {
  overflow: auto;
}

.matrix-table,
.problem-table,
.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.matrix-table th,
.matrix-table td,
.problem-table th,
.problem-table td,
.mini-table th,
.mini-table td {
  padding: 7px 8px;
  border: 1px solid var(--border);
  vertical-align: top;
}

.matrix-table th,
.problem-table th,
.mini-table th {
  background: #f2f4f7;
  text-align: left;
}

.matrix-table td,
.problem-table td {
  background: #fff;
}

.matrix-table td {
  text-align: center;
}

.matrix-diagonal {
  color: var(--muted);
  font-family: "Courier New", Courier, monospace;
}

.table-note,
.field-note,
.result-note,
.preview-text,
.range-field small {
  color: var(--muted);
}

.formula-editor {
  display: grid;
  gap: 10px;
}

.clause-editor-head,
.legend-head,
.mapping-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.literal-row,
.mapping-output,
.legend-values {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.literal-editor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.negation-toggle {
  min-width: 3.2rem;
}

.negation-toggle-active {
  background: var(--accent-soft);
  border-color: #9eb0c4;
}

.action-strip {
  display: grid;
  gap: 12px;
}

.status-line {
  margin: 0;
  font-size: 0.93rem;
}

.graph-limit-note {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.results-grid,
.detail-grid,
.legend-list,
.mapping-list {
  display: grid;
  gap: 12px;
}

.results-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-grid,
.legend-list,
.mapping-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.result-block,
.detail-block,
.legend-item,
.mapping-block {
  min-width: 0;
}

.result-block h3,
.detail-block h3,
.legend-item h3,
.mapping-block h3 {
  margin: 0 0 8px;
}

.result-block,
.detail-block,
.legend-item,
.mapping-block {
  padding-top: 2px;
}

.mini-table th {
  width: 42%;
}

.formula-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.clause,
.literal,
.token-chip,
.empty-formula {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.92rem;
}

.logic-join {
  margin: 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.logic-join-strong {
  font-weight: 700;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border: 1px solid #1f2937;
  display: inline-block;
  border-radius: 999px;
}

.token-chip {
  padding: 4px 7px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.preview-line {
  margin-top: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

.mapping-row {
  margin-top: 10px;
  flex-direction: column;
  align-items: flex-start;
}

.landscape-wrap {
  overflow: auto;
}

.landscape-svg {
  width: 100%;
  min-width: 720px;
  height: auto;
  color: #8a94a2;
}

.landscape-edge {
  stroke: currentColor;
  stroke-width: 1.8;
}

.landscape-node {
  fill: #fff;
  stroke: var(--border-strong);
  stroke-width: 1.2;
}

.landscape-label {
  font-size: 0.78rem;
  font-weight: 700;
  fill: #334155;
}

@media (max-width: 980px) {
  .split-layout,
  .results-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }
}
