:root {
  color-scheme: light dark;
  --accent: #2f8cff;
  --text: #3b414a;
  --secondary: #66707d;
  --border: #e3e8ef;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --editor-split: 50%;
  --editor-measure: 760px;
  --reader-measure: 760px;
  font-family:
    Manrope,
    -apple-system,
    BlinkMacSystemFont,
    "Helvetica Neue",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.workspace {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

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

#bridge-status[data-state="error"] {
  position: absolute;
  z-index: 10;
  top: 16px;
  left: 50%;
  width: auto;
  height: auto;
  max-width: min(440px, calc(100% - 32px));
  padding: 8px 12px;
  overflow: visible;
  clip: auto;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, #c83e4d 35%, var(--border));
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 10%);
  color: #b73343;
  font:
    12px/1.4 -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  white-space: normal;
}

#vditor {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

#vditor.vditor {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
}

#vditor .vditor-toolbar {
  display: none !important;
}

#vditor .vditor-content {
  display: flex !important;
  height: 100% !important;
  min-height: 0;
  background: var(--surface);
}

#vditor .vditor-sv,
#vditor .vditor-preview {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

#vditor .vditor-sv {
  flex: 0 0 var(--editor-split) !important;
  width: var(--editor-split) !important;
  padding: 36px 36px 96px;
  color: var(--text);
  caret-color: var(--accent);
  font:
    16px/1.72 "SFMono-Regular",
    Menlo,
    Monaco,
    monospace;
  tab-size: 2;
}

#vditor .vditor-preview {
  flex: 1 1 0 !important;
  width: auto !important;
  border-left: 0;
  padding: 36px 44px 96px;
  color: var(--text);
  font:
    17px/1.72 Manrope,
    -apple-system,
    BlinkMacSystemFont,
    "Helvetica Neue",
    sans-serif;
}

.kito-split-resizer {
  position: relative;
  z-index: 2;
  flex: 0 0 9px;
  width: 9px;
  margin: 0 -4px;
  padding: 0;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
}

.kito-split-resizer::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: var(--border);
  content: "";
  transition:
    width 120ms ease,
    background-color 120ms ease;
}

.kito-split-resizer:hover::before,
.kito-split-resizer[data-dragging="true"]::before {
  width: 2px;
  background: var(--accent);
}

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

:root[data-view-mode="editor"] #vditor .vditor-sv,
:root[data-view-mode="reader"] #vditor .vditor-preview {
  display: block !important;
  flex: 1 1 100% !important;
  width: 100% !important;
}

:root[data-view-mode="editor"] #vditor .vditor-sv {
  padding-right: max(48px, calc((100% - var(--editor-measure)) / 2));
  padding-left: max(48px, calc((100% - var(--editor-measure)) / 2));
  font-size: 17px;
  line-height: 1.76;
}

:root[data-view-mode="editor"] #vditor .vditor-preview,
:root[data-view-mode="reader"] #vditor .vditor-sv,
:root[data-view-mode="editor"] .kito-split-resizer,
:root[data-view-mode="reader"] .kito-split-resizer {
  display: none !important;
}

:root[data-view-mode="reader"] #vditor .vditor-preview {
  padding-right: max(48px, calc((100% - var(--reader-measure)) / 2));
  padding-left: max(48px, calc((100% - var(--reader-measure)) / 2));
  font-size: 18px;
  line-height: 1.76;
}

#vditor .vditor-reset {
  color: var(--text);
}

#vditor .vditor-preview .vditor-reset {
  letter-spacing: -0.008em;
}

#vditor .vditor-preview .vditor-reset p,
#vditor .vditor-preview .vditor-reset ul,
#vditor .vditor-preview .vditor-reset ol,
#vditor .vditor-preview .vditor-reset blockquote,
#vditor .vditor-preview .vditor-reset pre,
#vditor .vditor-preview .vditor-reset table {
  margin-top: 0;
  margin-bottom: 1.25em;
}

