:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #20252b;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #ffffff 0, #f6f7f9 340px);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #14736d;
  border-radius: 6px;
  padding: 0 14px;
  background: #14736d;
  color: #ffffff;
  cursor: pointer;
}

button:hover {
  background: #0f5f5a;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row button {
  border-color: #c7d0da;
  background: #ffffff;
  color: #20252b;
}

.button-row button:hover {
  background: #edf4f2;
  border-color: #93b8b2;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand h1,
.panel h2 {
  margin: 0;
  color: #1b2026;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 30px;
}

.brand h1 a {
  color: inherit;
  text-decoration: none;
}

.brand h1 a:hover {
  color: #14736d;
}

.brand h1 a:focus-visible {
  outline: 2px solid #14736d;
  outline-offset: 3px;
}

.brand p,
.panel-header p {
  margin: 5px 0 0;
  color: #59636f;
  line-height: 1.45;
}

.brand p a {
  color: inherit;
  text-decoration-color: #aeb8c2;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.brand p a:hover {
  color: #3f4b57;
  text-decoration-color: #7f8b96;
}

.brand p a:focus-visible {
  outline: 2px solid #93b8b2;
  outline-offset: 2px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 18px);
  grid-template-rows: repeat(2, 18px);
  flex: 0 0 auto;
  gap: 4px;
  padding: 8px;
  border: 1px solid #c8d2dc;
  border-radius: 6px;
  background: #ffffff;
}

.brand-mark span {
  display: block;
  border-radius: 3px;
}

.brand-mark span:nth-child(1) {
  background: #14736d;
}

.brand-mark span:nth-child(2) {
  background: #d29026;
}

.brand-mark span:nth-child(3) {
  background: #536878;
}

.brand-mark span:nth-child(4) {
  background: #7f4f24;
}

.runtime-status {
  align-self: center;
  min-width: 138px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: #59636f;
  text-align: center;
}

.runtime-status[data-state="ready"] {
  border-color: #9bc6bc;
  color: #14736d;
}

.runtime-status[data-state="error"] {
  border-color: #e7a6a1;
  color: #b42318;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.25fr);
  gap: 16px;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 36px;
}

.source-column {
  display: grid;
  align-self: start;
  min-width: 0;
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid #d7dde5;
  border-radius: 6px;
  padding: 18px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(26, 35, 44, 0.04);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 20px;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 16px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  padding: 4px;
  background: #f3f6f8;
}

.source-tab {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: #3d4650;
}

.source-tab:hover {
  background: #e7eef1;
}

.source-tab[aria-pressed="true"] {
  border-color: #9bc6bc;
  background: #ffffff;
  color: #14736d;
  box-shadow: 0 1px 1px rgba(26, 35, 44, 0.05);
}

.source-mode {
  display: none;
}

html[data-source="generate"] .generate-mode,
html[data-source="parse"] .parse-mode {
  display: block;
}

html[data-source="parse"] #generate-button {
  display: none;
}

html[data-source="parse"] .version-panel {
  display: none;
}

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

.parser-grid {
  grid-template-columns: minmax(0, 1fr) 160px;
}

.parser-input {
  min-width: 0;
}

.version-control {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
}

.control-set {
  display: none;
}

html[data-version="3"] .name-controls,
html[data-version="5"] .name-controls,
html[data-version="2"] .dce-controls {
  display: contents;
}

.control {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: #3d4650;
  font-size: 14px;
}

.control span {
  font-weight: 600;
}

.control input,
.control select {
  width: 100%;
  min-height: 38px;
  min-width: 0;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  padding: 7px 10px;
  background: #ffffff;
  color: #20252b;
}

.control input:focus,
.control select:focus {
  outline: 2px solid #91c7bd;
  outline-offset: 1px;
  border-color: #14736d;
}

.namespace-control {
  grid-column: 1 / -1;
}

#namespace-input {
  display: none;
}

html[data-namespace="custom"] #namespace-input {
  display: block;
}

