:root {
  color-scheme: light;
  --app-bg: #dfe6ee;
  --chrome: #111923;
  --chrome-2: #192431;
  --surface: #fbfcfe;
  --surface-2: #f3f6f9;
  --surface-3: #ebf0f5;
  --line: #cad5e1;
  --line-strong: #9dabb9;
  --text: #14202c;
  --muted: #5d6e80;
  --muted-2: #8290a1;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e0f1ef;
  --danger: #b72e24;
  --danger-soft: #fff1ef;
  --warning: #996208;
  --warning-soft: #fff3d6;
  --ok: #147447;
  --ok-soft: #e5f4ec;
  --editor-bg: #121a24;
  --editor-bg-2: #0e151e;
  --editor-gutter: #182331;
  --editor-line: #2b3948;
  --editor-text: #d9e2ec;
  --editor-muted: #75879a;
  --editor-selection: rgba(46, 168, 161, 0.28);
  --editor-font-size: 13.5px;
  --editor-line-height: 20px;
  --shadow: 0 18px 48px rgba(15, 23, 32, 0.14);
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: "IBM Plex Sans", "Inter", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 123, 120, 0.10);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button.is-loading {
  opacity: 1;
}

button.is-loading .icon {
  animation: spin 850ms linear infinite;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(24, 33, 44, 0.96), rgba(34, 48, 59, 0.94)),
    var(--chrome);
}

.login-panel {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: #fbfcfd;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.login-brand,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand {
  margin-bottom: 24px;
}

.brand-emblem {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(23, 123, 120, 0.32);
  border-radius: 9px;
  background: linear-gradient(180deg, #eaf7f5, #d8ecea);
  color: var(--accent-strong);
}

.brand-emblem.small {
  width: 34px;
  height: 34px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #7ed6ce;
}

.brand-emblem .icon {
  width: 22px;
  height: 22px;
}

.product-mark {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0;
}

.product-submark {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  color: #4d5c6c;
  font-size: 13px;
  font-weight: 620;
}

input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 123, 120, 0.12);
}

.form-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidebar workspace";
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--chrome);
  color: #f5f8fb;
}

.product-title {
  font-size: 17px;
  font-weight: 760;
}

.user-line,
.active-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.topbar .user-line {
  color: #aab6c3;
}

.topbar-actions,
.editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f5f8fb;
}

.topbar button:hover:not(:disabled) {
  border-color: rgba(126, 214, 206, 0.75);
  background: rgba(126, 214, 206, 0.12);
  box-shadow: none;
}

.families-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.families-status.ok {
  border-color: #b8dcc7;
  background: var(--ok-soft);
  color: var(--ok);
}

.families-status.error {
  border-color: #efb4ad;
  background: var(--danger-soft);
  color: var(--danger);
}

.sidebar {
  grid-area: sidebar;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #f9fbfd;
  overflow: auto;
}

.sidebar-title {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: #526174;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-title .icon {
  color: var(--accent);
}

.list-nav {
  padding: 10px 8px 16px;
}

.list-item {
  position: relative;
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  margin-bottom: 4px;
  padding: 6px 10px;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.list-item:hover:not(:disabled) {
  background: #eef3f7;
  border-color: #dbe4ed;
  box-shadow: none;
}

.list-item.active {
  border-color: #b9d8d4;
  background: var(--accent-soft);
  color: #0d4f4d;
}

.list-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d7e1ea;
  border-radius: 7px;
  background: var(--surface);
  color: #4f6578;
}

.list-item.active .list-icon {
  border-color: #9bcac5;
  background: #d6ece9;
  color: var(--accent-strong);
}

.list-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.list-title,
.list-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-title {
  font-weight: 680;
}

.list-meta {
  color: var(--muted-2);
  font-size: 11px;
  text-transform: uppercase;
}

.list-item.dirty::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.workspace {
  grid-area: workspace;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 210px;
  min-width: 0;
  min-height: 0;
  background: linear-gradient(180deg, #e3eaf1 0%, var(--app-bg) 220px);
}

.editor-band {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  padding: 18px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

h1,
h2 {
  margin: 0;
  font-weight: 750;
  letter-spacing: 0;
}

h1 {
  font-size: 23px;
  color: #101926;
}

h2 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: #566679;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.signature-help {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  align-items: start;
  gap: 14px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid #d3dde7;
  border-radius: 9px;
  background: #f9fbfd;
  box-shadow: 0 1px 0 rgba(18, 27, 37, 0.03);
}

.signature-overview,
.example-list {
  min-width: 0;
}

.signature-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent-strong);
}

