:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #56627a;
  --soft-muted: #6d7890;
  --canvas: #eef1f6;
  --surface: #ffffff;
  --surface-alt: #f7f8fb;
  --surface-raised: #ffffff;
  --header: #111b31;
  --header-ink: #f8faff;
  --header-muted: #b9c5dc;
  --border: #cbd3df;
  --strong-border: #aab5c7;
  --accent: #155eef;
  --accent-hover: #0b4fc7;
  --accent-soft: #e8efff;
  --accent-ink: #0a419f;
  --success: #087a55;
  --success-soft: #def7ec;
  --error: #b42318;
  --error-soft: #fee9e7;
  --warning: #7a4f01;
  --warning-soft: #fff1cc;
  --code-bg: #182136;
  --code-ink: #f2f5ff;
  --focus: #0b63ce;
  --selection: #c9dbff;
  --shadow: 0 12px 36px rgb(20 31 55 / 0.12);
  --editor-font: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --ui-font: Inter, "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf2ff;
  --muted: #b5c0d6;
  --soft-muted: #9ca9c2;
  --canvas: #0b1120;
  --surface: #11192a;
  --surface-alt: #172137;
  --surface-raised: #1a253b;
  --header: #080d18;
  --header-ink: #f8faff;
  --header-muted: #b9c5dc;
  --border: #3e4b63;
  --strong-border: #5b6983;
  --accent: #79a6ff;
  --accent-hover: #a6c3ff;
  --accent-soft: #1a3564;
  --accent-ink: #c7d8ff;
  --success: #62d6ac;
  --success-soft: #123d35;
  --error: #ff8b82;
  --error-soft: #4a2426;
  --warning: #f1c667;
  --warning-soft: #453719;
  --code-bg: #070b13;
  --code-ink: #f2f5ff;
  --focus: #8bb4ff;
  --selection: #274b86;
  --shadow: 0 12px 36px rgb(0 0 0 / 0.34);
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--ui-font);
  background: var(--canvas);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled),
summary {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex="0"]:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: 12px 16px;
  border-radius: 8px;
  color: #ffffff;
  background: #0b4fc7;
  transform: translateY(-160%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
}

.app-header {
  position: relative;
  z-index: 5;
  display: flex;
  min-height: 72px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px clamp(16px, 2.5vw, 32px);
  border-bottom: 1px solid #273550;
  color: var(--header-ink);
  background:
    radial-gradient(circle at 72% -70%, rgb(64 113 221 / 0.55), transparent 35%),
    var(--header);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 10px;
  color: #ffffff;
  background: #155eef;
  font-family: var(--editor-font);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -2px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2);
}

.brand-mark span {
  color: #a9c4ff;
}