.panel-error {
  min-height: 22px;
  margin: 10px 0 0;
  color: #b42318;
  overflow-wrap: anywhere;
}

.output-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  border-top: 1px solid #e5e9ef;
  padding-top: 14px;
}

.output-line button {
  border-color: #c7d0da;
  background: #ffffff;
  color: #20252b;
}

.output-line button:hover {
  background: #edf4f2;
  border-color: #93b8b2;
}

.output-text {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.output-text span {
  color: #59636f;
  font-size: 13px;
  font-weight: 600;
}

code {
  font-family:
    "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  min-width: 0;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border: 1px solid #e0e5ec;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfcfd;
}

.field-row[hidden] {
  display: none;
}

.field-row.wide {
  grid-column: 1 / -1;
}

.field-row span {
  color: #59636f;
  font-size: 13px;
  font-weight: 600;
}

.field-row code[data-field-state="empty"] {
  color: #8a949f;
}

.version-panel {
  padding-top: 16px;
}

.version-panel .panel-header {
  margin-bottom: 10px;
}

.version-detail-text {
  margin: 0;
  color: #20252b;
  line-height: 1.5;
}

.layout-visual {
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-gutter: stable;
}

.layout-track {
  display: none;
  width: 100%;
  min-height: 42px;
  min-width: 440px;
  overflow: hidden;
  border: 1px solid #ccd4de;
  border-radius: 6px;
  background: #ffffff;
}

html[data-version="1"] .layout-v1,
html[data-version="2"] .layout-v2,
html[data-version="3"] .layout-v3,
html[data-version="4"] .layout-v4,
html[data-version="5"] .layout-v5,
html[data-version="6"] .layout-v6,
html[data-version="7"] .layout-v7,
html[data-version="8"] .layout-v8 {
  display: grid;
}

.layout-v1,
.layout-v2 {
  grid-template-columns:
    minmax(86px, 32fr)
    minmax(74px, 16fr)
    minmax(88px, 16fr)
    minmax(56px, 16fr)
    minmax(108px, 48fr);
}

.layout-v3,
.layout-v4,
.layout-v5,
.layout-v6,
.layout-v7,
.layout-v8 {
  grid-template-columns:
    minmax(116px, 48fr)
    minmax(40px, 4fr)
    minmax(72px, 12fr)
    minmax(38px, 2fr)
    minmax(132px, 62fr);
}

.layout-track span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.8);
  padding: 0 5px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout-track span:first-child {
  border-left: 0;
}

.layout-time,
.layout-time-mid {
  background: #14736d;
}

.layout-version {
  background: #536878;
}

.layout-variant {
  background: #7f4f24;
}

.layout-random {
  background: #d29026;
}

.layout-node {
  background: #47637c;
}

.layout-sequence {
  background: #7b5aa6;
}

.layout-local {
  background: #a4515f;
}

.layout-hash {
  background: #4b6f44;
}

.layout-custom {
  background: #6e6259;
}

.panel[data-state="ok"] .panel-header p {
  color: #14736d;
}

.panel[data-state="error"] {
  border-color: #e7a6a1;
}

.panel[data-state="error"] .panel-header p {
  color: #b42318;
}

@media (max-width: 920px) {
  .app-header,
  .workspace {
    width: min(100% - 24px, 720px);
  }

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

}

@media (max-width: 640px) {
  .app-header {
    grid-template-columns: 1fr;
    padding-top: 18px;
  }

  .runtime-status {
    justify-self: stretch;
  }

  .brand {
    align-items: flex-start;
  }

  .brand h1 {
    font-size: 25px;
  }

  .workspace {
    width: min(100% - 20px, 720px);
    gap: 12px;
  }

  .panel {
    padding: 14px;
  }

  .panel-header,
  .output-line {
    grid-template-columns: 1fr;
  }

  .panel-header {
    display: grid;
  }

  .panel-header button,
  .button-row button,
  #copy-active-button {
    width: 100%;
  }

  .control-grid,
  .parser-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 4px;
  }

  .layout-track span {
    padding: 0 3px;
    font-size: 10px;
  }
}
