:root {
  --text-color: #413e41;
  --muted-text: #6f7178;
  --link-color: #054bb0;
  --link-hover-color: #0569fa;
  --reference-color: #e0e6fa;
  --header-pill: #e9eefc;
  --warning-pill: #fff6db;
  --error-pill: #fce8e6;
  --border-color: #dbdde3;
  --surface: #ffffff;
  --body-bg: #f2f4f8;
  --button-bg: #ffffff;
  --button-hover: #f5f8ff;
  --button-text: #2f3442;
  --floating-button: #0569fa;
  --floating-button-text: #ffffff;
  --menu-surface: rgba(255, 255, 255, 0.92);
  --shadow-soft: 0 1px 1px 0 rgba(66, 66, 66, 0.08), 0 1px 3px 1px rgba(66, 66, 66, 0.16);
  --shadow-float: 0 19px 38px rgba(0, 0, 0, 0.1), 0 15px 12px rgba(0, 0, 0, 0.05);
  --chip-active: linear-gradient(135deg, #0569fa, #0d9aa5);
  --chip-active-text: #ffffff;
  --chip-idle: #ffffff;
  --chip-idle-text: #5c6272;
  --separator-color: #eeeeee;
  --caret-color: #000000;
  --line-height: 1.5;
  --output-column: minmax(180px, 29%);
}

html[data-theme="dark"] {
  --text-color: #e7ecf7;
  --muted-text: #98a1b6;
  --link-color: #8eb6ff;
  --link-hover-color: #d7e6ff;
  --reference-color: rgba(123, 161, 255, 0.16);
  --header-pill: rgba(123, 161, 255, 0.18);
  --warning-pill: rgba(255, 176, 103, 0.18);
  --error-pill: rgba(255, 110, 135, 0.18);
  --border-color: #263044;
  --surface: #111827;
  --body-bg: #0b1020;
  --button-bg: #131c2e;
  --button-hover: #19243a;
  --button-text: #e7ecf7;
  --floating-button: #3a7cff;
  --floating-button-text: #ffffff;
  --menu-surface: rgba(17, 24, 39, 0.94);
  --shadow-soft: 0 1px 1px 0 rgba(0, 0, 0, 0.2), 0 1px 3px 1px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 20px 50px rgba(0, 0, 0, 0.45);
  --chip-active: linear-gradient(135deg, #7aa2ff, #14b8a6);
  --chip-active-text: #06111f;
  --chip-idle: #161f33;
  --chip-idle-text: #b1bdd7;
  --separator-color: #263044;
  --caret-color: #ffffff;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--body-bg);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
a,
textarea {
  font: inherit;
}

button {
  appearance: none;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--link-hover-color);
  outline-offset: 2px;
}

.topbar {
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-color);
  text-decoration: none;
  font-size: 26px;
  font-weight: 700;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0569fa, #9747ff);
  color: #ffffff;
  font-size: 15px;
  letter-spacing: -0.08em;
}

.tagline {
  margin: 0;
  color: var(--muted-text);
  font-size: 0.95rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.toplinks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toplinks a,
.chip {
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--button-text);
  padding: 0.65rem 0.95rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.toplinks a:hover,
.chip:hover {
  background: var(--button-hover);
}

.theme-switcher {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--button-bg);
  box-shadow: var(--shadow-soft);
}

.theme-option {
  border: 0;
  border-radius: 999px;
  padding: 0.6rem 0.9rem;
  background: var(--chip-idle);
  color: var(--chip-idle-text);
  cursor: pointer;
}

.theme-option[aria-pressed="true"] {
  background: var(--chip-active);
  color: var(--chip-active-text);
}

.app-wrap {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto 24px;
}

.app {
  background: var(--surface);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 20px var(--output-column);
  min-height: calc(100vh - 112px);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

#editor,
#output {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 300;
  font-size: 18px;
  line-height: var(--line-height);
  color: var(--text-color);
}

.separator {
  display: flex;
  justify-content: center;
}

.separator-line {
  width: 1px;
  height: 100%;
  background: var(--separator-color);
}

#editor,
#output {
  tab-size: 4;
  overflow: auto;
  padding: 17px 7px 17px 17px;
  caret-color: var(--caret-color);
}

#editor {
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
}

.output-pane {
  display: flex;
  flex-direction: column;
}

.output-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 10px 0 0;
  text-align: right;
  color: var(--muted-text);
  font-size: 12px;
}

.output-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: auto;
}

#document-label {
  color: var(--text-color);
  font-weight: 600;
}

