/* Playground page. Library styles come from styles.css (react-llm-markdown/styles.css). */

:root {
  --fog: #eef0f3;
  --panel: #ffffff;
  --ink: #14161b;
  --graphite: #5a6070;
  --rule: #d6dae1;
  --highlighter: #ffe066;
  --wire: #2f6bff;
  --alert: #e5484d;
  --display: 'Bricolage Grotesque', 'IBM Plex Sans', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* The library's tokens follow the page. */
  --rlm-link: var(--wire);
  --rlm-card: #f6f7f9;
  --rlm-chart-height: 300px;
  --bezel: #14161b;
  color-scheme: light;
}

:root.dark {
  --fog: #0f1115;
  --panel: #171a20;
  --ink: #eceef2;
  --graphite: #9aa1ae;
  --rule: #2a2f38;
  --wire: #7aa2ff;
  --rlm-card: #1d2027;
  --bezel: #3b414d;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--fog);
  color: var(--ink);
  font: 15px/1.6 var(--body);
}

a {
  color: inherit;
}

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

/* ---------- masthead ---------- */

.masthead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 8px 32px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 40px 24px 28px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  transform: translateY(7px);
}

.brand h1 {
  margin: 0;
  font: 800 clamp(28px, 4vw, 44px) / 1 var(--display);
  letter-spacing: -0.03em;
}

.thesis {
  margin: 0;
  max-width: 36ch;
  color: var(--graphite);
  font: 500 clamp(17px, 1.6vw, 21px) / 1.35 var(--display);
}

.thesis mark {
  padding: 0 0.12em;
  background: linear-gradient(var(--highlighter), var(--highlighter)) no-repeat left 60% / 100% 70%;
  color: var(--ink);
  animation: swipe 900ms cubic-bezier(0.65, 0, 0.35, 1) 250ms both;
}

:root.dark .thesis mark {
  color: #14161b;
  background-size: 100% 100%;
}

@keyframes swipe {
  from {
    background-size: 0% 70%;
  }
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 14px;
  font-weight: 500;
}

.links a {
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.links a:hover {
  border-bottom-color: var(--ink);
}

.links .links-docs {
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--highlighter);
  color: #14161b;
}

/* ---------- playground ---------- */

.playground {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.presets,
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

button,
select {
  font: inherit;
  color: inherit;
}

.chip,
.ghost,
.stream {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover,
.ghost:hover {
  border-color: var(--graphite);
}

.chip[aria-pressed='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--fog);
}

.ghost.square {
  width: 34px;
  padding: 0;
}

.stream {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: var(--ink);
  background: var(--highlighter);
  color: #14161b;
  font-weight: 600;
}

.stream .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #14161b;
}

.stream.is-live .dot {
  background: var(--alert);
  animation: pulse 900ms ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.speed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 6px;
  color: var(--graphite);
  font-size: 13px;
}

.speed select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
}

.tabs {
  display: none;
}

.panes {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr) 400px;
  gap: 16px;
  /* Tall enough for the phone to keep a phone's proportions (about 9 : 19.5). */
  height: clamp(860px, calc(100vh - 140px), 1040px);
}

.pane {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.pane-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 8px;
  font: 600 12px/1 var(--body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pane-label span,
.pane-label code {
  color: var(--graphite);
  font: 400 12px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
}

.pane-source textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 16px;
  resize: none;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: 13px/1.6 var(--mono);
  tab-size: 2;
}

.browser {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--panel);
}

.browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule);
}

.browser-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rule);
}

.browser-bar span {
  flex: 1;
  margin-left: 10px;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--fog);
  color: var(--graphite);
  font: 12px var(--mono);
}

.browser-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 40px;
}

.pane-phone {
  align-items: center;
}

.pane-phone .pane-label {
  align-self: stretch;
}

.phone {
  position: relative;
  display: flex;
  width: 380px;
  max-width: 100%;
  flex: 1;
  min-height: 0;
  max-height: 840px;
  flex-direction: column;
  overflow: hidden;
  border: 10px solid var(--bezel);
  border-radius: 46px;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--rule);
}

.phone-status {
  display: flex;
  height: 40px;
  flex: none;
  align-items: center;
  justify-content: center;
  background: var(--panel);
}

.phone-island {
  width: 96px;
  height: 26px;
  border-radius: 20px;
  background: var(--bezel);
}

.note {
  max-width: 380px;
  margin: 10px 0 0;
  color: var(--graphite);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- install ---------- */

.install {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  max-width: 1480px;
  margin: 56px auto 0;
  padding: 28px 24px 0;
  border-top: 1px solid var(--rule);
}

.install h2 {
  margin: 0 0 10px;
  font: 800 20px/1.2 var(--display);
  letter-spacing: -0.01em;
}

.install .rlm-markdown [data-streamdown='code-block'] {
  margin-block: 0 12px;
  border: 1px solid var(--rule);
}

.install {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 0.9fr);
}

