/* ─────────────────────────────────────────────────────────────────────────
   Marl download page.

   The page is built on the app's own duality: Markdown source set in mono,
   the rendered document set in a serif. Colour comes from the app icon's
   indigo. Everything is quiet except the working window in the hero.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --paper:      #ECEEF4;
  --paper-alt:  #E3E6EF;
  --card:       #FFFFFF;
  --ink:        #14161F;
  --slate:      #565D73;
  --rule:       #D5D9E6;
  --indigo:     #4A57E8;
  --periwinkle: #6D7CFF;
  --tint:       rgba(74, 87, 232, .09);
  --scrim:      rgba(20, 22, 31, .26);
  --shadow:     0 1px 2px rgba(20, 22, 31, .06), 0 18px 46px -12px rgba(20, 22, 31, .22);

  --serif: "Newsreader", Iowan Old Style, Georgia, serif;
  --mono:  "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --split: 50%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #0F111A;
    --paper-alt:  #1B1F2B;
    --card:       #181B26;
    --ink:        #E8EAF3;
    --slate:      #969DB4;
    --rule:       #282C3A;
    --indigo:     #8590FF;
    --periwinkle: #A3ACFF;
    --tint:       rgba(133, 144, 255, .14);
    --scrim:      rgba(0, 0, 0, .5);
    --shadow:     0 1px 2px rgba(0, 0, 0, .5), 0 22px 50px -14px rgba(0, 0, 0, .7);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button { font: inherit; color: inherit; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 13px;
  z-index: 20;
}
.skip:focus { left: 12px; top: 12px; }

:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */

.topbar { border-bottom: 1px solid var(--rule); }

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.brand img { border-radius: 5px; display: block; }

.brand-tag {
  margin-left: -3px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--slate);
}

.topbar-meta {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--slate);
}

/* ── Hero ────────────────────────────────────────────────────────────── */

.hero { padding: 58px 0 0; }

/* ── The window ──────────────────────────────────────────────────────── */

.window {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 11px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.titlebar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule);
}

.lights { display: inline-flex; gap: 7px; }
.lights i {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--rule);
  display: block;
}

.win-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}
.win-sub { font-size: 10.5px; font-weight: 400; color: var(--slate); }

.win-tools {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool, .segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--slate);
  cursor: pointer;
}
.tool:hover, .segmented button:hover { background: var(--paper-alt); color: var(--ink); }
.tool[aria-pressed="true"] { color: var(--indigo); }

.segmented {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.segmented button[aria-pressed="true"] {
  background: var(--tint);
  color: var(--indigo);
}

.win-tools svg, .segmented svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Tabs ────────────────────────────────────────────────────────────── */

.tabstrip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--rule);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 200px;
  padding: 5px 13px 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--slate);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.tab:hover { background: var(--paper-alt); }
.tab.is-active { background: var(--paper-alt); color: var(--ink); font-weight: 500; }

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

.tab-dot {
  flex: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  position: relative;
}
.tab-dot.is-dirty::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 50%;
  background: var(--slate);
}
.tab:hover .tab-dot::after {
  content: "×";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  line-height: 12px;
  text-align: center;
}

.tab-add {
  margin-left: auto;
  width: 26px; height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--slate);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.tab-add:hover { background: var(--paper-alt); color: var(--ink); }

/* ── Body: sidebar + panes ───────────────────────────────────────────── */

.body {
  position: relative;
  display: flex;
  height: 432px;
}

.sidebar {
  flex: none;
  width: 216px;
  padding: 12px 10px;
  border-right: 1px solid var(--rule);
  background: var(--paper-alt);
  overflow: auto;
}

.side-head {
  margin: 8px 0 6px 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slate);
}

.side-file {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.side-file:hover { background: var(--card); }
.side-file.is-open { background: var(--tint); }

.side-name, .side-path {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}
.side-name { font-size: 12px; font-weight: 500; }
.side-path { font-size: 10.5px; color: var(--slate); }
.side-file.is-open .side-name { color: var(--indigo); }

.split {
  flex: 1;
  display: grid;
  grid-template-columns: var(--split) 9px 1fr;
  min-width: 0;
}

#app[data-mode="preview"] .split { grid-template-columns: 1fr; }
#app[data-mode="preview"] .pane-source,
#app[data-mode="preview"] .divider { display: none; }

#app[data-mode="edit"] .split { grid-template-columns: 1fr; }
#app[data-mode="edit"] .pane-rendered,
#app[data-mode="edit"] .divider { display: none; }

.pane {
  display: flex;
  flex-direction: column;
  padding: 18px 22px 20px;
  min-width: 0;
  overflow: hidden;
}

.pane-label {
  flex: none;
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--slate);
  opacity: .8;
}

/* Source: a highlighted <pre> with the real textarea laid transparently on top. */
.editor-wrap { position: relative; flex: 1; min-height: 0; }

#src, #editor {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.85;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow: auto;
  tab-size: 2;
}

#src { color: var(--ink); pointer-events: none; }
#src .mk { color: var(--indigo); }

#editor {
  color: transparent;
  caret-color: var(--indigo);
  background: transparent;
  resize: none;
  outline: none;
  -webkit-text-fill-color: transparent;
}
#editor::selection { background: var(--tint); }

