:root {
  --ink: #201c19;
  --muted: #716861;
  --paper: #fdfbf8;
  --surface: #ffffff;
  --line: #eadfd8;
  --soft: #fff7f1;
  /* Buttons and badges: white on orange in light mode, dark on light orange in dark mode. */
  --orange: #db5b1f;
  --orange-hover: #b94715;
  --on-orange: #ffffff;
  /* Shared in both modes. */
  --user-bubble: #c4470f;
  /* Text hyperlinks: same as the Open original link in light mode. */
  --link: #db5b1f;
  --user-bubble-text: #ffffff;
  --quote-border: #ad6440;
  /* Text accents adapt: light orange text is unreadable on the cream background. */
  --accent-text: #db5b1f;
  --accent-strong: #b94715;
  --orange-light: #fff1e5;
  --code: #211b18;
  --panel: rgba(255, 255, 255, 0.92);
  --topbar: rgba(253, 251, 248, 0.96);
  --page-glow: rgba(255, 161, 91, 0.22);
  --input-border: #d4ccc6;
  --subtle: #f7f3ef;
  --bubble: #f3f1ee;
  --bubble-border: #e6e1dc;
  --description: #4e4742;
  --note-text: #5b4a40;
  --inline-code: #eee9e5;
  --table-border: #ddd4ce;
  --quote-text: #514943;
  --pre-text: #fff7f2;
  --copy-hover-border: #d7b9a7;
  --error: #8b2d26;
  --error-border: #a13b32;
  --popover: #ffffff;
  --popover-shadow: 0 8px 12px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.62);
  --row-hover: rgba(0, 0, 0, 0.04);
  --row-active: rgba(0, 0, 0, 0.06);
  --radius: 18px;
  --shadow: 0 24px 70px rgba(32, 28, 25, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4eee9;
    --muted: #b8afa8;
    --paper: #171513;
    --surface: #201d1a;
    --line: #3c3530;
    --soft: #241c18;
    --orange: #ff7a32;
    --orange-hover: #ff9a64;
    --on-orange: #1b100a;
    --accent-text: #ff7a32;
    --accent-strong: #ff9a64;
    --link: #ff9a64;
    --orange-light: #2c211b;
    --code: #0f0e0d;
    --panel: rgba(32, 29, 26, 0.94);
    --topbar: rgba(23, 21, 19, 0.96);
    --page-glow: rgba(219, 91, 31, 0.16);
    --input-border: #4a423c;
    --subtle: #292521;
    --bubble: #2a2724;
    --bubble-border: #3e3935;
    --description: #d0c7c0;
    --note-text: #d3c3b8;
    --inline-code: #302b27;
    --table-border: #4a423c;
    --quote-text: #d1c7c0;
    --pre-text: #f5eee9;
    --copy-hover-border: #76513d;
    --error: #ff9a90;
    --error-border: #c65d55;
    --popover: #2b2825;
    --popover-shadow: 0 8px 12px rgba(0, 0, 0, 0.45), 0 0 1px rgba(255, 255, 255, 0.28);
    --row-hover: rgba(255, 255, 255, 0.06);
    --row-active: rgba(255, 255, 255, 0.1);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  }
}

