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

:root {
  color-scheme: light;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --legend-text: #424a53;
  --border: #d0d7de;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --banner-warn-bg: #fff8c5;
  --banner-warn-text: #7d4e00;
  --banner-warn-border: #bf8700;
  --banner-error-bg: #ffebe9;
  --banner-error-text: #82071e;
  --banner-error-border: #cf222e;
  --banner-info-bg: #ddf4ff;
  --banner-info-text: #0550ae;
  --banner-info-border: #0969da;
  --banner-success-bg: #dafbe1;
  --banner-success-text: #1a7f37;
  --banner-success-border: #2da44e;
  --banner-note-bg: #eaeef2;
  --banner-note-text: #59636e;
  --banner-note-border: #656d76;
  --banner-important-bg: #fbefff;
  --banner-important-text: #6639ba;
  --banner-important-border: #8250df;
  --code-bg: #eff1f3;
  --hl-blue: rgba(56, 139, 253, 0.22);
  --hl-green: rgba(46, 160, 67, 0.2);
  --hl-amber: rgba(210, 153, 34, 0.28);
  --hl-red: rgba(255, 99, 99, 0.22);
  --hl-icon-blue: #0969da;
  --hl-icon-green: #1a7f37;
  --hl-icon-amber: #bf8700;
  --hl-icon-red: #cf222e;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
    monospace;
  --control-height: calc(1rem + 1.5em + 2px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --legend-text: #c3ccd5;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --banner-warn-bg: #3d2e00;
  --banner-warn-text: #f0c040;
  --banner-warn-border: #6e5400;
  --banner-error-bg: #3d1418;
  --banner-error-text: #ff7b72;
  --banner-error-border: #8b2e34;
  --banner-info-bg: #051d4d;
  --banner-info-text: #79c0ff;
  --banner-info-border: #164b8a;
  --banner-success-bg: #033a16;
  --banner-success-text: #3fb950;
  --banner-success-border: #116329;
  --banner-note-bg: #21262d;
  --banner-note-text: #8b949e;
  --banner-note-border: #484f58;
  --banner-important-bg: #2b1941;
  --banner-important-text: #d2a8ff;
  --banner-important-border: #8957e5;
  --code-bg: #21262d;
  --hl-blue: rgba(56, 139, 253, 0.18);
  --hl-green: rgba(46, 160, 67, 0.16);
  --hl-amber: rgba(210, 153, 34, 0.22);
  --hl-red: rgba(255, 99, 99, 0.18);
  --hl-icon-blue: #58a6ff;
  --hl-icon-green: #3fb950;
  --hl-icon-amber: #e3b341;
  --hl-icon-red: #ff7b72;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header,
main,
body > footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  width: 100%;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.site-logo {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
}

.site-brand h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
}

.tagline {
  margin: 0;
  color: var(--muted);
}

.tagline code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.tagline-link {
  margin-left: 0.35rem;
  font-size: inherit;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 2rem;
}

.banner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid var(--border);
}

.banner-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.banner-icon-svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.banner-body {
  flex: 1;
  min-width: 0;
}

#mapping-banner .mapping-banner-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.mapping-banner-text {
  flex: 1;
  min-width: 12rem;
}

.mapping-banner-btn {
  flex-shrink: 0;
}

.banner-warning {
  background: var(--banner-warn-bg);
  color: var(--banner-warn-text);
  border-color: var(--banner-warn-border);
}

.banner-error {
  background: var(--banner-error-bg);
  color: var(--banner-error-text);
  border-color: var(--banner-error-border);
}

.banner-info {
  background: var(--banner-info-bg);
  color: var(--banner-info-text);
  border-color: var(--banner-info-border);
}

.banner-success {
  background: var(--banner-success-bg);
  color: var(--banner-success-text);
  border-color: var(--banner-success-border);
}

.banner-note {
  background: var(--banner-note-bg);
  color: var(--banner-note-text);
  border-color: var(--banner-note-border);
}

