/* MarkHippo — app.css
 *
 * The editor's chrome: header, split pane, status bar, dialogs. The rendered
 * document's own styles are in preview.css.
 *
 * One stylesheet, two themes, in the shape JsonHippo and Rest Hippo use: the
 * dark theme is the Hippo family palette (the one hippoherd.com uses), the
 * light theme its daylight counterpart. The theme follows the system unless
 * the header toggle pins one. These values are the Hippo palette's, the
 * defaults for the first paint; the palette in use — Hippo, a plugin's, or
 * the user's own — is set on <html> as custom properties by
 * js/theme-manager.js (and, before the first paint, js/theme.js), and the
 * Themes dialog edits them.
 *
 * The brand orange (#E06000, hue 25.7 — the logo's own, src/img/markhippo.svg)
 * is used as a fill: the white hippo on it is 3.59:1. Text in the accent
 * uses --accent, the same hue deepened for light (#A84800, 5.85:1 on white,
 * 4.96:1 on the palest surface) and brightened for dark (#FF9A52, 8.11:1 on
 * #1c1c1c), so it passes AA on both.
 *
 * Naming: mh- prefix; state classes are block--modifier.
 */

/* ── Theme ──────────────────────────────────────────────────────────────── */

:root {
  --brand: #e06000;
  --on-brand: #ffffff;

  --bg: #ffffff;
  --mantle: #f6f6f8;
  --crust: #ececf0;
  --surface-0: #ececf0;
  --surface-1: #dcdce2;
  --surface-2: #c8c8d0;
  --text: #1f1f24;
  --subtext: #57575f;
  --muted: #6e6e76;
  --accent: #a84800;
  --selection: #fde4d0;
  --code-bg: #f3f3f5;
  --quote-bar: #eeb183;
  --error: #c4271d;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --code-size: 13.5px;
  --code-line: 21px;

  color-scheme: light;
}

/* The family's dark palette. Written out twice — once for "follow the system"
   and once for "pinned dark" — because a media query cannot be combined with
   an attribute selector into one rule. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1c;
    --mantle: #161616;
    --crust: #101010;
    --surface-0: #2a2a2a;
    --surface-1: #383838;
    --surface-2: #484848;
    --text: #e8e8e8;
    --subtext: #b0b0b0;
    --muted: #8a8a8a;
    --accent: #ff9a52;
    --selection: #4a2a12;
    --code-bg: #242424;
    --quote-bar: #80410f;
    --error: #ff7b72;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1c1c1c;
  --mantle: #161616;
  --crust: #101010;
  --surface-0: #2a2a2a;
  --surface-1: #383838;
  --surface-2: #484848;
  --text: #e8e8e8;
  --subtext: #b0b0b0;
  --muted: #8a8a8a;
  --accent: #ff9a52;
  --selection: #4a2a12;
  --code-bg: #242424;
  --quote-bar: #80410f;
  --error: #ff7b72;
  color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.mh-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mh-icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.mh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--surface-1);
  border-radius: 6px;
  background: var(--mantle);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.mh-btn:hover {
  border-color: var(--surface-2);
  background: var(--surface-0);
}

.mh-btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--subtext);
}

.mh-btn--ghost:hover {
  color: var(--text);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.mh-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--surface-0);
  background: var(--mantle);
}

.mh-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 2px 2px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.mh-logo {
  border-radius: 7px;
}

.mh-name {
  font-size: 16px;
  font-weight: 650;
}

.mh-file {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mh-filename {
  overflow: hidden;
  margin-left: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mh-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

/* Inside ViewHippo (theme.js sets the attribute; hippoherd's brief, "Host
   chrome"). The app's File menu opens and saves, and its tab or title names
   the file, so these go whenever the page is hosted. */
[data-viewhippo-chrome] .mh-file [data-action],
[data-viewhippo-chrome] #mh-filename {
  display: none;
}

/* With the app's tab strip showing, the strip carries the logo, Hippo Herd,
   the light/dark mode and GitHub. What is left is MarkHippo's own: Export,
   Plugins, the guide and Themes, as a slimmer row. */
[data-viewhippo-chrome="tabs"] .mh-brand,
[data-viewhippo-chrome="tabs"] #mh-herd-link,
[data-viewhippo-chrome="tabs"] #mh-theme,
[data-viewhippo-chrome="tabs"] #mh-github-link {
  display: none;
}

[data-viewhippo-chrome="tabs"] .mh-header {
  padding-block: 4px;
}

@media (max-width: 900px) {
  .mh-header-actions .mh-btn span,
  .mh-file .mh-btn span {
    display: none;
  }
}