.signature-title-row h2 {
  margin: 0;
}

.signature-help p {
  margin: 0;
  color: #536477;
  line-height: 1.42;
}

.signature-format {
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid #d5e0ea;
  border-radius: 7px;
  background: #eef3f7;
  color: #223142;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 520;
  white-space: pre-wrap;
}

.example-list {
  display: grid;
  align-content: start;
  gap: 7px;
}

.example-button {
  width: 100%;
  min-height: 34px;
  height: auto;
  justify-content: flex-start;
  padding: 7px 10px;
  overflow: hidden;
  border-color: #d5e0ea;
  background: #eef3f7;
  color: #243143;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 520;
  text-align: left;
}

.example-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-button .icon {
  color: var(--accent);
}

.example-button:hover {
  background: #eef7f5;
}

.editor-wrap {
  --gutter-width: 58px;
  --editor-pad-x: 16px;
  --editor-pad-y: 14px;
  --editor-border-width: 1px;
  position: relative;
  min-height: 320px;
  height: 100%;
  border: 1px solid #536477;
  border-radius: 10px;
  background: var(--editor-bg);
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(16, 24, 34, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.editor {
  position: absolute;
  z-index: 3;
  inset: 0 0 0 var(--gutter-width);
  width: calc(100% - var(--gutter-width));
  height: 100%;
  min-height: 320px;
  resize: none;
  padding: var(--editor-pad-y) var(--editor-pad-x);
  border: 0;
  border-left: var(--editor-border-width) solid var(--editor-line);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: #63d6cc;
  font-family: var(--mono);
  font-size: var(--editor-font-size);
  font-weight: 500;
  line-height: var(--editor-line-height);
  overflow: auto;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  -webkit-text-fill-color: transparent;
}

.editor:focus {
  box-shadow: inset 3px 0 0 rgba(99, 214, 204, 0.35);
}

.editor::selection {
  background: var(--editor-selection);
  -webkit-text-fill-color: transparent;
}

.editor-wrap:focus-within {
  border-color: #2ea8a1;
  box-shadow: 0 0 0 3px rgba(46, 168, 161, 0.18), 0 16px 36px rgba(16, 24, 34, 0.18);
}

.editor-wrap.has-errors {
  border-color: #f0645a;
  box-shadow: 0 0 0 3px rgba(240, 100, 90, 0.22), 0 16px 36px rgba(16, 24, 34, 0.18);
}

.editor-wrap.has-errors::after {
  content: attr(data-error-count);
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 12px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 176, 169, 0.52);
  border-radius: 999px;
  background: rgba(91, 32, 32, 0.92);
  color: #ffd6d1;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.line-numbers {
  position: absolute;
  inset: var(--editor-pad-y) auto 0 0;
  width: var(--gutter-width);
  height: auto;
  min-height: 320px;
  padding: 0;
  overflow: hidden;
  background: var(--editor-gutter);
  color: var(--editor-muted);
  font-family: var(--mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  text-align: right;
  white-space: pre;
  user-select: none;
}

#lineNumbersInner,
#editorHighlightsInner {
  will-change: transform;
}

.line-number {
  position: relative;
  height: var(--editor-line-height);
  min-height: var(--editor-line-height);
  padding-right: 11px;
  border-right: 3px solid transparent;
}

.line-number.error {
  border-right-color: #ff766d;
  background: linear-gradient(90deg, rgba(255, 118, 109, 0.18), rgba(183, 46, 36, 0.34));
  color: #ffd2cd;
  font-weight: 750;
}

.line-number.error::before {
  content: "!";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ff766d;
  color: #241013;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 850;
  transform: translateY(-50%);
}

.editor-highlights {
  position: absolute;
  z-index: 1;
  inset: var(--editor-pad-y) 0 0 var(--gutter-width);
  height: auto;
  min-height: 320px;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

.editor-syntax {
  position: absolute;
  z-index: 2;
  inset: var(--editor-pad-y) var(--editor-pad-x) 0 calc(var(--gutter-width) + var(--editor-border-width) + var(--editor-pad-x));
  height: auto;
  min-height: 320px;
  padding: 0;
  overflow: hidden;
  border-left: 0;
  color: var(--editor-text);
  font-family: var(--mono);
  font-size: var(--editor-font-size);
  font-weight: 500;
  line-height: var(--editor-line-height);
  pointer-events: none;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

#editorSyntaxInner {
  width: max-content;
  min-width: 100%;
  will-change: transform;
}

.syntax-line {
  height: var(--editor-line-height);
  min-height: var(--editor-line-height);
  white-space: pre;
}

.syntax-delimiter {
  color: #607083;
}

.syntax-hash {
  color: #8ecbff;
}

.syntax-hash-alt {
  color: #75e3cf;
}

.syntax-size,
.syntax-score {
  color: #f1ca7a;
}

.syntax-type,
.syntax-keyword {
  color: #ff9f70;
}

.syntax-family,
.syntax-name {
  color: #8ce99a;
}

.syntax-initials {
  color: #c6a6ff;
}

.syntax-code,
.syntax-category {
  color: #65d6d0;
}

.syntax-identifier {
  color: #9dbbff;
}

.syntax-path,
.syntax-string,
.syntax-indicator {
  color: #e8d98b;
}

.syntax-regex,
.syntax-mask,
.syntax-sections {
  color: #ff86a7;
}

.syntax-condition {
  color: #ffb86b;
}

.syntax-suffix {
  color: #b2c7d9;
}

.syntax-text {
  color: var(--editor-text);
}

.editor-highlight-line {
  height: var(--editor-line-height);
  min-height: var(--editor-line-height);
  border-left: 4px solid transparent;
}

.editor-highlight-line.error {
  border-left-color: #ff766d;
  background:
    linear-gradient(90deg, rgba(255, 118, 109, 0.34), rgba(183, 46, 36, 0.22) 38%, rgba(183, 46, 36, 0.11)),
    rgba(183, 46, 36, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 176, 169, 0.08), inset 0 -1px 0 rgba(255, 176, 169, 0.08);
}

.suggestions {
  position: fixed;
  z-index: 30;
  width: min(460px, calc(100vw - 24px));
  max-height: 304px;
  overflow: auto;
  padding: 6px;
  border: 1px solid #9cadbb;
  border-radius: 10px;
  background: #fcfdff;
  box-shadow: var(--shadow);
}

.suggestion-item {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 5px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}

.suggestion-item:hover {
  box-shadow: none;
}

.suggestion-item.active,
.suggestion-item:hover {
  background: var(--accent-soft);
  color: #0d4f4d;
}

.suggestion-value {
  min-width: 0;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 540;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-hint {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  min-height: 0;
  padding: 0 18px 18px;
}

.panel {
  min-width: 0;
  min-height: 0;
  padding: 14px;
  border: 1px solid #d3dde7;
  border-radius: 9px;
  background: #fcfdff;
  overflow: auto;
  box-shadow: 0 1px 0 rgba(18, 27, 37, 0.03);
}

.panel h2 .icon {
  color: var(--accent);
}

.diagnostic-line,
.log-line {
  padding: 7px 0;
  border-bottom: 1px solid #edf1f5;
  color: #2b3949;
}

.diagnostic-line:last-child,
.log-line:last-child {
  border-bottom: 0;
}

.diagnostic-line strong {
  color: var(--danger);
}

.log-line.ok {
  color: #196843;
}

.muted {
  color: var(--muted);
}

.ok {
  color: var(--ok);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(440px, calc(100% - 36px));
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "sidebar"
      "workspace";
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .list-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 10px;
  }

  .list-item {
    flex: 0 0 190px;
    width: 190px;
  }

  .workspace {
    grid-template-rows: minmax(0, 1fr) 250px;
  }

  .signature-help,
  .status-band {
    grid-template-columns: 1fr;
  }

  .editor-toolbar,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .families-status {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .editor-band,
  .status-band {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    padding: 12px;
  }

  .editor-actions button,
  .topbar-actions button {
    flex: 1 1 auto;
  }

  .editor-wrap {
    --gutter-width: 46px;
  }

  .editor,
  .line-numbers,
  .editor-syntax {
    font-size: 12px;
  }

  .editor {
    width: calc(100% - var(--gutter-width));
  }

  .line-numbers {
    width: var(--gutter-width);
  }

  .editor-highlights {
    left: var(--gutter-width);
  }
}