.banner-important {
  background: var(--banner-important-bg);
  color: var(--banner-important-text);
  border-color: var(--banner-important-border);
}

.hidden {
  display: none;
}

.mapping-version-label {
  color: var(--muted);
  font-size: inherit;
  white-space: nowrap;
}

.tooltip {
  position: fixed;
  z-index: 200;
  max-width: 16rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(31, 35, 40, 0.12);
}

:root[data-theme="dark"] .tooltip {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.tooltip:not(.is-visible) {
  visibility: hidden;
  opacity: 0;
}

.tooltip.is-visible {
  visibility: visible;
  opacity: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--control-height);
  font: inherit;
  line-height: 1.5;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-icon {
  box-sizing: border-box;
  min-height: var(--control-height);
  width: var(--control-height);
  padding: 0;
  color: var(--text);
}

.btn-icon[aria-pressed="false"] {
  color: var(--muted);
}

.btn-icon-svg {
  display: block;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

.verbose-names-icon,
.always-number-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.verbose-names-glyph,
.always-number-glyph {
  font-family: inherit;
}

.highlight-icon-swatch {
  stroke: var(--border);
  stroke-width: 0.75;
}

.highlight-icon .hl-blue {
  fill: var(--hl-icon-blue);
}

.highlight-icon .hl-green {
  fill: var(--hl-icon-green);
}

.highlight-icon .hl-amber {
  fill: var(--hl-icon-amber);
}

.highlight-icon .hl-red {
  fill: var(--hl-icon-red);
}

.btn-icon[aria-pressed="false"] .highlight-icon-swatch {
  opacity: 0.35;
}

.btn-icon[aria-pressed="false"] .syntax-icon {
  opacity: 0.45;
}

.btn-icon[aria-pressed="true"] .verbose-names-glyph-numbered {
  display: none;
}

.btn-icon[aria-pressed="false"] .verbose-names-glyph-verbose {
  display: none;
}

.btn-icon[aria-pressed="true"] .always-number-glyph-off {
  display: none;
}

.btn-icon[aria-pressed="false"] .always-number-glyph-on {
  display: none;
}

.combo-btn {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  align-self: center;
}

.combo-btn-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.combo-btn-toggle {
  padding: 0.5rem 0.625rem;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid var(--border);
}

.combo-btn-toggle:hover:not(:disabled),
.combo-btn-main:hover:not(:disabled) + .combo-btn-toggle:not(:disabled) {
  border-color: var(--accent);
}

.combo-btn-chevron {
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.combo-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  min-width: 100%;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(31, 35, 40, 0.12);
}

:root[data-theme="dark"] .combo-menu {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.combo-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.combo-menu-item:hover,
.combo-menu-item:focus-visible {
  background: var(--code-bg);
  outline: none;
}

:root[data-theme="dark"] .btn-primary {
  color: #0d1117;
}

.toolbar-spacer {
  margin-left: auto;
}

.legend {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--legend-text);
}

.legend.is-disabled {
  opacity: 0.45;
}

.legend-swatch {
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: help;
}

.legend .hl-blue {
  background: var(--hl-blue);
}

.legend .hl-green {
  background: var(--hl-green);
}

.legend .hl-amber {
  background: var(--hl-amber);
}

.legend .hl-red {
  background: var(--hl-red);
}

.panes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 400px;
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.pane-label {
  font-weight: 600;
  font-size: 0.875rem;
}

.code-editor {
  position: relative;
  flex: 1;
  min-height: 360px;
  resize: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.code-editor:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.code-editor-scroll {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: auto;
}

.line-gutter {
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 1;
  margin: 0;
  padding: 0.75rem 0.625rem 0.75rem 0.5rem;
  min-width: 2.25rem;
  text-align: right;
  user-select: none;
  white-space: pre;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.code-input-editable,
.code-output {
  flex: 1;
  min-width: 0;
  display: block;
  margin: 0;
  padding: 0.75rem;
  white-space: pre;
  overflow: visible;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: none;
  text-shadow: none;
  tab-size: 4;
}

/* Beat Prism global pre/code rules inside editors */
.code-editor pre.code-input-editable,
.code-editor pre.code-output {
  white-space: pre;
  padding: 0.75rem;
  margin: 0;
  overflow: visible;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  background: transparent;
}

.code-editor [class*="language-"],
.code-editor [class*="language-"] .token {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
}

.code-input-editable {
  cursor: text;
  outline: none;
  min-height: 100%;
  box-sizing: border-box;
}

.code-editor-readonly .code-output {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
}

.code-input-editable.is-empty::before,
.code-output.is-empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}

.code-input-editable::selection,
.code-input-editable *::selection,
.code-output::selection,
.code-output *::selection {
  background: rgba(9, 105, 218, 0.28);
}

:root[data-theme="dark"] .code-input-editable::selection,
:root[data-theme="dark"] .code-input-editable *::selection,
:root[data-theme="dark"] .code-output::selection,
:root[data-theme="dark"] .code-output *::selection {
  background: rgba(88, 166, 255, 0.35);
}

/* Prism tokens inside editors — backgrounds from step highlights remain visible */
.code-input-editable .token,
.code-output .token {
  background: transparent;
}

.code-input-editable .hl-blue,
.code-input-editable .hl-green,
.code-input-editable .hl-amber,
.code-input-editable .hl-red,
.code-output .hl-blue,
.code-output .hl-green,
.code-output .hl-amber,
.code-output .hl-red {
  border-radius: 2px;
}

.code-input-editable .hl-blue,
.code-output .hl-blue {
  background: var(--hl-blue);
}

.code-input-editable .hl-green,
.code-output .hl-green {
  background: var(--hl-green);
}

.code-input-editable .hl-amber,
.code-output .hl-amber {
  background: var(--hl-amber);
}

.code-input-editable .hl-red,
.code-output .hl-red {
  background: var(--hl-red);
}

body > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.footer-meta {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.footer-brand-icon {
  display: block;
  width: 1.625rem;
  height: 1.625rem;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

:root[data-theme="light"] .footer-brand-icon {
  background-image: url("res/icon/fi-light.svg");
}

:root[data-theme="dark"] .footer-brand-icon {
  background-image: url("res/icon/fi-dark.svg");
}

body > footer a {
  color: var(--accent);
}

.btn-link {
  display: inline;
  min-height: 0;
  font: inherit;
  font-size: inherit;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.btn-link:hover {
  color: var(--accent-hover);
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 35, 40, 0.5);
}

:root[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(31, 35, 40, 0.2);
}

:root[data-theme="dark"] .modal-panel {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 0.5rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--code-bg);
  color: var(--text);
}

.modal-hint {
  margin: 0;
  padding: 0 1.25rem 0.75rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 0 1.25rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.6;
}

.modal-body p {
  margin: 0 0 0.875rem;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-subheading {
  margin: 1rem 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.modal-example-label {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--legend-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-code {
  margin: 0 0 0.75rem;
  padding: 0.75rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
}

.modal-body code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.about-extra-content .about-extra-block {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px dashed var(--border);
}

.modal-error {
  margin: 0 1.25rem 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--banner-error-bg);
  color: var(--banner-error-text);
  font-size: 0.8125rem;
}

.mapping-editor {
  flex: 1;
  min-height: 640px;
  margin: 0 1.25rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  overflow: auto;
  resize: none;
  white-space: pre;
  tab-size: 2;
  cursor: text;
  outline: none;
}

.mapping-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.mapping-editor [class*="language-"],
.mapping-editor [class*="language-"] .token {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
}

.mapping-editor .token {
  background: transparent;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.modal-footer-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

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

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.theme-toggle-btn:hover {
  color: var(--text);
  background: var(--code-bg);
}

.theme-toggle-btn[aria-pressed="true"] {
  color: var(--text);
  background: var(--code-bg);
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.theme-icon {
  width: 1rem;
  height: 1rem;
}
