:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f4;
  --ink: #172026;
  --muted: #5d6972;
  --line: #d8dee3;
  --accent: #176f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e4f2ed;
  --blue: #255f9f;
  --warning: #9b5b00;
  --danger: #ad2b2b;
  --danger-soft: #ffe8e8;
  --code-bg: #101418;
  --code-gutter: #1d252c;
  --code-line: #2b353e;
  --code-text: #e8edf2;
  --code-muted: #8e9ba7;
  --string: #89d185;
  --comment: #8ca0a7;
  --keyword: #72a7ff;
  --variable: #f0cf73;
  --number: #d9a8ff;
  --operator: #f28c8c;
  --function: #78dce8;
  --parameter: #ffb86b;
  --shadow: 0 14px 40px rgba(30, 39, 46, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
select,
input[type="number"] {
  min-height: 38px;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  padding: 0 14px;
}

button:hover {
  border-color: #adb8c1;
  background: #f8fafb;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 95, 159, 0.24);
  outline-offset: 2px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2.15rem);
  font-weight: 760;
}

.topbar p {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--muted);
}

.status-pill {
  flex: 0 0 auto;
  max-width: min(520px, 45vw);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 14px;
  font-size: 0.92rem;
  line-height: 1.25;
  text-align: right;
  box-shadow: var(--shadow);
}

.status-pill.is-error {
  border-color: #f2b0b0;
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.is-ok {
  border-color: #acd6c9;
  background: var(--accent-soft);
  color: var(--accent);
}

.toolbar,
.actions,
.workspace,
.status-row {
  margin-top: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow);
}

.control-group,
.field,
.check {
  min-width: 0;
}

.control-group {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 6px;
  grid-column: span 2;
}

.field span,
.control-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  text-transform: uppercase;
}

.field select,
.field input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.short-field {
  grid-column: span 1;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 2px;
}

.segment {
  min-height: 32px;
  border: 0;
  background: transparent;
  padding: 0 10px;
}

.segment.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.92rem;
  font-weight: 620;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions button {
  min-width: 112px;
}

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

.primary-button:hover {
  background: #115f4e;
  border-color: #115f4e;
}

.danger-button {
  border-color: #e8b4b4;
  color: var(--danger);
}

.danger-button:hover {
  background: var(--danger-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pane-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px 14px;
}

.pane-bar.compact {
  align-items: center;
  min-height: 50px;
}

.pane-bar h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
}

.pane-bar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric {
  flex: 0 0 auto;
  max-width: 260px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.editor-wrap {
  height: clamp(280px, 34vh, 520px);
  background: var(--code-bg);
}

.editor-wrap .CodeMirror {
  height: 100%;
  background: var(--code-bg);
  color: var(--code-text);
  font-family:
    "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.editor-wrap .CodeMirror-focused {
  outline: 3px solid rgba(37, 95, 159, 0.24);
  outline-offset: -3px;
}

.editor-wrap .CodeMirror-scroll {
  min-height: 100%;
}

.editor-wrap .CodeMirror-lines {
  padding: 14px 0;
}

.editor-wrap pre.CodeMirror-line,
.editor-wrap pre.CodeMirror-line-like {
  padding: 0 14px;
}

.editor-wrap .CodeMirror-gutters {
  border-right: 1px solid var(--code-line);
  background: var(--code-gutter);
}

.editor-wrap .CodeMirror-linenumber {
  color: var(--code-muted);
  padding: 0 10px 0 8px;
}

.editor-wrap .CodeMirror-cursor {
  border-left-color: #f4f7fa;
}

.editor-wrap .CodeMirror-selected,
.editor-wrap .CodeMirror-focused .CodeMirror-selected {
  background: rgba(73, 137, 204, 0.35);
}

.editor-wrap .CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.045);
}

.editor-wrap .CodeMirror-activeline-gutter {
  background: #24303a;
}

.cm-s-base64-tool .cm-string,
.cm-s-base64-tool .cm-string-2 {
  color: var(--string);
}

.cm-s-base64-tool .cm-comment {
  color: var(--comment);
  font-style: italic;
}

.cm-s-base64-tool .cm-keyword {
  color: var(--keyword);
  font-weight: 700;
}

.cm-s-base64-tool .cm-variable,
.cm-s-base64-tool .cm-variable-2,
.cm-s-base64-tool .cm-variable-3 {
  color: var(--variable);
}

.cm-s-base64-tool .cm-number,
.cm-s-base64-tool .cm-atom {
  color: var(--number);
}

.cm-s-base64-tool .cm-operator {
  color: var(--operator);
}

.cm-s-base64-tool .cm-def,
.cm-s-base64-tool .cm-builtin {
  color: var(--function);
}

.cm-s-base64-tool .cm-attribute,
.cm-s-base64-tool .cm-property,
.cm-s-base64-tool .cm-qualifier {
  color: var(--parameter);
}

.cm-s-base64-tool .cm-bracket,
.cm-s-base64-tool .cm-tag {
  color: #cad2da;
}

.cm-s-base64-tool .cm-error {
  color: #ffd3d3;
  background: rgba(173, 43, 43, 0.3);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .toolbar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .control-group,
  .field {
    grid-column: span 2;
  }

  .short-field {
    grid-column: span 1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    padding-top: 14px;
  }

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

  .topbar {
    display: grid;
  }

  .status-pill {
    max-width: none;
    text-align: left;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-group,
  .field,
  .short-field {
    grid-column: span 1;
  }

  .check {
    min-height: 42px;
  }

  .editor-wrap {
    height: 300px;
  }
}

@media (max-width: 560px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .control-group,
  .field,
  .short-field {
    grid-column: span 1;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions button {
    min-width: 0;
  }

  .pane-bar {
    display: grid;
    min-height: auto;
  }

  .metric {
    max-width: none;
    text-align: left;
  }

  .status-row {
    display: grid;
  }
}
