:root {
  color-scheme: light;
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f1e8;
  --panel: rgba(255, 252, 245, 0.92);
  --ink: #1d1d1b;
  --muted: #68655f;
  --line: #d6d0c2;
  --accent: #1c7c54;
  --failure: #a63c30;
  --warning: #9d5f13;
  --highlight-blue: #3d73ff;
  --highlight-green: #2f9d63;
  --external-target: #c35a18;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(28, 124, 84, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f6f0 0%, var(--bg) 100%);
}

main {
  width: min(1180px, calc(100vw - 32px));
  margin: 48px auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(29, 29, 27, 0.08);
}

button {
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(61, 115, 255, 0.32);
  outline-offset: 3px;
}

code,
pre,
.sequence-content {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.page-header,
.result-section-head,
.status-head,
.export-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header,
.result-section-head {
  justify-content: space-between;
  flex-wrap: wrap;
}

.page-header {
  align-items: flex-start;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 9px;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

h2,
h3,
h4,
p {
  margin: 0;
}

.intro,
.helper,
.file-name,
.result-message {
  color: var(--muted);
}

.load-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.file-name {
  max-width: 280px;
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button {
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--ink);
}

.secondary-button,
.copy-button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fcfaf3;
}

.empty-state,
.error-message {
  display: grid;
  gap: 5px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: #fffdf8;
}

.empty-state strong {
  color: var(--ink);
}

.error-message {
  margin-top: 18px;
  border-color: rgba(166, 60, 48, 0.45);
  color: var(--failure);
  background: rgba(166, 60, 48, 0.08);
}

[hidden] {
  display: none !important;
}

.result-summary {
  display: grid;
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf8;
  min-width: 0;
  overflow: hidden;
}

.result-details,
.result-section,
.result-title-block,
.result-sequence-grid,
.result-state-grid,
.result-graph-grid,
.pairing-change-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.result-details {
  gap: 22px;
}

.result-section h2 {
  font-size: 1.08rem;
}

.result-section h3 {
  font-size: 1rem;
}

.status-head {
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid rgba(28, 124, 84, 0.35);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(28, 124, 84, 0.12);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge.failed {
  border-color: rgba(166, 60, 48, 0.35);
  color: var(--failure);
  background: rgba(166, 60, 48, 0.1);
}

.export-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-metadata {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-metadata dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
}

.result-metadata dt,
.sequence-label,
.proxy-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-metadata dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.warning-list {
  margin: 0;
  padding-left: 18px;
  color: var(--warning);
}

.sequence-card,
.state-card,
.graph-card,
.pairing-change-card {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.graph-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fcfaf3;
}

.alignment-shell,
.proxy-shell {
  max-width: 100%;
  min-width: 0;
  padding: 16px 14px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfaf3;
}

.alignment-scroll,
.proxy-scroll,
.table-scroll,
.graph-preview {
  max-width: 100%;
  overflow-x: auto;
}

.alignment-content,
.proxy-content {
  display: grid;
  gap: 9px;
  width: max-content;
  min-width: 100%;
  padding-top: 20px;
  font: 0.92rem/1.6 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.sequence-line {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.sequence-row,
.index-row,
.pairing-row {
  display: flex;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.sequence-char,
.index-cell,
.pairing-cell {
  position: relative;
  display: inline-flex;
  width: 1ch;
  min-width: 1ch;
  justify-content: center;
  text-align: center;
}

.sequence-char.is-locked {
  text-decoration: underline 2px rgba(28, 124, 84, 0.95);
  text-underline-offset: 0.16em;
}

.sequence-char.is-highlight-blue {
  background: rgba(61, 115, 255, 0.16);
  box-shadow: inset 0 -2px 0 rgba(61, 115, 255, 0.46);
}

.sequence-char.is-highlight-green {
  background: rgba(47, 157, 99, 0.18);
  box-shadow: inset 0 -2px 0 rgba(47, 157, 99, 0.5);
}

.sequence-char.is-external-target {
  background: rgba(195, 90, 24, 0.18);
  box-shadow: inset 0 -2px 0 rgba(195, 90, 24, 0.58);
}

.sequence-char.is-shared-annotation {
  box-shadow: inset 0 2px 0 var(--annotation-color, rgba(29, 29, 27, 0.5));
}

.sequence-char.is-substituted {
  background: rgba(181, 137, 0, 0.16);
  box-shadow: inset 0 -2px 0 rgba(181, 137, 0, 0.45);
}

.sequence-char.is-added {
  background: rgba(28, 124, 84, 0.16);
  box-shadow: inset 0 -2px 0 rgba(28, 124, 84, 0.5);
}

.sequence-char.is-deleted {
  background: rgba(166, 60, 48, 0.16);
  box-shadow: inset 0 -2px 0 rgba(166, 60, 48, 0.5);
}

.sequence-char.is-gap {
  color: rgba(43, 47, 65, 0.34);
}

.sequence-char.has-label::before {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  z-index: 2;
  min-width: 1.8em;
  padding: 0 0.38em;
  transform: translateX(-50%);
  border-radius: 999px;
  color: #fffdf8;
  background: rgba(29, 29, 27, 0.9);
  font: 700 0.64rem/1.35 "IBM Plex Sans", "Helvetica Neue", sans-serif;
  white-space: nowrap;
  pointer-events: none;
}

.index-row {
  min-height: 1.55em;
}

.index-cell {
  height: 1.55em;
}

.index-cell.has-label::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 1px;
  height: 4px;
  background: rgba(104, 101, 95, 0.72);
}

.index-label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.pairing-track {
  display: grid;
  gap: 4px;
}

.pairing-cell {
  height: 1.45em;
  align-items: center;
  color: var(--pairing-text, #fff);
  background: var(--pairing-bg, #e8e1d1);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px rgba(29, 29, 27, 0.18);
}

.pairing-cell.unpaired {
  color: rgba(29, 29, 27, 0.62);
  font-weight: 600;
  text-shadow: none;
}

.pairing-cell.separator {
  color: white;
  background: #3b352b;
}

.pairing-cell.endpoint {
  cursor: pointer;
}

.pairing-cell.active {
  color: white;
  background: #0b5fff !important;
  text-shadow: none;
}

.pairing-summary {
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.proxy-content {
  gap: 12px;
  padding-top: 0;
}

.proxy-window {
  display: grid;
  gap: 6px;
}

.proxy-title {
  color: var(--muted);
  font: 700 0.76rem/1.35 "IBM Plex Sans", "Helvetica Neue", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.proxy-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  white-space: pre;
}

.graph-preview {
  min-height: 420px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.graph-target {
  width: 100%;
  min-height: 420px;
}

.graph-image,
.graph-svg {
  display: block;
  width: 100%;
  height: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.result-table th,
.result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.result-table th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-pass {
  color: var(--accent);
  font-weight: 700;
}

.result-fail {
  color: var(--failure);
  font-weight: 700;
}

.pairing-region-list {
  display: grid;
  gap: 3px;
}

.raw-response {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
}

.raw-response summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 600;
}

.raw-response pre {
  max-height: 520px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: #2b2f41;
  background: #fcfaf3;
  font-size: 0.82rem;
}

@media (max-width: 700px) {
  main {
    width: calc(100vw - 20px);
    margin: 20px auto;
    padding: 18px;
  }

  .page-header {
    display: grid;
  }

  .load-actions {
    justify-items: start;
  }

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

  .result-metadata dl,
  .sequence-line,
  .proxy-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