.brand > div {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(14px, 1.35vw, 18px);
  line-height: 1.25;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.brand p {
  margin: 3px 0 0;
  color: var(--header-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-note {
  margin: 0 10px 0 0;
  color: var(--header-muted);
  font-size: 12px;
  white-space: nowrap;
}

.privacy-note span {
  margin-right: 5px;
  color: #5fdbad;
  font-size: 9px;
}

.quiet-button,
.icon-button,
.support-link {
  min-height: 44px;
  border: 1px solid #43516c;
  border-radius: 8px;
  color: var(--header-ink);
  background: rgb(255 255 255 / 0.06);
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 21px;
}

.support-link {
  display: inline-flex;
  min-width: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.support-link > span[aria-hidden="true"] {
  font-size: 19px;
  line-height: 1;
}

.quiet-button:hover,
.icon-button:hover,
.support-link:hover {
  border-color: #7282a0;
  background: rgb(255 255 255 / 0.12);
}

.app-main {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.workspace {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.pane {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
}

.editor-pane {
  border-right: 1px solid var(--strong-border);
}

.pane-header {
  display: flex;
  min-height: 50px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px 6px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}

.pane-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.pane-heading h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.pane-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.editor-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.preview-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.live-label {
  color: var(--muted);
  font-size: 11px;
}

.live-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.live-label > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.copy-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.pane-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.pane-tool-button {
  width: 36px;
  justify-content: center;
  padding-inline: 0;
}

.pane-tool-button .button-label {
  display: none;
}

.copy-button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.copy-button.is-active {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.format-hint-icon {
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
}

.copy-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.copy-button.is-copied {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.format-toolbar {
  display: flex;
  min-height: 46px;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  scrollbar-width: thin;
}

.format-toolbar[hidden] {
  display: none;
}

.format-toolbar button {
  display: inline-grid;
  min-width: 36px;
  min-height: 36px;
  flex: 0 0 auto;
  place-items: center;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-family: var(--editor-font);
  font-size: 13px;
}

.format-toolbar button:hover,
.format-toolbar button.is-active {
  border-color: var(--border);
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.format-toolbar .sync-button {
  display: inline-flex;
  width: auto;
  gap: 5px;
  font-family: var(--ui-font);
  font-size: 11px;
}

.toolbar-separator {
  width: 1px;
  height: 22px;
  flex: 0 0 auto;
  margin: 0 3px;
  background: var(--border);
}

.toolbar-spacer {
  flex: 1 0 10px;
}

.editor-shell {
  position: relative;
  min-height: 180px;
  flex: 1;
  overflow: hidden;
  background: var(--surface);
}

.line-numbers {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 54px;
  overflow: hidden;
  border-right: 1px solid var(--border);
  color: var(--soft-muted);
  background: var(--surface-alt);
  font-family: var(--editor-font);
  font-size: 13px;
  line-height: 1.7;
  text-align: right;
  user-select: none;
}

#line-number-content {
  padding: 18px 10px 80px 4px;
  will-change: transform;
}

#line-number-content > span {
  display: block;
  height: 1.7em;
  padding-right: 4px;
  border-right: 2px solid transparent;
}

#line-number-content > span.is-active {
  color: var(--ink);
  font-weight: 700;
}

#line-number-content > span.has-error {
  border-right-color: var(--error);
  color: var(--error);
  background: var(--error-soft);
  font-weight: 800;
}

#line-number-content > span.has-warning:not(.has-error) {
  border-right-color: var(--warning);
  color: var(--warning);
  background: var(--warning-soft);
  font-weight: 800;
}

#markdown-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 18px 22px 80px 70px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  outline-offset: -4px;
  color: var(--ink);
  caret-color: var(--accent);
  background: transparent;
  font-family: var(--editor-font);
  font-size: 14px;
  font-variant-ligatures: none;
  line-height: 1.7;
  tab-size: 2;
  resize: none;
  white-space: pre;
}

.search-panel {
  position: absolute;
  z-index: 4;
  top: 8px;
  right: 12px;
  width: min(430px, calc(100% - 82px));
  padding: 7px;
  border: 1px solid var(--strong-border);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.search-row,
.replace-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.replace-row {
  margin-top: 6px;
}

.search-panel input {
  min-width: 60px;
  min-height: 36px;
  flex: 1;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
}

.search-panel output {
  min-width: 50px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.search-panel button {
  min-width: 36px;
  min-height: 36px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-alt);
}

.status-bar,
.preview-footer {
  display: flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 4px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 11px;
}

#validation-status {
  min-height: 24px;
  padding: 1px 4px;
  border: 0;
  color: var(--success);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}

#validation-status.has-error {
  color: var(--error);
}

#validation-status.has-warning {
  color: var(--warning);
}

.preview-scroll {
  min-height: 180px;
  flex: 1;
  overflow: auto;
  scroll-behavior: auto;
}

.markdown-body {
  width: min(100%, 860px);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) clamp(22px, 6vw, 72px) 100px;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.82;
}

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

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.7em 0 0.65em;
  color: var(--ink);
  line-height: 1.3;
  scroll-margin-top: 16px;
}

.markdown-body h1 {
  padding-bottom: 0.42em;
  border-bottom: 2px solid var(--border);
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.025em;
}