/* ── Menus (js/menu-button.js) ──────────────────────────────────────────── */

.mh-menu-wrap {
  position: relative;
}

.mh-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 270px;
  padding: 4px;
  border: 1px solid var(--surface-1);
  border-radius: 8px;
  background: var(--mantle);
  box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
}

.mh-menu[hidden] {
  display: none;
}

.mh-menu [role="menuitem"] {
  display: flex;
  align-items: baseline;
  gap: 16px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

/* The item with the focus is the one marked: arrow keys and the pointer
   move the same mark. */
.mh-menu [role="menuitem"][hidden] {
  display: none;
}

.mh-menu [role="menuitem"]:hover,
.mh-menu [role="menuitem"]:focus {
  background: var(--selection);
  outline: none;
}

.mh-menu-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.mh-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--surface-0);
}

/* ── Split pane ─────────────────────────────────────────────────────────── */

.mh-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.mh-panes {
  --split: 50%;
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, var(--split)) 6px minmax(0, 1fr);
  /* A fixed row and contained panes: a pane's size never depends on its
     content, so an edit to a long document relays out one line, not the
     whole page (without these, every keystroke re-measured all of it). */
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

.mh-pane {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  contain: strict;
}

.mh-pane--source {
  display: flex;
  background: var(--bg);
}

.mh-source-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
  contain: strict;
}

/* ── Minimap ── */

.mh-minimap {
  flex: none;
  width: 72px;
  height: 100%;
  border-left: 1px solid var(--surface-0);
  background: var(--crust);
  cursor: pointer;
  touch-action: none;
}

.mh-minimap[hidden] {
  display: none;
}

/* The editor: a <textarea> exactly over a coloured <pre> of the same text
   (js/source-highlight.js). Both get the same font, box and wrapping, so
   every character of the copy sits under the textarea's (transparent) one;
   the textarea is as tall as the <pre> and the pane scrolls them together. */
.mh-editor {
  position: relative;
  min-height: 100%;
}

.mh-highlight,
.mh-source {
  display: block;
  width: 100%;
  margin: 0;
  padding: 16px 20px 40vh;
  border: 0;
  font-family: var(--mono);
  font-size: var(--code-size);
  font-kerning: none;
  font-variant-ligatures: none;
  letter-spacing: 0;
  line-height: var(--code-line);
  overflow-wrap: break-word;
  tab-size: 4;
  white-space: pre-wrap;
  word-break: normal;
}

.mh-highlight {
  color: var(--text);
  pointer-events: none;
}

/* One block per source line: an edit relays out only its own lines. */
.mh-highlight > span {
  display: block;
}

.mh-source {
  position: absolute;
  inset: 0;
  height: 100%;
  overflow: hidden;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
}

/* The selection is painted over the coloured copy, so it must let it show. */
.mh-source::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: transparent;
}

.mh-source::placeholder {
  color: var(--muted);
}

.mh-divider {
  background: var(--surface-0);
  cursor: col-resize;
  touch-action: none;
}

.mh-divider:hover,
.mh-divider--dragging {
  background: var(--brand);
}

.mh-pane--preview {
  overflow: auto;
  background: var(--bg);
}

/* Narrow screens: the panes stack, preview under the source. */
@media (max-width: 700px) {
  .mh-panes {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 0 minmax(0, 1fr);
  }

  .mh-divider {
    display: none;
  }

  .mh-pane--source {
    border-bottom: 1px solid var(--surface-1);
  }
}

/* ── Drop target ────────────────────────────────────────────────────────── */

.mh-drop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 3px dashed var(--brand);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  pointer-events: none;
}

.mh-drop[hidden] {
  display: none;
}

.mh-drop p {
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 16px;
  font-weight: 600;
}

/* ── Status bar ─────────────────────────────────────────────────────────── */

