/* PathwayAnnotator. Colours are tokens, redefined for dark mode. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d2228;
  --muted: #5c6670;
  --border: #d9dde1;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --done: #2b7a78;
  --high: #2e8540;
  --likely: #b07d10;
  --uncertain: #c2541b;
  --unknown: #9aa3ab;
  --chip-bg: #eef1f4;
  --error: #b42318;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1d2127;
    --text: #e6e9ec;
    --muted: #9aa4ae;
    --border: #343a42;
    --accent: #4f8ff7;
    --accent-text: #0b0d10;
    --done: #3fb5b0;
    --high: #4cb862;
    --likely: #e0a83a;
    --uncertain: #f07a45;
    --unknown: #6b747d;
    --chip-bg: #2a3038;
    --error: #f97066;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 1000px; margin: 0 auto; padding: 16px 16px 48px; }

button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { border: none; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:focus-visible, a:focus-visible, label.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

a { color: var(--accent); word-break: break-all; }

/* Header */
header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
header.top h1 { font-size: 18px; margin: 0; }
header.top .file { color: var(--muted); }
header.top .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }

/* Start */
.start { max-width: 640px; margin: 40px auto; }
.start h2 { margin-top: 0; }
label.drop {
  display: flex; align-items: center; justify-content: center; min-height: 140px;
  border: 2px dashed var(--border); border-radius: 10px; background: var(--surface);
  cursor: pointer; text-align: center; padding: 16px;
}
label.drop.dragging { border-color: var(--accent); }
label.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-text { color: var(--muted); }
.or { color: var(--muted); }

.loading, .empty, .muted { color: var(--muted); }
.error { color: var(--error); }

/* Overview */
.overview {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.overview .bulk { grid-column: 1 / -1; }
@media (max-width: 640px) { .overview { grid-template-columns: 1fr; } }
.progress-head { display: flex; justify-content: space-between; gap: 8px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--chip-bg); margin: 6px 0; }
.seg { display: block; height: 100%; }
.seg.done { background: var(--done); }
.seg.high { background: var(--high); }
.seg.likely { background: var(--likely); }
.seg.uncertain { background: var(--uncertain); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }

/* Status dots, badges, chips */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--unknown); }
.dot.done { background: var(--done); }
.dot.high { background: var(--high); }
.dot.likely { background: var(--likely); }
.dot.uncertain { background: var(--uncertain); }

.badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; margin-left: 6px; border: 1px solid currentColor; }
.badge.high { color: var(--high); }
.badge.likely { color: var(--likely); }
.badge.uncertain { color: var(--uncertain); }

/* Tabs and filters */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.tab { border-radius: 6px 6px 0 0; }
.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.filters { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.chip-filter { font-size: 13px; padding: 2px 10px; border-radius: 12px; }
.chip-filter.active { border-color: var(--accent); color: var(--accent); }

/* Items */
ul.items { list-style: none; margin: 0; padding: 0; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.item.open { border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; cursor: pointer; }
.row .name { font-weight: 600; }
.row .id { color: var(--muted); font-size: 13px; font-family: ui-monospace, monospace; }
.row .what { margin-left: auto; }
.row .accept { margin-left: 4px; }
.row:hover { background: var(--chip-bg); border-radius: 8px; }
.item.open > .row { background: var(--chip-bg); border-radius: 8px 8px 0 0; }

/* The row's Details / Hide control. */
.disclose { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--accent); border-color: transparent; background: none; }
.disclose:hover:not(:disabled) { border-color: var(--accent); }
.disclose .chevron { transition: transform 0.15s; }
.disclose[aria-expanded="true"] .chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .disclose .chevron { transition: none; } }

.equation { padding: 0 12px 8px 32px; color: var(--muted); line-height: 2; }
.chip {
  font-size: 13px; padding: 1px 8px; border-radius: 12px; background: var(--chip-bg);
  border: 1px solid var(--border); border-left: 4px solid var(--unknown);
}
.chip.done { border-left-color: var(--done); }
.chip.high { border-left-color: var(--high); }
.chip.likely { border-left-color: var(--likely); }
.chip.uncertain { border-left-color: var(--uncertain); }
.arrow { white-space: pre; }

/* A molecule chip's card: shown on hover, on keyboard focus, or pinned by a
   click. The padding above the body keeps the hover alive while the
   pointer moves from the chip into the card. */
.chip-wrap { position: relative; display: inline-block; }
.chip-card { display: none; position: absolute; top: 100%; left: 0; z-index: 20; padding-top: 6px; }
.chip-wrap:hover .chip-card,
.chip-wrap:has(.chip:focus-visible) .chip-card,
.chip-wrap.pinned .chip-card { display: block; }
/* No room below or to the right: the card opens upward, or lines up with
   the chip's right edge (set by place_card in views.rs). */