.markdown-body h2 {
  position: relative;
  padding-left: 14px;
  font-size: clamp(21px, 3vw, 27px);
}

.markdown-body h2::before {
  position: absolute;
  top: 0.1em;
  bottom: 0.1em;
  left: 0;
  width: 4px;
  border-radius: 4px;
  background: var(--accent);
  content: "";
}

.markdown-body h3 {
  font-size: 19px;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  position: relative;
  padding-inline-start: 1.25em;
}

.markdown-body h3::before,
.markdown-body h4::before,
.markdown-body h5::before,
.markdown-body h6::before {
  position: absolute;
  inset-inline-start: 0.12em;
  box-sizing: border-box;
  border: 2px solid var(--accent);
  content: "";
}

.markdown-body h3::before {
  top: 0.38em;
  width: 0.56em;
  height: 0.56em;
  border-radius: 50%;
  background: var(--accent);
}

.markdown-body h4::before {
  top: 0.43em;
  width: 0.52em;
  height: 0.52em;
  transform: rotate(45deg);
}

.markdown-body h5::before {
  top: 0.6em;
  width: 0.68em;
  height: 0.24em;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
}

.markdown-body h6::before {
  top: 0.47em;
  width: 0.44em;
  height: 0.44em;
  border-radius: 50%;
}

.markdown-body a {
  border-bottom: 1px solid currentColor;
  color: var(--accent-ink);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.markdown-body a:hover {
  color: var(--accent-hover);
}

.markdown-body blockquote {
  margin: 1.5em 0;
  padding: 13px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  background: var(--accent-soft);
}

.markdown-body blockquote > :first-child,
.markdown-body li > :first-child {
  margin-top: 0;
}

.markdown-body blockquote > :last-child,
.markdown-body li > :last-child {
  margin-bottom: 0;
}

.markdown-body code,
.markdown-body kbd {
  padding: 0.16em 0.42em;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-family: var(--editor-font);
  font-size: 0.9em;
}

.markdown-body pre {
  position: relative;
  margin: 1.5em 0;
  padding: 18px 20px;
  overflow: auto;
  border: 1px solid #33415d;
  border-radius: 10px;
  color: var(--code-ink);
  background: var(--code-bg);
  line-height: 1.65;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
}

.markdown-body table {
  display: block;
  width: 100%;
  margin: 1.5em 0;
  overflow-x: auto;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  min-width: 110px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body th {
  background: var(--surface-alt);
  font-weight: 750;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5em auto;
  border-radius: 8px;
}

.blocked-image {
  display: grid;
  min-height: 120px;
  place-items: center;
  gap: 6px;
  margin: 1.5em 0;
  padding: 20px;
  border: 2px dashed var(--strong-border);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-alt);
  text-align: center;
}

.blocked-image strong {
  color: var(--ink);
  font-size: 13px;
}

.blocked-image > span {
  font-size: 12px;
}

.markdown-body hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid var(--strong-border);
}

.markdown-body li + li {
  margin-top: 0.3em;
}

.markdown-body input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0 0.45em 0 0;
  vertical-align: -3px;
  accent-color: var(--accent);
}

.preview-footer {
  justify-content: space-between;
}

.preview-security {
  display: flex;
  align-items: center;
  gap: 10px;
}

.privacy-control {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--strong-border);
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
}

.privacy-control[aria-pressed="true"] {
  color: var(--warning);
  background: var(--warning-soft);
}

.mobile-jump {
  display: none;
  min-height: 30px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  text-underline-offset: 2px;
}

.problems {
  flex: 0 0 auto;
  max-height: 190px;
  overflow: auto;
  border-top: 1px solid var(--strong-border);
  background: var(--surface-raised);
}

.problems summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 7px 18px;
  list-style: none;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.problems summary::-webkit-details-marker {
  display: none;
}

.problems summary > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.problem-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
}

.problem-summary {
  color: var(--muted);
  font-weight: 500;
}