.mh-status {
  display: flex;
  gap: 20px;
  padding: 4px 12px;
  border-top: 1px solid var(--surface-0);
  background: var(--mantle);
  color: var(--subtext);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.mh-status-note {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mh-status-note--warn {
  color: var(--error);
}

.mh-status-cursor {
  margin-left: auto;
}

.mh-view {
  display: flex;
  gap: 2px;
  margin: -3px -8px -3px 0;
}

.mh-toggle {
  padding: 2px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--subtext);
  font: inherit;
  cursor: pointer;
}

.mh-toggle:hover {
  background: var(--surface-0);
  color: var(--text);
}

.mh-toggle[aria-pressed="true"] {
  color: var(--accent);
  font-weight: 600;
}

/* ── Outline ────────────────────────────────────────────────────────────── */

.mh-outline {
  display: flex;
  flex: none;
  flex-direction: column;
  width: 240px;
  min-height: 0;
  border-right: 1px solid var(--surface-0);
  background: var(--mantle);
}

.mh-outline[hidden] {
  display: none;
}

.mh-outline-title {
  margin: 0;
  padding: 10px 14px 6px;
  color: var(--subtext);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mh-outline-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0 6px 12px;
  list-style: none;
}

.mh-outline-item {
  display: block;
  width: 100%;
  padding: 3px 8px 3px calc(8px + var(--depth, 0) * 12px);
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--subtext);
  font: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.mh-outline-item:hover {
  background: var(--surface-0);
  color: var(--text);
}

.mh-outline-item--h1 {
  color: var(--text);
  font-weight: 650;
}

.mh-outline-item[aria-current="location"] {
  background: var(--selection);
  color: var(--text);
}

.mh-outline-empty {
  margin: 0;
  padding: 4px 14px;
  color: var(--muted);
  font-size: 13px;
}

.mh-outline-empty[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .mh-outline {
    width: 180px;
  }
}

/* Too narrow for a side panel: no outline, and no switch for one. */
@media (max-width: 700px) {
  .mh-outline,
  .mh-toggle--outline {
    display: none;
  }
}

/* ── Export and print (js/exporter.js) ─────────────────────────────────── */

/* Where an export is finished by the plugins (math, diagrams): in the page,
   as they need, but out of sight. */
.mh-export-stage {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 760px;
  visibility: hidden;
  pointer-events: none;
}

/* Printing prints the document alone, put in the print area in the
   palette's light colours — never the editor. */
.mh-print {
  display: none;
}

@media print {
  html,
  body {
    height: auto;
  }

  body {
    display: block;
    background: none;
  }

  body > :not(.mh-print) {
    display: none;
  }

  /* (Over preview.css's .mh-preview, which comes later.) */
  .mh-preview.mh-print {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
  }
}

/* ── About ──────────────────────────────────────────────────────────────── */

.mh-about {
  max-width: 380px;
  padding: 28px 32px 24px;
  border: 1px solid var(--surface-1);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
}

.mh-about::backdrop {
  background: rgb(0 0 0 / 45%);
}

.mh-about-logo {
  border-radius: 22px;
}

.mh-about-name {
  margin: 12px 0 2px;
  font-size: 22px;
}

.mh-about-tagline {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 600;
}

.mh-about-desc,
.mh-about-credit {
  color: var(--subtext);
}

.mh-about-links {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.mh-about-links a {
  color: var(--accent);
}

.mh-about-credit {
  font-size: 12px;
}

.mh-about-version {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.mh-about-support a {
  color: var(--accent);
  text-decoration: none;
}

.mh-about-support a:hover {
  text-decoration: underline;
}

/* ── Plugins ────────────────────────────────────────────────────────────── */

.mh-plugins {
  width: min(520px, calc(100vw - 32px));
  padding: 22px 26px 20px;
  border: 1px solid var(--surface-1);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
}

.mh-plugins::backdrop {
  background: rgb(0 0 0 / 45%);
}

.mh-plugins-title {
  margin: 0 0 6px;
  font-size: 18px;
}

.mh-plugins-intro {
  margin: 0 0 14px;
  color: var(--subtext);
}

.mh-plugin-list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.mh-plugin {
  padding: 10px 12px;
  border: 1px solid var(--surface-0);
  border-radius: 8px;
  background: var(--mantle);
}

.mh-plugin + .mh-plugin {
  margin-top: 8px;
}

.mh-plugin-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mh-plugin-head input {
  margin: 0;
  accent-color: var(--brand);
}

.mh-plugin-name {
  font-weight: 600;
}

.mh-plugin-version {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.mh-plugin-badge {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--surface-0);
  color: var(--subtext);
  font-size: 11.5px;
}

.mh-plugin-desc {
  margin: 4px 0 0 24px;
  color: var(--subtext);
  font-size: 13px;
}

/* The desktop app: where a plugin of the user's came from, and why one is
   not running. */
.mh-plugin-source {
  margin: 2px 0 0 24px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.mh-plugin-error {
  margin: 4px 0 0 24px;
  color: var(--error);
  font-size: 13px;
}

.mh-plugin--failed {
  border-color: color-mix(in srgb, var(--error) 45%, var(--surface-0));
}

.mh-plugins-desktop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}

.mh-plugins-desktop[hidden] {
  display: none;
}

.mh-plugins-desktop p {
  flex-basis: 100%;
  margin: 0;
  color: var(--subtext);
  font-size: 13px;
}

.mh-plugins form {
  display: flex;
  justify-content: flex-end;
}

/* ── Autocomplete ───────────────────────────────────────────────────────── */

.mh-complete {
  position: absolute;
  z-index: 2;
  min-width: 220px;
  max-width: min(420px, calc(100% - 16px));
  max-height: 264px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--surface-1);
  border-radius: 8px;
  background: var(--mantle);
  box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
  font: 13px/1.3 var(--sans);
}

.mh-complete[hidden] {
  display: none;
}

.mh-complete-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.mh-complete-item[aria-selected="true"] {
  background: var(--selection);
}

.mh-complete-label {
  font-weight: 550;
}

.mh-complete-detail {
  overflow: hidden;
  color: var(--subtext);
  text-overflow: ellipsis;
}

.mh-complete-hint {
  margin-left: auto;
  padding-left: 12px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
}

.mh-complete[data-kind="fence-info"] .mh-complete-label,
.mh-complete[data-kind="link-ref"] .mh-complete-label {
  font-family: var(--mono);
  font-weight: 500;
}

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

.mh-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

/* ── Themes ─────────────────────────────────────────────────────────────── */

.mh-themes {
  width: min(1000px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--surface-1);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
}

.mh-themes[open] {
  display: flex;
  flex-direction: column;
}

.mh-themes::backdrop {
  background: rgb(0 0 0 / 35%);
}

.mh-themes-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--surface-0);
  background: var(--mantle);
}

