:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181b1f;
  --panel-2: #20242a;
  --line: #303741;
  --text: #f3f5f7;
  --muted: #a5adb8;
  --accent: #3ddc97;
  --danger: #ff6b6b;
  --button: #4f7cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  align-self: start;
  padding: 18px;
  position: sticky;
  top: 16px;
}

.brand {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 6px;
}

.status {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 9px;
  white-space: nowrap;
}

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

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field span,
.toggles label {
  color: var(--muted);
  font-size: 13px;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1114;
  color: var(--text);
  font: inherit;
  padding: 10px 11px;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: #6f91ff;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

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

.simple-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.advanced {
  border: 1px solid #28303a;
  border-radius: 6px;
  margin: 2px 0 14px;
  padding: 0;
}

.advanced summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  list-style-position: inside;
  padding: 10px;
}

.advanced[open] {
  padding-bottom: 10px;
}

.advanced .grid,
.advanced .toggles {
  margin-left: 10px;
  margin-right: 10px;
}

.chain-actions {
  display: flex;
  gap: 8px;
}

.chain-actions button {
  background: #121519;
  border: 1px solid #28303a;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 6px 9px;
}

.chain-picker {
  display: grid;
  gap: 10px;
  max-height: 230px;
  overflow: auto;
  padding-right: 3px;
}

.chain-group {
  border: 1px solid #28303a;
  border-radius: 8px;
  padding: 9px;
}

.chain-group-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.chain-group-options {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chain-option {
  align-items: center;
  background: #121519;
  border: 1px solid #28303a;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 7px;
  min-width: 0;
  padding: 7px;
}

.chain-option.optional {
  border-style: dashed;
  opacity: 0.78;
}

.chain-option input {
  flex: 0 0 auto;
  width: auto;
}

.chain-option .chain-badge {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggles {
  display: grid;
  gap: 10px;
  margin: 4px 0 16px;
}

.toggles label {
  align-items: flex-start;
  background: #121519;
  border: 1px solid #28303a;
  border-radius: 6px;
  display: grid;
  gap: 7px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 9px;
}

.toggles input {
  margin-top: 2px;
  width: auto;
}

.toggles span {
  color: var(--text);
  display: grid;
  font-weight: 600;
  gap: 3px;
}

.toggles small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

.primary {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: var(--button);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 12px;
}

.primary:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary {
  width: 100%;
  border: 1px solid #344152;
  border-radius: 6px;
  background: #151a20;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px;
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

.message.error {
  color: var(--danger);
}

.variant-tool {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 12px;
}

.section-title.compact {
  border-bottom: 0;
  padding: 0 0 11px;
}

.variant-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 96px;
}

.variant-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
}

.variant-item {
  background: #101419;
  border: 1px solid #28303a;
  border-radius: 6px;
  display: grid;
  gap: 5px;
  padding: 9px;
}

.variant-item.match {
  border-color: var(--accent);
}

.variant-item code {
  white-space: normal;
  word-break: break-all;
}

.hint {
  margin: -3px 0 14px;
}

.results {
  display: grid;
  gap: 16px;
  align-content: start;
}

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

.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 26px;
  line-height: 1.1;
}

.section-title {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 13px 15px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 820px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #252b33;
  font-size: 13px;
  padding: 11px 15px;
  text-align: left;
  vertical-align: top;
}

tr.asset-row {
  cursor: pointer;
}

tr.asset-row:hover {
  background: #151a20;
}

th {
  color: var(--muted);
  font-weight: 600;
}

td code {
  color: #d6dbe3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.mini {
  align-items: center;
  background: #222a34;
  border: 1px solid #3a4452;
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.detail-row td {
  background: #121519;
  border-bottom: 1px solid #303741;
  padding: 0 15px 14px;
}

.detail-box {
  border: 1px solid #2a323d;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 12px;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h3 {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  text-transform: uppercase;
}

.detail-line {
  align-items: center;
  background: #0e1115;
  border: 1px solid #252b33;
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, auto) auto auto;
  padding: 9px;
}

.detail-line strong {
  color: var(--accent);
}

.amount-cell {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  text-align: right;
}

.chain-badge,
.asset-kind {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.chain-badge.red { background: #442028; color: #ff9da8; }
.chain-badge.blue { background: #1d2d4d; color: #9dc0ff; }
.chain-badge.gold { background: #3b3218; color: #ffd777; }
.chain-badge.purple { background: #302348; color: #d5b6ff; }
.chain-badge.orange { background: #422816; color: #ffb078; }
.chain-badge.silver { background: #2b3038; color: #d7dde6; }
.chain-badge.green { background: #17392c; color: #7ce0ad; }
.chain-badge.cyan { background: #143840; color: #83e5f2; }

.asset-kind {
  margin-left: 7px;
  padding: 4px 7px;
}

.asset-kind.native {
  background: #17392c;
  color: #7ce0ad;
}

.asset-kind.token {
  background: #2b3038;
  color: #c6ccd5;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

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

.errors {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.empty-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 14px;
}

.empty-chain {
  align-items: center;
  background: #121519;
  border: 1px solid #28303a;
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  padding: 8px;
}

.error-item {
  border: 1px solid #553338;
  border-radius: 6px;
  color: #ffd3d3;
  padding: 10px;
}

pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

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

  .controls {
    position: static;
  }

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