/* Explicit choice from the theme switcher. Keep identical to the dark block above. */
:root[data-theme="dark"] {
  --ink: #f4eee9;
  --muted: #b8afa8;
  --paper: #171513;
  --surface: #201d1a;
  --line: #3c3530;
  --soft: #241c18;
  --orange: #ff7a32;
  --orange-hover: #ff9a64;
  --on-orange: #1b100a;
  --accent-text: #ff7a32;
  --accent-strong: #ff9a64;
  --link: #ff9a64;
  --orange-light: #2c211b;
  --code: #0f0e0d;
  --panel: rgba(32, 29, 26, 0.94);
  --topbar: rgba(23, 21, 19, 0.96);
  --page-glow: rgba(219, 91, 31, 0.16);
  --input-border: #4a423c;
  --subtle: #292521;
  --bubble: #2a2724;
  --bubble-border: #3e3935;
  --description: #d0c7c0;
  --note-text: #d3c3b8;
  --inline-code: #302b27;
  --table-border: #4a423c;
  --quote-text: #d1c7c0;
  --pre-text: #f5eee9;
  --copy-hover-border: #76513d;
  --error: #ff9a90;
  --error-border: #c65d55;
  --popover: #2b2825;
  --popover-shadow: 0 8px 12px rgba(0, 0, 0, 0.45), 0 0 1px rgba(255, 255, 255, 0.28);
  --row-hover: rgba(255, 255, 255, 0.06);
  --row-active: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

html {
  color-scheme: light dark;
  scroll-behavior: auto !important;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, var(--page-glow), transparent 31rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-anchor: none;
}

a { color: inherit; }

.home-shell,
.error-shell {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  padding: 56px 24px 32px;
}

.home-card,
.error-card {
  width: min(100%, 780px);
  padding: clamp(28px, 6vw, 64px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand-large { font-size: 1.15rem; }

.brand-mark {
  position: relative;
  display: grid;
  width: 46px;
  height: 33px;
  place-items: center;
  border-radius: 12px;
  background: var(--orange);
  color: var(--on-orange);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  box-shadow: 0 5px 14px rgba(219, 91, 31, 0.18);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: -9px;
  width: 15px;
  height: 12px;
  background: var(--orange);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.hero-copy { margin: clamp(52px, 9vw, 92px) 0 40px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.home-title { font-size: clamp(1.9rem, 4vw, 3rem); }
.home-title span { display: block; white-space: nowrap; }

.lede {
  max-width: 610px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.22rem);
}

.share-form label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.82rem;
  font-weight: 750;
}

.form-row { display: flex; gap: 10px; }
.input-wrap { position: relative; min-width: 0; flex: 1; }
.input-wrap input { width: 100%; padding-right: 82px; }

input,
button,
.button-link { font: inherit; }

input {
  min-width: 0;
  flex: 1;
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}

input:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 4px rgba(219, 91, 31, 0.12);
}

input[aria-invalid="true"] { border-color: var(--error-border); }

button,
.button-link {
  display: inline-flex;
  height: 54px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--orange);
  color: var(--on-orange);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button-link:hover { background: var(--orange-hover); }

.paste-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: auto;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--subtle);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
}

.paste-button:hover { background: var(--orange-light); color: var(--accent-strong); }