.mh-themes-title {
  margin: 0;
  font-size: 18px;
}

.mh-themes-done {
  margin-left: auto;
}

.mh-segmented {
  display: inline-flex;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--surface-1);
  border-radius: 8px;
  background: var(--bg);
}

.mh-segmented label {
  position: relative;
  display: inline-flex;
}

.mh-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mh-segmented span {
  padding: 4px 12px;
  border-radius: 6px;
  color: var(--subtext);
  cursor: pointer;
}

.mh-segmented input:checked + span {
  background: var(--surface-0);
  color: var(--text);
  font-weight: 600;
}

.mh-segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

.mh-themes-body {
  display: grid;
  flex: 1;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 0;
}

.mh-themes-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  border-right: 1px solid var(--surface-0);
  background: var(--mantle);
}

.mh-palette-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mh-palette {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  margin-bottom: 4px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mh-palette:hover {
  background: var(--surface-0);
}

.mh-palette[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--bg);
}

.mh-palette-swatches {
  display: flex;
  grid-row: span 2;
  overflow: hidden;
  border: 1px solid var(--surface-1);
  border-radius: 6px;
}

.mh-palette-half {
  display: grid;
  grid-template-columns: repeat(2, 7px);
  gap: 3px;
  padding: 5px;
}

.mh-palette-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.mh-palette-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mh-palette-badge {
  color: var(--muted);
  font-size: 12px;
}

.mh-themes-side-actions {
  display: flex;
  gap: 6px;
}

.mh-theme-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--subtext);
  font-size: 12.5px;
}

.mh-theme-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mh-theme-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 6px;
}

.mh-theme-name {
  flex: 1 1 160px;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--surface-1);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.mh-theme-name:read-only {
  border-color: transparent;
}

.mh-tabs {
  display: inline-flex;
  gap: 2px;
}

.mh-tabs [role="tab"] {
  padding: 5px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--subtext);
  font: inherit;
  cursor: pointer;
}

.mh-tabs [aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.mh-theme-actions {
  display: flex;
  gap: 6px;
}

.mh-theme-note {
  margin: 0;
  padding: 0 16px 8px;
  color: var(--subtext);
  font-size: 12.5px;
}

.mh-theme-grid {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.mh-color-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 4px 18px;
}

.mh-color-group h3 {
  grid-column: 1 / -1;
  margin: 14px 0 6px;
  color: var(--subtext);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mh-color-row {
  display: grid;
  grid-template-columns: 1fr auto 76px 54px;
  gap: 8px;
  align-items: center;
}

.mh-color-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mh-color-picker {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--surface-1);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.mh-color-picker:disabled {
  cursor: default;
}

.mh-color-hex {
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--surface-1);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.mh-contrast {
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: right;
}

.mh-contrast--good {
  color: var(--subtext);
}

.mh-contrast--fair,
.mh-contrast--poor {
  color: var(--error);
  font-weight: 700;
}

@media (max-width: 700px) {
  .mh-themes-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .mh-themes-side {
    max-height: 40vh;
    border-right: 0;
    border-bottom: 1px solid var(--surface-0);
  }
}
