@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-500.woff2") format("woff2"); }

:root {
  --gray-100: #161616; --gray-90: #262626; --gray-80: #393939; --gray-70: #525252; --gray-60: #6f6f6f;
  --gray-50: #8d8d8d; --gray-30: #c6c6c6; --gray-20: #e0e0e0; --gray-10: #f4f4f4; --white: #ffffff;
  --focus: #0f62fe; --error: #da1e28;
  /* MEGA's palette. The page is light only (no dark theme); these tokens are the one place to
     retune it. The badges carry their own contrast (white on green), and the orange passes
     4.5:1 on white. */
  --mega-green: #2d5f45; --mega-green-hi: #4f8a69; --mega-green-lo: #1d4230;
  --mega-orange: #b9502a; --mega-red: #b8322a;
  --sans: "IBM Plex Sans", system-ui, sans-serif; --mono: "IBM Plex Mono", ui-monospace, monospace;
  --cell: 9px;
}
* { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; font: 14px/1.4 var(--sans); color: var(--gray-100); background: var(--white); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
a { color: inherit; }

.icon { display: inline-block; width: 16px; height: 16px; flex: none; background: currentColor; -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat; }

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

/* Window menu strip: File and Help, as MEGA keeps them in the system menu bar. */
.shell { display: flex; align-items: center; gap: 12px; height: 34px; padding: 0 8px 0 12px; background: var(--gray-10); border-bottom: 1px solid var(--gray-20); font-size: 13px; }
.brand { font-weight: 600; letter-spacing: 0.01em; }
.strip { display: flex; }
.strip .menu-button { height: 34px; padding: 0 10px; }
.engine-note { color: var(--gray-60); font-size: 12px; }
.shell-links { display: flex; gap: 16px; }
.shell-links a, .link { color: var(--gray-80); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.shell .danger { height: 26px; padding: 0 10px; font-size: 13px; }
.shell .run-status { padding: 0; }

.menu { position: relative; }
.menu-button { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 0; background: none; cursor: pointer; }
.menu-button:hover:not(:disabled), .menu-button[aria-expanded="true"] { background: var(--gray-20); }
/* Placed by ui/menus.js against the opener (fixed, so scrolling toolbars never clip it). */
.menu-list { position: fixed; top: 0; left: 0; z-index: 20; min-width: 260px; max-width: calc(100vw - 16px); overflow-y: auto; display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--gray-30); box-shadow: 0 2px 6px rgb(0 0 0 / 0.2); }

/* MEGA toolbar: twelve badges, each opening its MEGA menu. */
.toolbar { display: flex; gap: 2px; padding: 10px 8px 8px; border-bottom: 2px solid var(--mega-red); background: linear-gradient(var(--white), var(--gray-10)); overflow-x: auto; scrollbar-width: thin; }
.toolbar > .menu { flex: 1 0 calc(76 * var(--tb-unit, 1px) * var(--tb-width, 1)); max-width: calc(108 * var(--tb-unit, 1px) * var(--tb-width, 1)); }
.menu-button.badge { width: 100%; height: auto; flex-direction: column; gap: 6px; padding: 2px 2px 4px; color: var(--gray-90); }
.menu-button.badge:hover, .menu-button.badge[aria-expanded="true"] { background: none; }
.disc { display: grid; place-items: center; width: calc(56 * var(--tb-unit, 1px) * var(--tb-size, 1)); height: calc(56 * var(--tb-unit, 1px) * var(--tb-size, 1)); border-radius: 50%; color: var(--white);
  background: radial-gradient(circle at 34% 28%, var(--mega-green-hi), var(--mega-green) 58%, var(--mega-green-lo));
  box-shadow: inset 0 0 0 3px var(--mega-green), inset 0 0 0 4.5px rgb(255 255 255 / 0.75), inset 0 -4px 6px rgb(0 0 0 / 0.28), 0 2px 3px rgb(0 0 0 / 0.3); }
.disc svg { width: calc(30 * var(--tb-unit, 1px) * var(--tb-size, 1)); height: calc(30 * var(--tb-unit, 1px) * var(--tb-size, 1)); }
.badge:hover .disc { filter: brightness(1.15); }
.badge[aria-expanded="true"] .disc { box-shadow: inset 0 0 0 3px var(--mega-green), inset 0 0 0 4.5px rgb(255 255 255 / 0.75), inset 0 3px 6px rgb(0 0 0 / 0.35), 0 0 0 2px var(--white), 0 0 0 4px var(--mega-green); }
.badge-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.badge[aria-expanded="true"] .badge-label { color: var(--mega-green); }

/* Launch row: MEGA's links and settings under the main area. */
.launch { position: relative; padding: 2px 12px 4px; border-top: 1px solid var(--gray-20); background: var(--white); }
.launch-captions { display: flex; justify-content: space-between; border-bottom: 2px solid var(--mega-red); }
.caption-link { padding: 3px 0; border: 0; background: none; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.launch-row { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.launch-items { display: flex; flex-wrap: wrap; gap: 0 10px; }
.launch-item, .launch-more { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 4px; border: 0; background: none; color: var(--mega-orange); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; cursor: pointer; }
.launch-item.menu-button:hover, .launch-item.menu-button[aria-expanded="true"] { background: none; }
.launch-item:hover:not(:disabled) .ring, .launch-item[aria-expanded="true"] .ring, .launch-more:hover .ring { background: var(--mega-orange); color: var(--white); }
.launch-item:disabled { color: var(--mega-orange); opacity: 0.5; }
.ring { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; border: 1.5px solid var(--mega-orange); color: var(--mega-orange); }
.ring svg { width: 15px; height: 15px; }
/* Display Settings > Other Images: Stretch To Full Size fills the ring; without Keep Proportional the image is stretched with it */
:root[data-stretch="true"] .ring svg { width: 70%; height: 70%; }
:root[data-stretch="true"][data-proportional="false"] .ring svg { transform: scaleX(1.25); }
.display-group { border: 1px solid var(--gray-30); margin: 0 0 12px; padding: 6px 12px 10px; }
.display-caption { margin: 8px 0 4px; font-size: 12px; font-weight: 600; }
.display-line { display: flex; align-items: center; gap: 8px; padding: 2px 0 2px 16px; }
.display-line input[type="number"] { width: 64px; }
.launch-more { display: none; }
.mode { display: inline-flex; }
.mode-help { width: 24px; height: 24px; margin-right: 6px; border: 1.5px solid var(--mega-green); border-radius: 50%; background: var(--white); color: var(--mega-green); font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer; }
.mode-help:hover { background: var(--mega-green); color: var(--white); }
body.prototype .mode button[aria-pressed="true"] { background: var(--mega-orange); border-color: var(--mega-orange); }
.mode button { height: 28px; padding: 0 12px; border: 1.5px solid var(--mega-green); background: var(--white); color: var(--mega-green); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.mode button + button { border-left: 0; }
.mode button[aria-pressed="true"] { background: var(--mega-green); color: var(--white); cursor: default; }
.mode button:disabled { color: var(--mega-green); opacity: 0.5; }
.logo { width: 40px; height: 40px; flex: none; }

/* Empty main area: open data on the left, MEGA's service tiles on the right. */
.home { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; padding: 0 16px; }
.tiles { display: flex; flex-direction: column; gap: 10px; padding: 24px 0; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border: 1px solid var(--gray-30); border-left: 4px solid var(--mega-green); background: var(--white); text-align: left; }
a.tile { text-decoration: none; }
a.tile:hover { border-color: var(--mega-green); }
.tile-name { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; color: var(--mega-green); }
.tile-note { font-size: 12px; color: var(--gray-60); }
.tile:disabled .tile-name { opacity: 0.6; }
.cite { font-size: 14px; }
.menu-list[hidden] { display: none; }
.menu-list button { text-align: left; padding: 10px 16px; border: 0; background: none; cursor: pointer; }
.menu-list button:hover:not(:disabled) { background: var(--gray-10); }
.menu-list hr { margin: 4px 0; border: 0; border-top: 1px solid var(--gray-20); }
.menu-label { padding: 8px 16px 4px; font-size: 12px; color: var(--gray-70); }
.menu-list button.sub { padding-left: 28px; }
.menu-list button[data-myfiles][aria-checked="true"]::after { content: "\2713"; float: right; margin-left: 16px; }
.grid { font-size: var(--grid-font, 12px); line-height: calc(var(--grid-font, 12px) * 1.5); }
dialog.wide { width: min(960px, calc(100vw - 32px)); }
#text-editor { display: block; width: calc(100% - 32px); margin: 16px; height: 50vh; font: 12px/18px var(--mono); resize: vertical; }
button:disabled { color: var(--gray-50); cursor: not-allowed; }
.spacer { flex: 1; }
.run-status { font-size: 13px; color: var(--gray-70); padding: 0 12px; font-variant-numeric: tabular-nums; }
.danger, .primary { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 16px; border: 0; cursor: pointer; }
.primary { background: var(--gray-100); color: var(--white); }
.primary:hover { background: var(--gray-80); }
.danger { background: var(--error); color: var(--white); }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--gray-20); padding: 0 8px; }
.tabs button { height: 40px; padding: 0 16px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; color: var(--gray-70); }
.tabs button[aria-selected="true"] { color: var(--gray-100); border-bottom-color: var(--gray-100); font-weight: 500; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel[hidden] { display: none; }
.panel-head, .alignment-head { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--gray-20); flex-wrap: wrap; font-size: 13px; }
.panel-head button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--gray-30); background: var(--white); cursor: pointer; }
.panel-head .menu-button { border: 1px solid var(--gray-30); height: 32px; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
select, input[type="number"], input[type="text"] { height: 32px; padding: 0 8px; border: 0; border-bottom: 1px solid var(--gray-50); background: var(--gray-10); }
input.narrow { width: 64px; }
.segmented { display: inline-flex; border: 1px solid var(--gray-30); }
.segmented button { border: 0; height: 30px; }
.segmented button[aria-pressed="true"] { background: var(--gray-100); color: var(--white); }

.empty { margin: 40px auto; width: min(640px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.empty textarea { width: 100%; height: 160px; padding: 8px; font: 12px/1.4 var(--mono); border: 0; border-bottom: 1px solid var(--gray-50); background: var(--gray-10); resize: vertical; }
.empty > button:not(.primary) { height: 32px; padding: 0 16px; border: 1px solid var(--gray-30); background: var(--white); cursor: pointer; }
body.dragging .empty { outline: 2px dashed var(--gray-50); outline-offset: 12px; }

.alignment { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.alignment[hidden] { display: none; }
.grid { flex: 1; overflow: auto; font: 12px/18px var(--mono); position: relative; }
.grid-table { display: grid; grid-template-columns: max-content max-content; }
.names { position: sticky; left: 0; z-index: 2; background: var(--white); border-right: 1px solid var(--gray-20); }
.names div, .seqs div { height: 18px; white-space: pre; }
.names label { display: flex; align-items: center; gap: 6px; padding: 0 12px 0 8px; cursor: pointer; font-family: var(--sans); font-size: 12px; }
.names .ruler-cell, .seqs .ruler { position: sticky; top: 0; z-index: 1; background: var(--gray-10); color: var(--gray-60); border-bottom: 1px solid var(--gray-20); }
.names .ruler-cell { z-index: 3; }
.seqs { padding: 0 12px 0 4px; }
.colored .A { background: #ffe8a3; } .colored .C { background: #c9e5ff; } .colored .G { background: #d4f2c4; } .colored .T, .colored .U { background: #ffd6d6; }
.colored .x { background: var(--gray-20); }

.matrix { flex: 1; overflow: auto; padding: 12px 16px; }
.matrix table { border-collapse: collapse; font: 12px/1.3 var(--mono); }
.matrix th, .matrix td { border: 1px solid var(--gray-20); padding: 4px 8px; text-align: right; white-space: nowrap; }
.matrix th { background: var(--gray-10); font-family: var(--sans); font-weight: 500; }
.matrix th[scope="row"] { text-align: left; }
.matrix td.upper { color: var(--gray-60); }

.tree-area { flex: 1; overflow: auto; padding: 12px 16px; color: var(--gray-100); }
.tree-area svg { display: block; font-family: var(--sans); }
.caption { margin: 0; padding: 12px 16px; border-top: 1px solid var(--gray-20); font-size: 13px; color: var(--gray-80); max-width: 110ch; }
.caption:empty { display: none; }
.muted { color: var(--gray-60); }

.log { margin: 0; padding: 12px 16px 12px 40px; overflow: auto; font-size: 13px; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--gray-20); }
.log code { font: 12px var(--mono); color: var(--gray-70); word-break: break-all; }
.log .failed { color: var(--error); }

.statusbar { display: flex; gap: 16px; padding: 4px 16px; border-top: 1px solid var(--gray-20); background: var(--gray-10); font-size: 12px; color: var(--gray-70); }
.statusbar .error { color: var(--error); }

dialog { border: 1px solid var(--gray-30); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 4px 16px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(22 22 22 / 0.5); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 66px); }
dialog h2 { margin: 0; padding: 16px; font-size: 18px; font-weight: 500; border-bottom: 1px solid var(--gray-20); }
dialog p { margin: 12px 16px 0; }
.prefs { border-collapse: collapse; width: 100%; font-size: 13px; overflow: auto; display: block; }
.prefs thead, .prefs tbody { display: table; width: 100%; table-layout: fixed; }
.prefs th { text-align: left; background: var(--gray-10); padding: 6px 16px; font-weight: 500; }
.prefs td { padding: 4px 16px; border-bottom: 1px solid var(--gray-10); vertical-align: middle; }
.prefs td:first-child { color: var(--gray-80); }
.prefs tr.group td { background: var(--gray-10); font-weight: 500; color: var(--gray-100); padding-top: 8px; }
.prefs select, .prefs input { width: 100%; }
.prefs input[type="checkbox"] { width: auto; }
.prefs tr.off td { color: var(--gray-50); }
.note { font-size: 12px; color: var(--gray-70); }
.actions { display: flex; justify-content: flex-end; gap: 0; margin-top: 16px; border-top: 1px solid var(--gray-20); }
.actions button { height: 48px; min-width: 120px; padding: 0 16px; border: 0; background: var(--gray-80); color: var(--white); cursor: pointer; text-align: left; }
.actions button.primary { background: var(--gray-100); }
.actions button:hover { background: var(--gray-70); }
.taxon-list { margin: 12px 16px 0; max-height: 50vh; overflow: auto; border: 1px solid var(--gray-20); }
.taxon-list label { display: flex; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--gray-10); cursor: pointer; }

@media (max-width: 640px) {
  .engine-note { display: none; }
  .panel-head { gap: 8px; }
  .shell { gap: 8px; padding-left: 8px; }
  .strip .menu-button { padding: 0 8px; }
  .toolbar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px 0; padding: 8px 4px 6px; overflow: visible; }
  .toolbar > .menu { max-width: none; min-width: 0; }
  .menu-button.badge { gap: 4px; padding: 0; }
  .disc { width: 40px; height: 40px; }
  .disc svg { width: 22px; height: 22px; }
  .badge-label { font-size: 9px; letter-spacing: 0; }
  .launch { padding: 0 8px 2px; }
  .launch-more { display: inline-flex; }
  .launch-items { display: none; position: absolute; left: 8px; right: 8px; bottom: 100%; z-index: 15; padding: 8px; background: var(--white); border: 1px solid var(--gray-30); box-shadow: 0 -2px 8px rgb(0 0 0 / 0.18); }
  .launch.open .launch-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; }
  .home { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .empty { margin: 20px auto 8px; }
  .tiles { flex-direction: row; padding: 8px 0 16px; }
  .tile { flex: 1 1 0; min-width: 0; padding: 8px; }
  .tile-name { font-size: 12px; }
  .tile-note { font-size: 11px; }
}

.results-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(180px, 260px) 1fr; }
.result-list { margin: 0; padding: 8px 0; list-style: none; border-right: 1px solid var(--gray-20); overflow: auto; }
.result-list button { width: 100%; text-align: left; padding: 8px 16px; border: 0; background: none; cursor: pointer; font-size: 13px; }
.result-list button[aria-current="true"] { background: var(--gray-10); font-weight: 500; box-shadow: inset 3px 0 0 var(--gray-100); }
.result-view { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.result-title { font-weight: 500; }
.explorer { flex: 1; overflow: auto; padding: 12px 16px; max-width: 900px; }
.explorer h3 { margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
.explorer table { border-collapse: collapse; font-size: 13px; width: 100%; }
.explorer th, .explorer td { text-align: left; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--gray-10); vertical-align: top; }
.explorer th { font-weight: 500; color: var(--gray-70); width: 240px; }
.checks { display: inline-flex; gap: 12px; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: 4px; align-items: center; }
.highlighting .dim { color: var(--gray-50); background: none; }
.highlighting .mark { outline: 1px solid var(--gray-100); outline-offset: -1px; }
@media (max-width: 640px) { .results-layout { grid-template-columns: 1fr; } .result-list { border-right: 0; border-bottom: 1px solid var(--gray-20); max-height: 160px; } }

.tree-tools { display: flex; align-items: center; gap: 8px; padding: 6px 16px; border-bottom: 1px solid var(--gray-20); flex-wrap: wrap; font-size: 13px; }
.tree-tools button { height: 28px; padding: 0 10px; border: 1px solid var(--gray-30); background: var(--white); cursor: pointer; font-size: 13px; }
.tree-area .branch, .tree-area .hit { cursor: pointer; }
.tree-area .branch:hover { stroke-width: 3; }
.tree-area .branch.selected { stroke-width: 3.5; }
.tree-area .node-mark { fill: var(--gray-100); }

.file-text { margin: 0; font: 12px/1.45 var(--mono); white-space: pre; }
.mega-caption { max-width: 110ch; font-size: 13px; line-height: 1.5; }
.mega-caption table { border-collapse: collapse; margin: 8px 0; font: 12px/1.3 var(--mono); }
.mega-caption td, .mega-caption th { border: 1px solid var(--gray-20); padding: 3px 8px; text-align: right; }
.prefs input[type="file"] { height: auto; padding: 4px 0; background: none; border: 0; }