.problem-list {
  border-top: 1px solid var(--border);
}

.problem-empty {
  margin: 0;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 12px;
}

.problem-item {
  display: grid;
  width: 100%;
  min-height: 42px;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  text-align: left;
}

.problem-item:hover {
  background: var(--surface-alt);
}

.problem-item .severity {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 850;
}

.problem-item.error .severity,
.problem-item.error .problem-location {
  color: var(--error);
}

.problem-item.warning .severity,
.problem-item.warning .problem-location {
  color: var(--warning);
}

.problem-location {
  font-family: var(--editor-font);
  font-size: 11px;
  white-space: nowrap;
}

dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(720px, calc(100dvh - 28px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--strong-border);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: 0 24px 80px rgb(8 13 24 / 0.42);
}

dialog::backdrop {
  background: rgb(8 13 24 / 0.7);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: 24px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-header h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.dialog-close {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 24px;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: minmax(115px, 1fr) auto 14px auto;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 13px;
}

kbd {
  min-width: 32px;
  padding: 5px 8px;
  border: 1px solid var(--strong-border);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: var(--surface-alt);
  font-family: var(--editor-font);
  font-size: 11px;
  text-align: center;
}

.dialog-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12px;
}

#onboarding-dialog {
  width: min(680px, calc(100vw - 28px));
}

.onboarding-card {
  display: flex;
  min-height: min(560px, calc(100dvh - 28px));
  flex-direction: column;
}

.onboarding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.onboarding-header h2 {
  margin: 3px 0 0;
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.25;
}

.onboarding-header > div > p:last-child {
  max-width: 52ch;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.onboarding-content {
  flex: 1;
  padding: 26px 24px;
}

.onboarding-step h3 {
  margin: 4px 0 18px;
  font-size: clamp(20px, 3vw, 24px);
  line-height: 1.35;
}

.onboarding-kicker {
  margin: 0;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.onboarding-list,
.onboarding-numbered-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 1.5em;
  line-height: 1.65;
}

.onboarding-list li::marker,
.onboarding-numbered-list li::marker {
  color: var(--accent-ink);
  font-weight: 850;
}

.onboarding-storage-note,
.onboarding-tip {
  margin: 22px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 13px;
  line-height: 1.65;
}

.onboarding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.onboarding-progress {
  margin: 0;
  color: var(--muted);
  font-family: var(--editor-font);
  font-size: 12px;
  font-weight: 750;
}

.onboarding-actions {
  display: flex;
  gap: 10px;
}

.tutorial-primary,
.tutorial-secondary {
  min-width: 96px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--strong-border);
  border-radius: 8px;
  font-weight: 750;
}

.tutorial-primary {
  border-color: #155eef;
  color: #ffffff;
  background: #155eef;
}

.tutorial-secondary {
  color: var(--ink);
  background: var(--surface-raised);
}

.tutorial-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid #3e4b63;
  border-radius: 9px;
  color: #ffffff;
  background: #111b31;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 30;
  padding: 14px;
  border-radius: 8px;
  color: #ffffff;
  background: #b42318;
  text-align: center;
}

@media (min-width: 840px) {
  body {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
  }
}