#vditor .vditor-preview .vditor-reset h1,
#vditor .vditor-preview .vditor-reset h2,
#vditor .vditor-preview .vditor-reset h3,
#vditor .vditor-preview .vditor-reset h4,
#vditor .vditor-preview .vditor-reset h5,
#vditor .vditor-preview .vditor-reset h6 {
  margin: 1.8em 0 0.65em;
  color: var(--text);
  font-family:
    Manrope,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-weight: 680;
  letter-spacing: -0.028em;
  line-height: 1.22;
}

#vditor .vditor-preview .vditor-reset h1 {
  font-size: 2em;
}

#vditor .vditor-preview .vditor-reset h2 {
  padding-bottom: 0.32em;
  border-bottom: 1px solid var(--border);
  font-size: 1.5em;
}

#vditor .vditor-preview .vditor-reset h3 {
  font-size: 1.22em;
}

#vditor .vditor-preview .vditor-reset a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

#vditor .vditor-preview .vditor-reset blockquote {
  padding: 0.1em 0 0.1em 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--secondary);
}

#vditor .vditor-preview .vditor-reset code:not(pre code) {
  padding: 0.12em 0.32em;
  border-radius: 3px;
  background: var(--surface-soft);
  font-size: 0.88em;
}

#vditor .vditor-preview .vditor-reset pre {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-soft);
}

#vditor .vditor-preview .vditor-reset table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}

#vditor .vditor-preview .vditor-reset th,
#vditor .vditor-preview .vditor-reset td {
  padding: 0.55em 0.7em;
  border: 1px solid var(--border);
  text-align: left;
}

#vditor .vditor-preview .vditor-reset th {
  background: var(--surface-soft);
  font-weight: 650;
}

#vditor .vditor-preview .vditor-reset hr {
  height: 1px;
  margin: 2.5em 0;
  border: 0;
  background: var(--border);
}

#vditor .vditor-reset > :first-child {
  margin-top: 0;
}

#vditor .vditor-reset > :last-child {
  margin-bottom: 0;
}

#vditor .kito-plain-fallback {
  white-space: pre-wrap;
}

#vditor .vditor-sv:focus {
  outline: 0;
}

#vditor .vditor-sv::selection,
#vditor .vditor-sv *::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

#vditor[data-bridge-enabled="false"] {
  cursor: progress;
}

:root[data-appearance="dark"] {
  --text: #eef1f5;
  --secondary: #a6aebb;
  --border: #2b323c;
  --surface: #14191f;
  --surface-soft: #191f27;
}

:root[data-appearance="dark"] #bridge-status[data-state="error"] {
  color: #ff9eaa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-appearance]),
  :root[data-appearance="system"] {
    --text: #eef1f5;
    --secondary: #a6aebb;
    --border: #2b323c;
    --surface: #14191f;
    --surface-soft: #191f27;
  }

  :root:not([data-appearance]) #bridge-status[data-state="error"],
  :root[data-appearance="system"] #bridge-status[data-state="error"] {
    color: #ff9eaa;
  }
}

@media print {
  :root,
  :root[data-appearance="dark"],
  :root[data-appearance="system"] {
    color-scheme: light;
    --text: #111;
    --secondary: #444;
    --border: #ccc;
    --surface: #fff;
    --surface-soft: #f5f5f5;
  }

  html,
  body,
  #vditor,
  #vditor .vditor-content {
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  #bridge-status,
  #vditor .vditor-toolbar,
  #vditor .vditor-sv,
  #vditor .kito-split-resizer {
    display: none !important;
  }

  #vditor .vditor-preview {
    display: block !important;
    flex: none !important;
    width: 100% !important;
    padding: 0 !important;
    overflow: visible !important;
    color: #111 !important;
    background: #fff !important;
    font-size: 12pt;
    line-height: 1.55;
  }

  #vditor .vditor-preview .vditor-reset pre {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }

  #vditor .vditor-preview .vditor-reset table {
    table-layout: fixed;
    overflow-wrap: anywhere;
  }

  #vditor .vditor-preview .vditor-reset img {
    max-width: 100%;
    height: auto;
  }
}