.chip-wrap.up .chip-card { top: auto; bottom: 100%; padding-top: 0; padding-bottom: 6px; }
.chip-wrap.end .chip-card { left: auto; right: 0; }
.chip-wrap.pinned .chip { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-card-body {
  width: max-content; max-width: min(340px, 85vw); padding: 10px 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); line-height: 1.45; font-size: 13px; text-align: left; white-space: normal;
}
.chip-card-body p { margin: 4px 0; }
.chip-card-title { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.chip-card-actions { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 6px; }

/* Searching other databases (Details). */
.online { margin-top: 12px; }
.online-form { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.online-form input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; min-width: 16em; }
.online-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.online-form select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.online .hint { margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.online h5 { margin: 10px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.online .detail { margin: 2px 0; font-size: 13px; }

/* Keyboard: the row the keyboard is on, and the shortcuts panel. */
.item.cursor > .row { box-shadow: inset 3px 0 0 var(--accent); background: var(--chip-bg); border-radius: 8px; }
kbd {
  font-family: ui-monospace, monospace; font-size: 12px; padding: 0 5px; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--text);
}
.shortcuts-button { margin-left: auto; font-size: 13px; }
.shortcuts {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto; padding: 12px 16px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22); font-size: 14px;
}
.shortcuts-head { display: flex; align-items: baseline; justify-content: space-between; }
/* About: data sources and their licenses. */
.about-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.35); }
.about {
  position: fixed; z-index: 50; left: 50%; top: 5vh; transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px)); max-height: 90vh; overflow: auto; padding: 16px 20px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28); font-size: 14px; line-height: 1.5;
}
.about h3 { margin: 16px 0 6px; font-size: 16px; }
.about .version { margin: 0 0 6px; color: var(--muted); }
.help h4 { margin: 14px 0 4px; font-size: 14px; }
.help ol, .help ul { margin: 4px 0; padding-left: 22px; }
.help li { margin: 3px 0; }
/* What the tool is for, above the overview. */
.intro { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.intro p { margin: 0 0 6px; }
.intro .link { font-size: inherit; }
.about .shortcuts-head h3 { margin-top: 0; }
.about h4 { margin: 12px 0 2px; font-size: 14px; }
.about .source p { margin: 2px 0; }
.about pre.notice {
  white-space: pre-wrap; font-family: inherit; font-size: 12px; margin: 6px 0; padding: 8px 10px;
  background: var(--chip-bg); border-radius: 6px; max-height: 240px; overflow: auto;
}
.shortcuts h3 { margin: 0 0 8px; font-size: 15px; }
.shortcuts table { border-collapse: collapse; width: 100%; }
.shortcuts td { padding: 3px 6px 3px 0; vertical-align: top; }
.shortcuts td.keys { white-space: nowrap; color: var(--muted); }

/* The way back after jumping from a reaction to a molecule. */
.back { position: sticky; top: 0; z-index: 10; padding: 6px 0; background: var(--bg); }
.back button { display: inline-flex; align-items: center; gap: 2px; border-color: var(--accent); color: var(--accent); }

/* Details */
.details { border-top: 1px solid var(--border); padding: 8px 12px 12px 32px; }
.details h4 { margin: 8px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.terms { margin: 0; padding-left: 16px; font-size: 13px; }
/* Editing the annotation (Details). */
.annotation select, .annotation input {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
}
.annotation input:focus, .annotation select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sbo-row, .add-term { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.sbo-number { width: 9em; }
.add-term input { min-width: 16em; flex: 1 1 16em; }
.terms.edit { list-style: none; padding-left: 0; }
.filters.hidden { visibility: hidden; }
.model-panel { padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.model-panel h3 { margin: 0 0 2px; font-size: 17px; }
.model-panel > .muted { margin: 0 0 8px; font-size: 13px; }
.references .paper { flex-basis: 100%; }
.model-panel .hint { margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.model-panel input, .model-panel select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
}
.model-panel input:focus, .model-panel select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.model-panel h4 { margin: 14px 0 4px; }
.creator-form input { min-width: 9em; flex: 1 1 9em; }
.model-panel textarea.notes {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; resize: vertical;
}
.model-panel textarea.notes:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint.warn { color: var(--error); }
.terms.edit li { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 3px 0; word-break: break-all; }
.annotation .hint { margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.qualifier { font-family: ui-monospace, monospace; color: var(--muted); }
.cand { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin-bottom: 6px; }
.cand-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cand-head .rank { color: var(--muted); font-size: 12px; }
.cand-head .ids { color: var(--muted); font-size: 13px; display: inline-flex; flex-wrap: wrap; gap: 2px 10px; }
.cand-head .ids a { white-space: nowrap; }

/* A suggestion's name links to its database entry. */
a.check { font-weight: 600; color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
a.check:hover { color: var(--accent); text-decoration-color: var(--accent); }
a.check .ext { margin-left: 3px; vertical-align: baseline; color: var(--muted); }
.cand-head .accept, .cand-head .accepted, .cand-head .cand-actions { margin-left: auto; }
.cand-actions { display: inline-flex; gap: 6px; }
button.reject { color: var(--muted); border-color: transparent; background: none; }
button.reject:hover:not(:disabled) { color: var(--uncertain); border-color: var(--uncertain); }
ul.rejected { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
ul.rejected li { display: flex; gap: 10px; align-items: baseline; }
.cand.is-accepted { border-color: var(--done); background: color-mix(in srgb, var(--done) 8%, var(--surface)); }
.accepted { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--done); padding: 4px 4px; }
.aka { color: var(--muted); font-size: 13px; margin-left: 6px; }
.aka-list { margin: 4px 0 0; font-size: 13px; color: var(--text); }
.evidence { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* Renaming an element's SBML id. */
.rename { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 4px; font-size: 13px; }
.rename code { font-family: ui-monospace, monospace; background: var(--chip-bg); padding: 1px 6px; border-radius: 4px; }
.rename input { font: inherit; font-family: ui-monospace, monospace; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; min-width: 12em; }
.rename input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.rename .hint { flex-basis: 100%; margin: 0; color: var(--muted); }
.rename .error { flex-basis: 100%; margin: 0; }

/* Messages */
.message {
  position: sticky; bottom: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin-top: 16px;
}
