:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #ccd6e2;
  --border-strong: #9fb0c3;
  --text: #172033;
  --muted: #627084;
  --blue: #1f6fb2;
  --blue-soft: #e7f1fb;
  --green: #18824f;
  --red: #b91c1c;
  --amber: #b87900;
  --code-bg: #fbfcfe;
  --shadow: 0 16px 42px rgba(26, 40, 58, 0.10);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--border-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

button[data-copied="true"] {
  border-color: var(--green);
  color: var(--green);
}

button:focus-visible,
select:focus-visible,
.editor-input:focus-visible {
  outline: 3px solid rgba(31, 111, 178, 0.22);
  outline-offset: 2px;
}

button[data-active="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #174f83;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

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

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

select {
  min-height: 36px;
  max-width: 210px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 0 34px 0 12px;
}

.segment {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segment button {
  border: 0;
  border-radius: 0;
  min-width: 74px;
}

.segment button + button {
  border-left: 1px solid var(--border);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 0.42fr) minmax(520px, 0.58fr);
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.editor-pane,
.preview-pane {
  position: relative;
  min-width: 0;
  min-height: calc(100vh - 106px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.pane-header h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1;
}

.pane-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.preview-header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.mini-actions {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.mini-actions button {
  min-width: 34px;
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 0;
  font-size: 13px;
}

.mini-actions button + button {
  border-left: 1px solid var(--border);
}

.editor-frame {
  --editor-gutter: 52px;
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--code-bg);
}

.editor-gutter {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: var(--editor-gutter);
  overflow: hidden;
  border-right: 1px solid #e2e8f0;
  background: #f4f7fb;
}

.editor-line-numbers {
  margin: 0;
  padding: 16px 10px 16px 4px;
  min-height: 100%;
  color: #8a98aa;
  text-align: right;
  user-select: none;
  white-space: pre;
  tab-size: 2;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.editor-highlight,
.editor-input {
  position: absolute;
  inset: 0 0 0 var(--editor-gutter);
  margin: 0;
  padding: 16px;
  border: 0;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.editor-highlight {
  color: #243145;
  pointer-events: none;
}

.editor-input {
  z-index: 1;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #101827;
  -webkit-text-fill-color: transparent;
}

.editor-input::selection {
  background: rgba(31, 111, 178, 0.24);
}

.wm-keyword {
  color: #1f6fb2;
  font-weight: 800;
}

.wm-coordinate,
.wm-number {
  color: #b87900;
}

.wm-operator {
  color: #7c3aed;
  font-weight: 800;
}

.wm-comment {
  color: #738197;
  font-style: italic;
}

.wm-name {
  color: #18824f;
}

.preview-output {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #ffffff;
}

.preview-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 100%;
}

.preview-output[data-zoom="custom"] .preview-stage {
  justify-content: flex-start;
}

.preview-output svg {
  flex: 0 0 auto;
  width: min(100%, 1120px);
  height: auto;
  margin: 0 auto;
}

.preview-output svg [data-wardley-component-id],
.preview-output svg [data-wardley-link-id],
.preview-output svg [data-wardley-marker-id],
.preview-output svg [data-wardley-callout-id] {
  transition: opacity 120ms ease;
}

.preview-output svg .wardley-map-context-layer {
  pointer-events: none;
  transition: opacity 120ms ease;
}

.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"] .wardley-callout-trigger-layer {
  cursor: help;
}

.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"] .wardley-callout-trigger-layer path,
.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"] .wardley-callout-trigger-layer line {
  pointer-events: none;
}

.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"] .wardley-callout-trigger {
  pointer-events: all;
}

.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"] .wardley-callout-body {
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"]:hover .wardley-callout-body,
.preview-output svg[data-wardley-annotation-mode="hover"] [data-wardley-callout-kind="annotation"].wardley-focus-visible .wardley-callout-body {
  opacity: 1;
  pointer-events: auto;
}

.preview-output svg[data-wardley-focus-active="true"] [data-wardley-component-id],
.preview-output svg[data-wardley-focus-active="true"] [data-wardley-link-id],
.preview-output svg[data-wardley-focus-active="true"] [data-wardley-marker-id],
.preview-output svg[data-wardley-focus-active="true"] [data-wardley-callout-id] {
  opacity: 0.08 !important;
}

.preview-output svg[data-wardley-focus-active="true"] .wardley-map-context-layer {
  opacity: 0.035 !important;
}

.preview-output svg[data-wardley-focus-active="true"] .wardley-focus-visible {
  opacity: 1 !important;
}

.preview-output svg[data-wardley-focus-active="true"] .wardley-focus-visible .wardley-link {
  stroke: #111827 !important;
  stroke-width: 3px !important;
  opacity: 1 !important;
}

.preview-output svg[data-wardley-focus-active="true"] .wardley-focus-visible text {
  fill-opacity: 1 !important;
}

.focus-paths {
  flex: 0 0 auto;
  width: 100%;
  max-height: 180px;
  overflow: auto;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.98);
  pointer-events: auto;
}

.focus-paths[hidden] {
  display: none;
}

.focus-paths-kicker {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.focus-paths-title {
  margin-top: 5px;
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.18;
}

.focus-paths-meta,
.focus-paths-more,
.focus-path-group p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.focus-path-group {
  margin-top: 8px;
}

.focus-path-group strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 12px;
  line-height: 1;
}

.focus-path {
  margin-top: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.focus-path-node {
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.focus-path-arrow {
  color: var(--blue);
  margin: 0 3px;
  font-size: 12px;
  font-weight: 900;
}

.preview-pane[data-fullscreen="true"] {
  position: fixed;
  inset: 12px;
  z-index: 20;
  min-height: 0;
  border-radius: 8px;
}

.preview-pane[data-fullscreen="true"] .preview-output {
  min-height: 0;
}

.preview-pane[data-fullscreen="true"] .diagnostics {
  display: none;
}

.diagnostics {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  min-height: 44px;
  max-height: 164px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  background: var(--surface-2);
}

.diagnostics strong {
  color: var(--text);
}

.diagnostics[data-state="ok"] {
  color: var(--green);
}

.diagnostics[data-state="error"] {
  color: var(--red);
}

.diagnostics ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.diagnostics li + li {
  margin-top: 3px;
}

.diagnostic-jump {
  min-height: 0;
  margin: 0 8px 0 0;
  border-color: #bfd0e3;
  border-radius: 5px;
  background: #edf5ff;
  color: #174f83;
  padding: 1px 6px 2px;
  font-size: 12px;
  line-height: 1.35;
}

.diagnostic-jump:hover {
  border-color: var(--blue);
}

.diagnostics-more {
  margin: 8px 0 0;
  color: var(--amber);
  font-weight: 700;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  select {
    max-width: min(100%, 260px);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-pane,
  .preview-pane {
    min-height: 520px;
  }
}