.divider {
  position: relative;
  background: var(--rule);
  cursor: col-resize;
  touch-action: none;
}
.divider span { position: absolute; inset: 0 -7px; display: block; }
.divider::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 3px; height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 2px;
  background: var(--slate);
  opacity: .3;
}
.divider:hover::after, .divider:focus-visible::after { opacity: .7; }

/* ── Rendered document ───────────────────────────────────────────────── */

.rendered { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; }

.rendered > :first-child { margin-top: 0; }
.rendered h1, .rendered h2, .rendered h3,
.rendered h4, .rendered h5, .rendered h6 {
  margin: 1.1em 0 .4em;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.rendered h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 400; }
.rendered h2 { font-size: 25px; }
.rendered h3 { font-size: 20px; }
.rendered h4, .rendered h5, .rendered h6 { font-size: 17px; }

.rendered p { margin: 0 0 .9em; }
.rendered strong { font-weight: 600; }
.rendered em { font-style: italic; }
.rendered a { color: var(--indigo); text-underline-offset: 2px; }

.rendered ul, .rendered ol { margin: 0 0 1em; padding-left: 1.2em; }
.rendered li { margin-bottom: .25em; }
.rendered li::marker { color: var(--indigo); }

.rendered li.task { list-style: none; margin-left: -1.2em; display: flex; gap: .55em; }
.rendered li.task input { margin-top: .42em; accent-color: var(--indigo); cursor: pointer; }

.rendered code {
  font-family: var(--mono);
  font-size: .82em;
  padding: .12em .38em;
  border-radius: 4px;
  background: var(--paper-alt);
}

.rendered pre.code {
  margin: 0 0 1em;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--paper-alt);
  overflow-x: auto;
}
.rendered pre.code code {
  padding: 0;
  background: none;
  font-size: 12.5px;
  line-height: 1.7;
}

.rendered blockquote {
  margin: 0 0 1em;
  padding-left: 15px;
  border-left: 2px solid var(--indigo);
  color: var(--slate);
  font-style: italic;
}

.rendered hr {
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.rendered table {
  width: 100%;
  margin: 0 0 1em;
  border-collapse: collapse;
  font-size: .92em;
}
.rendered th, .rendered td {
  padding: 7px 10px;
  border: 1px solid var(--rule);
  text-align: left;
}
.rendered th { background: var(--paper-alt); font-weight: 600; }

/* ── Search overlay (inside the window, like the app) ────────────────── */

.search {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  background: var(--scrim);
}
.search[hidden] { display: none; }

.search-card {
  width: min(430px, calc(100% - 40px));
  align-self: flex-start;
  margin-top: 34px;
  max-height: calc(100% - 68px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--slate);
}
.search-head svg { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; flex: none; }

#searchField {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
}

.search-results {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 5px;
  list-style: none;
  overflow: auto;
}

.search-row {
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.search-row.is-active { background: var(--tint); }
.search-name, .search-path { display: block; font-family: var(--mono); }
.search-name { font-size: 12.5px; font-weight: 500; }
.search-path { font-size: 10.5px; color: var(--slate); }
.search-row.is-active .search-name { color: var(--indigo); }

.search-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--slate);
}

/* ── Download ────────────────────────────────────────────────────────── */

.cta { margin-top: 40px; }

.button {
  display: inline-block;
  padding: 15px 30px;
  border-radius: 9px;
  background: var(--indigo);
  color: #fff;
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
  transition: background .16s ease, transform .16s ease;
}
.button:hover { background: var(--periwinkle); }
.button:active { transform: translateY(1px); }

@media (prefers-color-scheme: dark) {
  .button { color: #0F111A; }
}

.cta-meta {
  margin: 15px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--slate);
}

/* ── Band headings ───────────────────────────────────────────────────── */

.band-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
}
.band-label span {
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: none;
  color: var(--slate);
}

/* ── Shortcuts: each chip fires the real thing in the window above ───── */

.keys { margin-top: 74px; }

.key-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 9px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.key span {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--slate);
}
.key kbd {
  min-width: 46px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--paper-alt);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
}
.key:hover { border-color: var(--indigo); }
.key:hover span { color: var(--ink); }
.key.is-fired {
  background: var(--tint);
  border-color: var(--indigo);
}
.key.is-fired kbd { background: var(--indigo); color: var(--card); }

/* ── Rendered extras that arrive with KaTeX and Mermaid ──────────────── */

.rendered .katex-display { margin: .8em 0 1em; overflow-x: auto; overflow-y: hidden; }
.rendered .mermaid { display: flex; justify-content: center; margin: 0 0 1em; }
.rendered .mermaid svg { max-width: 100%; height: auto; }

/* ── Footer ──────────────────────────────────────────────────────────── */

.footer { margin-top: 70px; border-top: 1px solid var(--rule); }

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 22px;
  padding-bottom: 26px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--slate);
}

/* ── Narrow ──────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .sidebar { display: none; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .wrap { padding: 0 20px; }
  /* Keep the tagline, drop the version: the footer carries it too. */
  .topbar-meta { display: none; }
  .brand { min-width: 0; }
  .brand-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero { padding: 34px 0 0; }
  .win-title { display: none; }
  .body { height: 380px; }

  /* No room for two panes, so the switcher moves between them instead. */
  #app .split { grid-template-columns: 1fr; }
  #app .divider { display: none; }
  #app[data-mode="split"] .pane-source { display: none; }

  .keys { margin-top: 52px; }
  .key { width: 100%; }
  .button { display: block; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