@media (max-width: 839px) {
  .app-header {
    position: sticky;
    top: 0;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .editor-pane {
    min-height: 66svh;
    border-right: 0;
    border-bottom: 2px solid var(--strong-border);
  }

  .preview-pane {
    min-height: 60svh;
  }

  .editor-shell,
  .preview-scroll {
    min-height: 390px;
  }

  .problems {
    max-height: none;
  }

  .privacy-note {
    display: none;
  }

  .mobile-jump {
    display: inline-flex;
  }

  .format-toolbar button,
  .privacy-control,
  .mobile-jump {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 560px) {
  .app-header {
    min-height: 64px;
    padding-inline: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand p,
  .header-actions .quiet-button {
    display: none;
  }

  .support-link {
    width: 44px;
    padding: 0;
  }

  .support-link .button-label {
    display: none;
  }

  .pane-header {
    padding-left: 14px;
  }

  .copy-button {
    min-height: 44px;
  }

  .pane-tool-button,
  .pane-header .copy-button {
    width: 44px;
    justify-content: center;
    padding-inline: 0;
  }

  .pane-header .copy-button .button-label {
    display: none;
  }

  .onboarding-header {
    padding: 20px 18px 16px;
  }

  .onboarding-content {
    padding: 22px 18px;
  }

  .onboarding-footer {
    align-items: stretch;
    padding: 14px 18px;
  }

  .onboarding-actions {
    flex: 1;
  }

  .tutorial-primary,
  .tutorial-secondary {
    flex: 1;
    min-width: 0;
  }

  .preview-footer {
    min-height: auto;
    flex-wrap: wrap;
    padding-block: 8px;
  }

  .preview-security {
    width: 100%;
    justify-content: space-between;
  }

  .live-label,
  .format-toolbar .button-label {
    display: none;
  }

  .line-numbers {
    width: 45px;
  }

  #line-number-content {
    padding-right: 7px;
  }

  #markdown-input {
    padding-left: 58px;
    padding-right: 14px;
    font-size: 13px;
  }

  .markdown-body {
    padding: 30px 20px 70px;
  }

  .status-bar {
    justify-content: space-between;
    gap: 8px;
  }

  #document-status {
    display: none;
  }

  .problem-summary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .problem-item {
    grid-template-columns: 20px 1fr;
  }

  .problem-location {
    grid-column: 2;
  }

  .shortcut-grid {
    grid-template-columns: minmax(100px, 1fr) auto 10px auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .pane-dot,
  .live-label > span,
  .privacy-note span {
    border: 1px solid CanvasText;
  }

  #line-number-content > span.has-error,
  #line-number-content > span.has-warning {
    border-right-width: 4px;
  }
}

/* Cross-dialect Markdown rendering: GitHub alerts/footnotes, definition lists, and math. */
.markdown-body .md-alert {
  border-left-width: 5px;
}

.markdown-body .md-alert-title {
  margin: 0 0 0.45em;
  color: var(--ink);
  font-size: 0.92em;
  font-weight: 800;
}

.markdown-body .md-alert-note {
  border-left-color: var(--accent);
}