.install .rlm-markdown p {
  margin: 0;
  color: var(--graphite);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  max-width: 1480px;
  margin: 40px auto 0;
  padding: 20px 24px 40px;
  color: var(--graphite);
  font-size: 13px;
}

/* ---------- narrow screens: one pane at a time ---------- */

@media (max-width: 1100px) {
  .masthead {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 28px 16px 20px;
  }

  .playground,
  .install,
  .footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* One row of examples that scrolls sideways, edge to edge. */
  .presets {
    flex-wrap: nowrap;
    margin: 0 -16px;
    overflow-x: auto;
    padding: 0 16px 2px;
    scrollbar-width: none;
  }

  .presets::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: none;
  }

  .controls {
    flex-wrap: nowrap;
    width: 100%;
  }

  .stream {
    flex: 1;
    justify-content: center;
  }

  .speed {
    padding-left: 0;
  }

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

  /* The pane switcher stays in reach while the page scrolls. */
  .tabs {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    gap: 4px;
    margin: 0 -16px 12px;
    padding: 8px 16px;
    background: color-mix(in srgb, var(--fog) 92%, transparent);
    backdrop-filter: blur(8px);
  }

  .tabs::after {
    position: absolute;
    right: 16px;
    bottom: 0;
    left: 16px;
    border-bottom: 1px solid var(--rule);
    content: '';
  }

  .tabs button {
    flex: 1;
    height: 36px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--panel);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
  }

  .tabs button[aria-selected='true'] {
    background: var(--ink);
    color: var(--fog);
  }

  .panes {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  /* Panes grow with their content and the page does the scrolling (no scroll inside a scroll). */
  .pane {
    display: none;
    min-height: 60vh;
  }

  .pane-source textarea {
    min-height: 70vh;
    flex: none;
    field-sizing: content;
  }

  .browser-bar {
    display: none;
  }

  .browser,
  .browser-body {
    overflow: visible;
  }

  .browser-body {
    padding: 18px 16px 28px;
  }

  .pane-phone {
    align-items: stretch;
  }

  .device-bare {
    padding: 18px 16px 28px;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: var(--panel);
  }

  .note {
    max-width: none;
  }



  .panes[data-pane='source'] .pane-source,
  .panes[data-pane='web'] .pane-web,
  .panes[data-pane='phone'] .pane-phone {
    display: flex;
  }

  .install {
    grid-template-columns: minmax(0, 1fr);
  }

  .install .rlm-markdown [data-streamdown='code-block-body'] {
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thesis mark,
  .stream.is-live .dot {
    animation: none;
  }
}

/* ---------- documentation ---------- */

.docs-bar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--fog) 92%, transparent);
  backdrop-filter: blur(8px);
}

.docs-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font: 800 19px/1 var(--display);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.docs-brand img {
  border-radius: 8px;
}

.docs-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
  font-weight: 500;
}

.docs-links a {
  color: var(--graphite);
  text-decoration: none;
}

.docs-links a:hover,
.docs-links a[aria-current='page'] {
  color: var(--ink);
}

.docs-links a[aria-current='page'] {
  box-shadow: inset 0 -2px 0 var(--highlighter);
}

.docs {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 210px;
  gap: 56px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
}

.docs-menu-button {
  display: none;
}

.docs-nav {
  border-right: 1px solid var(--rule);
  padding-right: 16px !important;
}

.docs-nav,
.docs-toc {
  position: sticky;
  top: 60px;
  align-self: start;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 28px 0 40px;
}

.docs-nav-title {
  margin: 0 0 8px;
  color: var(--graphite);
  font: 600 11.5px/1 var(--body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-nav ul,
.docs-toc ul {
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.docs-nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--graphite);
  font-size: 14.5px;
  line-height: 1.35;
  text-decoration: none;
  transition: background-color 120ms, color 120ms;
}

.docs-nav a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}

.docs-nav a[aria-current='page'] {
  background: color-mix(in srgb, var(--highlighter) 55%, transparent);
  color: var(--ink);
  font-weight: 600;
}

:root.dark .docs-nav a[aria-current='page'] {
  background: color-mix(in srgb, var(--highlighter) 22%, transparent);
}

.docs-nav-title {
  padding-left: 12px;
}

.docs-toc a {
  display: block;
  padding: 4px 0;
  color: var(--graphite);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}

.docs-toc a:hover {
  color: var(--ink);
}

