:root {
  color-scheme: light;
  --bg: #e7eaee;
  --panel: #ffffff;
  --panel-muted: #f6f7f9;
  --text: #20242a;
  --muted: #626b76;
  --border: #c9d0d8;
  --accent: #245aa5;
  --accent-hover: #173f78;
  --danger: #b42318;
  --shadow: 0 12px 28px rgba(32, 36, 42, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
select,
textarea {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

select,
button {
  min-height: 36px;
  border-radius: 6px;
}

select {
  min-width: 92px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 0 34px 0 10px;
}

.export-control {
  display: inline-flex;
  align-items: stretch;
  gap: 6px;
}

button {
  border: 1px solid var(--accent-hover);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

button:hover,
button:focus-visible {
  background: var(--accent-hover);
}

.debug-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(520px, 1.18fr);
  gap: 14px;
  height: calc(100vh - 88px);
  padding: 12px 22px 22px;
}

.pane {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-muted);
}

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

.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.badge.error {
  border-color: #fecdca;
  color: var(--danger);
}

textarea {
  display: block;
  width: 100%;
  height: calc(100% - 44px);
  border: 0;
  resize: none;
  color: #24292f;
  background: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  padding: 14px;
  outline: none;
}

.preview {
  height: calc(100% - 44px);
  overflow: auto;
  padding: 22px;
  background: #d5dae1;
}

.preview .render-sheet {
  box-shadow: 0 18px 40px rgba(32, 36, 42, 0.2);
}

.diagnostics {
  margin: 0 auto;
  max-width: 780px;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fff6f5;
  color: var(--danger);
  font: 700 14px/1.45 ui-sans-serif, system-ui, sans-serif;
  padding: 16px;
}

.debug-mode .role-block {
  outline: 1px dashed rgba(36, 90, 165, 0.55);
  outline-offset: 2px;
}

.debug-mode .role-block::before {
  content: attr(data-role);
  display: inline-block;
  margin: 0 0 4px;
  border-radius: 4px;
  background: #e8f1ff;
  color: var(--accent-hover);
  font: 700 10px/1 ui-sans-serif, system-ui, sans-serif;
  padding: 3px 5px;
}

.profile-toggle {
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 10;
  min-height: 32px;
  border-color: #4c5663;
  background: #20242a;
  box-shadow: 0 10px 24px rgba(32, 36, 42, 0.22);
  font-size: 12px;
  padding: 0 12px;
}

.profile-toggle:hover,
.profile-toggle:focus-visible {
  background: #4c5663;
}

.profile-dialog {
  width: min(920px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(32, 36, 42, 0.32);
}

.profile-dialog::backdrop {
  background: rgba(32, 36, 42, 0.38);
}

.profile-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-muted);
  padding: 8px 10px 8px 14px;
}

.profile-dialog-header h2 {
  margin: 0;
  font-size: 14px;
}

.profile-source {
  height: calc(100% - 48px);
  margin: 0;
  overflow: auto;
  background: #ffffff;
  color: #24292f;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .pane {
    height: 76vh;
  }

  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .header-actions {
    flex-wrap: wrap;
  }
}