button:focus-visible,
.button-link:focus-visible,
a:focus-visible { outline: 3px solid #f09b62; outline-offset: 3px; }

.form-help,
.form-error {
  margin: 12px 2px 0;
  font-size: 0.83rem;
}

.form-help { color: var(--muted); }
.form-error { color: var(--error); font-weight: 650; }
.domain-sft { color: var(--accent-text); font-weight: 900; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 42px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.privacy-note p { margin: 0; }
.privacy-icon { color: var(--accent-text); font-size: 0.52rem; }
.site-footer { padding: 22px; color: var(--muted); text-align: center; font-size: 0.75rem; }
.site-footer p { margin: 0; }
.site-footer p + p { margin-top: 4px; }
.site-footer a { color: var(--accent-text); font-weight: 800; letter-spacing: 0.04em; text-underline-offset: 2px; }

/* Conversation page chrome: brand row plus a slim usage strip that reads as part
   of the app header rather than as part of the transcript. */
.topbar {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
}

.topbar-inner {
  width: min(100% - 40px, 1100px);
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.original-link { color: var(--accent-text); font-size: 0.86rem; font-weight: 700; text-decoration: none; }
.original-link:hover { text-decoration: underline; }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.theme-toggle {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

.theme-toggle:hover { background: var(--subtle); color: var(--accent-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
}

.topbar-tip {
  border-top: 1px solid var(--line);
  background: var(--subtle);
}

.topbar-tip p {
  width: min(100% - 40px, 1100px);
  margin: 0 auto;
  padding: 9px 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.topbar-tip strong { color: var(--ink); font-weight: 700; }
.topbar-tip strong:first-child {
  margin-right: 4px;
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.topbar-tip a { color: var(--link); font-weight: 800; text-underline-offset: 2px; }

.conversation-shell {
  width: min(100% - 40px, 760px);
  margin: 0 auto;
  padding: clamp(40px, 6vw, 64px) 0 72px;
}

.conversation-heading {
  width: min(100%, 760px);
  padding-bottom: 38px;
  border-bottom: 1px solid var(--line);
}

.conversation-heading h1 {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.conversation-date { margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; }

.usage-note {
  max-width: 700px;
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--orange);
  border-radius: 0 10px 10px 0;
  background: var(--orange-light);
  color: var(--note-text);
  font-size: 0.84rem;
}

.usage-note a,
.conversation-footer a,
.secondary-link { color: var(--link); font-weight: 800; text-underline-offset: 2px; }

.conversation-layout {
  width: min(100%, 760px);
  margin-top: 16px;
}

.transcript { min-width: 0; margin: 0; padding: 0; list-style: none; }

.message {
  position: relative;
  padding: 28px 0;
  scroll-margin-top: 86px;
}

.message-body { min-width: 0; }
.message-user { display: flex; justify-content: flex-end; }
.message-user .message-body { display: flex; max-width: 70%; flex-direction: column; align-items: flex-end; }
.message-assistant { background: transparent; }

.user-bubble {
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--user-bubble);
  color: var(--user-bubble-text);
}

.user-bubble .message-content a { color: inherit; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.chatgpt-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  background: var(--orange);
  color: var(--on-orange);
  font-size: 0.58rem;
  letter-spacing: 0.02em;
}

.message-content { overflow-wrap: anywhere; }
/* User turns are verbatim text (like chatgpt.com): keep line breaks and spacing. */
.message-content-plain { white-space: pre-wrap; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p, .message-content ul, .message-content ol, .message-content blockquote { margin: 0 0 1em; }
.message-content h1, .message-content h2, .message-content h3 { margin: 1.5em 0 0.55em; font-size: 1.2rem; line-height: 1.25; letter-spacing: -0.02em; }
.message-content ul, .message-content ol { padding-left: 1.4em; }
.message-content a { color: var(--accent-text); text-underline-offset: 2px; }
.message-content blockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid var(--quote-border); color: var(--quote-text); }
.message-content code { padding: 0.15em 0.35em; border-radius: 5px; background: var(--inline-code); font: 0.88em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.message-content pre { max-width: 100%; overflow-x: auto; padding: 18px; border-radius: 12px; background: var(--code); color: var(--pre-text); line-height: 1.55; }
.message-content pre code { padding: 0; background: transparent; color: inherit; }
.message-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.message-content th, .message-content td { padding: 8px 12px; border: 1px solid var(--table-border); text-align: left; }
.image-placeholder { color: var(--muted); font-style: italic; }

/* Copy action: revealed on hover/focus for pointer devices, always visible on touch
   and small screens (see media queries below). */
.message-actions {
  display: flex;
  min-height: 34px;
  align-items: center;
  margin-top: 7px;
  opacity: 0;
  transition: opacity 130ms ease;
}

.message-user .message-actions { justify-content: flex-end; }
.message:hover .message-actions,
.message:focus-within .message-actions,
.message.is-options-visible .message-actions { opacity: 1; }

.copy-button {
  width: auto;
  height: 32px;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  pointer-events: none;
}

.copy-button:hover { border-color: var(--copy-hover-border); background: var(--orange-light); color: var(--accent-strong); }
.message:hover .copy-button,
.message:focus-within .copy-button,
.message.is-options-visible .copy-button { pointer-events: auto; }

/* Conversation contents (mirrors the ChatGPT share page): a fixed column of bars
   on the right edge; hovering it slides in a popover listing every prompt. */
.conversation-toc {
  position: fixed;
  top: 50%;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  transform: translateY(-50%);
}

.toc-bars {
  display: flex;
  width: 36px;
  max-height: 50vh;
  max-height: 50lvh;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  overflow: hidden;
}

.toc-bar {
  display: block;
  width: 18px;
  height: 2px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.5;
  transition: background-color 130ms ease, opacity 130ms ease;
}

.toc-bar:hover { background: var(--muted); opacity: 0.9; }
.toc-bar.is-active { background: var(--accent-text); opacity: 1; }

.toc-popover {
  position: absolute;
  top: 50%;
  right: 0;
  z-index: 1;
  min-width: 240px;
  max-width: min(340px, calc(100vw - 32px));
  padding: 6px 0;
  border-radius: 16px;
  background: var(--popover);
  box-shadow: var(--popover-shadow);
  /* Hidden via opacity (not visibility) so keyboard focus can still land on a row
     and reveal the list through :focus-within. */
  opacity: 0;
  pointer-events: none;
  transform: translate(8px, -50%);
  transition:
    opacity 160ms cubic-bezier(0.33, 1, 0.68, 1),
    transform 160ms cubic-bezier(0.33, 1, 0.68, 1);
}

.conversation-toc:hover .toc-popover,
.conversation-toc:focus-within .toc-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.toc-list {
  position: relative;
  display: flex;
  max-height: 50vh;
  max-height: 50lvh;
  flex-direction: column;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.toc-list a {
  display: block;
  margin: 0 6px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-list a:hover { background: var(--row-hover); }
.toc-list a[aria-current="true"] { background: var(--row-active); }
.toc-list a:focus-visible { outline-offset: -3px; }

.share-again {
  width: min(100%, 760px);
  margin-top: 50px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.share-again h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.2; letter-spacing: -0.035em; }
.share-again-links { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.secondary-link { text-decoration: none; }
.secondary-link:hover { text-decoration: underline; }

.conversation-footer {
  width: min(100% - 40px, 1100px);
  margin: 0 auto;
  padding: 0 0 42px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.conversation-footer p { margin: 0; }
.conversation-footer p + p { margin-top: 4px; }

.error-card .card-head { margin-bottom: 64px; }
.error-card h1 { max-width: 620px; font-size: clamp(2rem, 5vw, 3.5rem); }
.error-card > p:not(.eyebrow) { margin: 20px 0 28px; color: var(--muted); }
.error-card .button-link { width: max-content; }

/* Touch devices cannot hover: keep the copy button visible at all times. */
@media (hover: none) {
  .message-actions { opacity: 1; transition: none; }
  .copy-button { height: 36px; pointer-events: auto; }
}

@media (max-width: 1023px) {
  .conversation-toc { display: none; }
}

@media (max-width: 650px) {
  .home-shell, .error-shell { padding: 18px 14px; align-items: start; }
  .home-card, .error-card { padding: 28px 20px; border-radius: 20px; }
  .hero-copy { margin: 56px 0 34px; }
  .form-row { flex-direction: column; }
  .submit-button, .button-link { width: 100%; }
  .home-title span { display: inline; white-space: normal; }
  .privacy-note { margin-top: 34px; }
  .topbar-inner, .conversation-shell, .conversation-footer, .topbar-tip p { width: min(100% - 28px, 1100px); }
  .topbar-inner { min-height: 62px; }
  .topbar-tip p { padding: 8px 0; font-size: 0.76rem; }
  .brand-mark { width: 42px; height: 31px; }
  .original-link { font-size: 0; }
  .original-link span { font-size: 1.1rem; }
  .conversation-shell { padding-top: 32px; }
  .conversation-heading { padding-bottom: 28px; }
  .conversation-heading h1 { font-size: clamp(1.7rem, 8vw, 2.3rem); }
  .usage-note { font-size: 0.8rem; }
  .conversation-layout { margin-top: 10px; }
  .message { padding: 24px 0; }
  .message-user .message-body { max-width: 85%; }
  .message-actions { opacity: 1; transition: none; }
  .copy-button { height: 36px; pointer-events: auto; }
  .share-again { margin-top: 34px; padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .toc-popover { transition: none; }
}