#output {
  padding-left: 0;
  padding-right: 10px;
}

.output-row {
  display: flex;
  justify-content: flex-end;
  min-height: calc(18px * var(--line-height));
}

.output-value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-height: calc(18px * var(--line-height));
  max-width: 100%;
  padding: 0 10px;
  border-radius: 20px;
  border: 0;
  background: transparent;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.output-row.value .output-value {
  cursor: pointer;
}

.output-row.value .output-value:hover,
.output-row.value .output-value:focus-visible {
  background: var(--reference-color);
}

.output-row.header .output-value {
  background: var(--header-pill);
  font-weight: 600;
}

.output-row.error .output-value {
  background: var(--error-pill);
  color: #b3261e;
}

html[data-theme="dark"] .output-row.error .output-value {
  color: #ff8ea0;
}

.output-row.warning .output-value {
  background: var(--warning-pill);
}

.output-row.blank .output-value {
  color: transparent;
}

#button {
  position: fixed;
  right: 15px;
  bottom: 15px;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background-color: var(--floating-button);
  color: var(--floating-button-text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-float);
}

#menu {
  visibility: hidden;
  opacity: 0;
  transform: scale(0.92) translateY(16px);
  transition: all 120ms ease;
  position: fixed;
  right: 16px;
  bottom: 77px;
  display: flex;
  flex-direction: column;
  width: 220px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--menu-surface);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

#menu.visible {
  visibility: visible;
  opacity: 1;
  transform: scale(1) translateY(0);
}

#menu .item {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  text-decoration: none;
  cursor: pointer;
}

#menu .item:last-child {
  border-bottom: 0;
}

#menu .item:hover,
#menu .item:focus-visible {
  background: var(--reference-color);
}

.documentation-modal {
  width: min(820px, calc(100% - 20px));
  max-height: min(84vh, 900px);
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-color);
  box-shadow: var(--shadow-float);
}

.documentation-modal::backdrop {
  background: rgba(8, 12, 24, 0.56);
  backdrop-filter: blur(4px);
}

.documentation-shell {
  display: flex;
  flex-direction: column;
  max-height: min(84vh, 900px);
}

.documentation-header,
.documentation-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-color);
}

.documentation-footer {
  align-items: center;
  border-top: 1px solid var(--border-color);
  border-bottom: 0;
}

.documentation-header h2 {
  margin: 4px 0 0;
  font-size: 1.5rem;
}

.documentation-kicker {
  margin: 0;
  color: var(--muted-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

.documentation-intro,
.documentation-footer p {
  margin: 8px 0 0;
  color: var(--muted-text);
}

.documentation-body {
  overflow: auto;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.documentation-body section {
  padding: 18px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 92%, var(--reference-color) 8%);
}

.documentation-body h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.documentation-body p,
.documentation-body ul {
  margin: 0;
  color: var(--muted-text);
}

.documentation-body ul {
  padding-left: 18px;
}

.documentation-body li + li {
  margin-top: 8px;
}

.documentation-body code,
.documentation-body pre {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.documentation-body code {
  font-size: 0.95em;
}

.documentation-body pre {
  margin: 12px 0 0;
  padding: 14px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--surface) 84%, #0f172a 16%);
}

.documentation-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.documentation-links a {
  color: var(--link-color);
  text-decoration: none;
}

.documentation-links a:hover {
  color: var(--link-hover-color);
}

#notification {
  visibility: hidden;
  opacity: 0;
  transform: translateY(-18px);
  transition: all 180ms ease;
  position: fixed;
  right: 17px;
  top: 17px;
  background: #15945f;
  color: #ffffff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  padding: 10px 18px;
  box-shadow: var(--shadow-float);
}

#notification.visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

#notification.error {
  background: #d34b62;
}

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

  .topbar-right {
    justify-content: flex-start;
  }

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

  .separator {
    display: none;
  }

  .output-pane {
    border-top: 1px solid var(--border-color);
  }

  .output-topbar {
    padding-left: 18px;
  }

  #output {
    padding-left: 18px;
  }
}

@media (max-width: 720px) {
  .topbar,
  .app-wrap {
    width: calc(100% - 16px);
  }

  .theme-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .theme-option {
    flex: 1;
  }

  .toplinks {
    width: 100%;
  }

  .app {
    min-height: calc(100vh - 132px);
  }

  #editor,
  #output {
    font-size: 15px;
  }

  .documentation-header,
  .documentation-footer {
    flex-direction: column;
  }
}