.markdown-body .md-alert-tip {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.markdown-body .md-alert-important {
  border-left-color: #7443b8;
  background: #f3eaff;
}

:root[data-theme="dark"] .markdown-body .md-alert-important {
  border-left-color: #c5a0ff;
  background: #30224a;
}

.markdown-body .md-alert-warning {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.markdown-body .md-alert-caution {
  border-left-color: var(--error);
  background: var(--error-soft);
}

.markdown-body .md-definition-list {
  margin: 1.5em 0;
}

.markdown-body .md-definition-list dt {
  color: var(--ink);
  font-weight: 800;
}

.markdown-body .md-definition-list dd {
  margin: 0.35em 0 1em 1.25em;
  padding-left: 0.9em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.markdown-body .md-footnote-ref {
  margin-inline: 0.08em;
  font-size: 0.78em;
  line-height: 1;
}

.markdown-body .md-footnotes {
  margin-top: 3em;
  color: var(--muted);
  font-size: 0.88em;
}

.markdown-body .md-footnotes hr {
  width: 30%;
  margin-right: auto;
  margin-left: 0;
}

.markdown-body .md-footnotes li:target,
.markdown-body .md-footnote-ref a:target {
  border-radius: 4px;
  background: var(--warning-soft);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.markdown-body .md-footnote-backref {
  display: inline-block;
  margin-left: 0.45em;
  padding-inline: 0.25em;
  border-bottom: 0;
  font-weight: 800;
}

.markdown-body .katex-display {
  max-width: 100%;
  margin: 1.5em 0;
  padding: 0.5em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.markdown-body .katex-error {
  color: var(--error) !important;
}

@media (forced-colors: active) {
  .markdown-body .md-alert {
    border-left-color: CanvasText;
  }

  .markdown-body h3::before,
  .markdown-body h4::before,
  .markdown-body h5::before,
  .markdown-body h6::before {
    border-color: CanvasText;
    background: CanvasText;
  }

  .markdown-body h4::before,
  .markdown-body h6::before {
    background: Canvas;
  }
}

.markdown-body abbr[title] {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.2em;
  cursor: help;
}

/* Terms page */
body.legal-page {
  min-height: 100dvh;
  height: auto;
  overflow: auto;
  background: var(--canvas);
}

.legal-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid #273550;
  color: var(--header-ink);
  background: var(--header);
}

.legal-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.legal-brand > span:last-child {
  display: grid;
  gap: 2px;
}

.legal-brand strong {
  font-size: 17px;
}

.legal-brand small {
  color: var(--header-muted);
  font-size: 12px;
}

.legal-back,
.legal-primary-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid #53627d;
  border-radius: 8px;
  color: #ffffff;
  background: rgb(255 255 255 / 0.08);
  font-size: 13px;
  font-weight: 750;
  text-underline-offset: 3px;
}

.terms-main {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 32px) 72px;
}

.terms-card {
  padding: clamp(24px, 5vw, 58px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.terms-title {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.terms-heading-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.terms-title h1 {
  margin: 4px 0;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 44px);
  letter-spacing: -0.025em;
}

.terms-title > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.draft-badge {
  padding: 4px 9px;
  border: 1px solid var(--warning);
  border-radius: 999px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 12px;
  font-weight: 800;
}

.draft-notice {
  margin: 26px 0;
  padding: 18px 20px;
  border: 1px solid var(--warning);
  border-left-width: 5px;
  border-radius: 8px;
  background: var(--warning-soft);
}

.draft-notice h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 16px;
}

.draft-notice p {
  margin: 0;
  color: var(--ink);
}

.support-principles {
  display: grid;
  gap: 12px;
  padding: 0;
  list-style: none;
}

.support-principles li {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}

.terms-meta {
  display: grid;
  gap: 8px;
  margin: 28px 0 36px;
}

.terms-meta > div {
  display: grid;
  grid-template-columns: minmax(80px, 120px) 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--surface-alt);
}

.terms-meta dt {
  color: var(--muted);
  font-weight: 750;
}

.terms-meta dd {
  margin: 0;
}

.terms-card section {
  margin-top: 36px;
}

.terms-card section h2 {
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  color: var(--ink);
  font-size: clamp(19px, 3vw, 23px);
  line-height: 1.4;
}

.terms-card section p,
.terms-card section li {
  color: var(--ink);
  line-height: 1.9;
}

.terms-card section ol {
  margin: 0;
  padding-left: 1.6em;
}

.terms-card section li + li {
  margin-top: 0.55em;
}

.terms-placeholder {
  color: var(--error);
  font-weight: 800;
}

.terms-end {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.terms-end p {
  margin: 0;
  font-weight: 750;
}

.terms-end .legal-primary-link {
  border-color: var(--accent);
  color: #ffffff;
  background: #155eef;
}

.site-legal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12px;
  text-align: center;
  flex-wrap: wrap;
}

.site-legal-footer a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

@media (max-width: 560px) {
  .legal-header {
    min-height: 64px;
    padding-inline: 12px;
  }

  .legal-brand small {
    display: none;
  }

  .legal-back {
    padding-inline: 10px;
  }

  .terms-card {
    padding: 22px 18px;
    border-radius: 10px;
  }

  .terms-meta > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .terms-end {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  .legal-header,
  .skip-link,
  .terms-end .legal-primary-link {
    display: none;
  }

  body.legal-page,
  .terms-card {
    color: #000000;
    background: #ffffff;
    box-shadow: none;
  }

  .terms-main {
    width: 100%;
    padding: 0;
  }

  .terms-card {
    padding: 0;
    border: 0;
  }
}