.docs-toc .sub a {
  padding-left: 12px;
}

.docs-page {
  min-width: 0;
  padding: 36px 0 80px;
  font-size: 16px;
  line-height: 1.7;
}

/* Reading typography for long pages (the library's defaults are tuned for chat). */
.docs-page .rlm-markdown h1 {
  margin: 0 0 18px;
  font: 800 clamp(30px, 4vw, 40px) / 1.1 var(--display);
  letter-spacing: -0.025em;
}

.docs-page .rlm-markdown .doc-heading {
  position: relative;
  scroll-margin-top: 80px;
  font-family: var(--display);
  letter-spacing: -0.015em;
}

.docs-page .rlm-markdown h2.doc-heading {
  margin: 44px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-size: 25px;
  font-weight: 800;
}

.docs-page .rlm-markdown h3.doc-heading {
  margin: 30px 0 8px;
  font-size: 19px;
  font-weight: 700;
}

.doc-anchor {
  margin-left: 8px;
  color: var(--graphite);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
}

.doc-heading:hover .doc-anchor,
.doc-anchor:focus-visible {
  opacity: 1;
}

.docs-page .rlm-markdown p,
.docs-page .rlm-markdown li {
  max-width: 76ch;
}

.docs-page .rlm-markdown :is(ul, ol) {
  margin: 10px 0 14px;
  padding-left: 1.4em;
  list-style-position: outside;
}

.docs-page .rlm-markdown li {
  margin: 4px 0;
  padding-left: 0.2em;
}

.docs-page .rlm-markdown li > p {
  margin: 0;
}

.docs-notice {
  margin: 0 0 20px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--highlighter);
  border-radius: 8px;
  background: var(--panel);
  color: var(--graphite);
  font-size: 14px;
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
}

.lang-switch a {
  padding: 3px 9px;
  border: 0 !important;
  border-radius: 999px;
  color: var(--graphite);
  font: 600 12px/1.4 var(--body);
  text-decoration: none;
}

.lang-switch a[aria-current='true'] {
  background: var(--ink);
  color: var(--fog);
}

.docs-page .rlm-markdown :is(pre, code),
.live .rlm-markdown :is(pre, code),
.install .rlm-markdown :is(pre, code) {
  font-family: var(--mono);
}

.docs-page .rlm-markdown :not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  font: 0.88em var(--mono);
}

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
}

.docs-pager a {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 600;
  text-decoration: none;
}

.docs-pager a:hover {
  border-color: var(--ink);
}

.docs-pager a.next {
  align-items: flex-end;
  text-align: right;
}

.docs-pager small {
  color: var(--graphite);
  font-size: 12px;
  font-weight: 500;
}

.docs-edit {
  margin: 20px 0 0;
  font-size: 13px;
}

.docs-edit a {
  color: var(--graphite);
}

.live {
  margin: 14px 0 22px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--panel);
}

.live-tabs {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--rule);
  background: var(--rlm-card);
}

.live-tabs button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--graphite);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.live-tabs button[aria-selected='true'] {
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--rule);
  color: var(--ink);
}

.live-body {
  padding: 16px 20px;
}

.live-body .rlm-markdown > div > :first-child {
  margin-top: 0;
}

@media (max-width: 1180px) {
  .docs {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .docs-toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .docs-bar {
    gap: 12px;
    padding: 0 16px;
  }

  .docs-brand span {
    display: none;
  }

  .docs-links {
    display: none;
  }

  .docs-bar .lang-switch {
    margin-left: auto;
  }

  .docs {
    display: block;
    padding: 0 16px;
  }

  /* The page list becomes a menu under the bar. */
  .docs-menu-button {
    position: sticky;
    z-index: 20;
    top: 60px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% + 32px);
    height: 46px;
    margin: 0 -16px;
    padding: 0 16px;
    border: 0;
    border-bottom: 1px solid var(--rule);
    background: var(--fog);
    font-size: 14.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  .docs-nav {
    border-right: 0;
    position: fixed;
    z-index: 19;
    inset: 106px 0 0;
    display: none;
    max-height: none;
    padding: 20px 26px;
    background: var(--fog);
  }

  .docs-nav.is-open {
    display: block;
  }

  .docs-page {
    padding-top: 24px;
    font-size: 15.5px;
  }

  .docs-page [data-streamdown='code-block-body'] {
    font-size: 12.5px;
  }

  .docs-page .rlm-markdown h2.doc-heading {
    margin-top: 32px;
    padding-top: 16px;
    font-size: 22px;
  }

  .docs-pager {
    flex-direction: column;
  }

  .docs-pager a.next {
    align-items: flex-start;
    text-align: left;
  }
}
