@font-face { font-family: "Switzer"; src: url("/_/a/fonts/switzer.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/_/a/fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #fafafa; --fg: #111214; --muted: #6b6f76; --faint: #a3a7ae; --line: #e4e5e8;
  --panel: #ffffff; --soft: #f1f2f4; --accent: #2f6bff; --danger: #d0362c;
  --syn-key: #7a3fd1; --syn-str: #1f7a4d; --syn-num: #b45309; --syn-fn: #2f6bff; --syn-type: #0e7490;
  --c1: #2f6bff; --c2: #e0457b; --c3: #1f9d6b; --c4: #d97706; --c5: #8b5cf6; --c6: #0891b2; --c7: #dc4a26; --c8: #65a30d;
  --sans: "Switzer", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", "Microsoft YaHei", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0e; --fg: #e9eaec; --muted: #8b9097; --faint: #5a5f67; --line: #1e2024;
    --panel: #111316; --soft: #16181c; --accent: #5b8cff; --danger: #ff6b5e;
    --syn-key: #b392f0; --syn-str: #7fd3a0; --syn-num: #f0b46a; --syn-fn: #7aa6ff; --syn-type: #67d0e0;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0e; --fg: #e9eaec; --muted: #8b9097; --faint: #5a5f67; --line: #1e2024;
  --panel: #111316; --soft: #16181c; --accent: #5b8cff; --danger: #ff6b5e;
  --syn-key: #b392f0; --syn-str: #7fd3a0; --syn-num: #f0b46a; --syn-fn: #7aa6ff; --syn-type: #67d0e0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { height: 100dvh; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--fg); font: 15px/1.7 var(--sans); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

header { display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 44px; border-bottom: 1px solid var(--line); font: 12px/1 var(--mono); color: var(--muted); flex: none; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
header::-webkit-scrollbar { display: none; }
.gap { flex: 1; }
.slug { color: var(--fg); letter-spacing: -0.01em; }
.slug:hover, .tool:hover, .me:hover { color: var(--accent); }
.tool { color: var(--muted); text-decoration: none; }
.tool.on { color: var(--accent); }
.readonly .edit-only { display: none; }
.status { display: inline-flex; align-items: center; gap: 7px; }
#dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
#dot[data-state="live"] { background: #22a565; }
#dot[data-state="readonly"] { background: var(--accent); }
#dot[data-state="offline"] { background: var(--danger); }
.me { display: inline-flex; align-items: center; gap: 7px; }
.me::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: var(--me, var(--accent)); }

main { flex: 1; min-height: 0; }
.cm-editor { height: 100%; background: transparent; }
.cm-editor.cm-focused { outline: none; }
.cm-scroller { font-family: var(--sans) !important; line-height: 1.7 !important; overflow: auto; }
.cm-content { max-width: 760px; margin: 0 auto !important; padding: 56px 20px 40vh !important; caret-color: var(--accent); }
.cm-line { padding: 0 !important; }
.cm-placeholder { color: var(--faint) !important; }
.cm-cursor { border-left: 1.5px solid var(--accent) !important; }
.cm-selectionBackground { background: color-mix(in srgb, var(--accent) 22%, transparent) !important; }

/* markdown, rendered in place */
.ln-h { font-weight: 600; letter-spacing: -0.015em; }
.ln-h1 { font-size: 1.7em; line-height: 1.3; padding-top: 0.5em !important; }
.ln-h2 { font-size: 1.35em; line-height: 1.35; padding-top: 0.45em !important; }
.ln-h3 { font-size: 1.14em; padding-top: 0.3em !important; }
.ln-h4, .ln-h5, .ln-h6 { color: var(--muted); }
.ln-em { font-style: italic; }
.ln-strong { font-weight: 650; }
.ln-strike { text-decoration: line-through; color: var(--muted); }
.ln-code { font-family: var(--mono); font-size: 0.88em; background: var(--soft); border-radius: 3px; padding: 0.12em 0.34em; }
.ln-link { color: var(--accent); }
.ln-url, .ln-dim { color: var(--faint); }
.ln-bullet { color: var(--accent); font-family: var(--mono); }
.ln-quote { border-left: 2px solid var(--line); padding-left: 14px !important; color: var(--muted); }
.ln-hr { color: var(--faint); }
.ln-pre { font-family: var(--mono); font-size: 0.87em; line-height: 1.65; background: var(--soft); padding: 0 14px !important; }
.ln-pre-first { border-radius: 4px 4px 0 0; padding-top: 8px !important; }
.ln-pre-last { border-radius: 0 0 4px 4px; padding-bottom: 8px !important; }
.ln-pre-first.ln-pre-last { border-radius: 4px; }
.ln-img { display: block; padding: 8px 0 12px; line-height: 0; }
.ln-img img { max-width: 100%; max-height: 70vh; border-radius: 4px; border: 1px solid var(--line); background: var(--soft); }

/* other people's cursors */
.loro-cursor { position: absolute; width: 2px !important; margin-left: -1px; background: var(--u); overflow: visible; }
.loro-cursor::before { content: var(--name) !important; display: block !important; position: absolute !important; left: 0 !important; top: -15px !important; bottom: auto !important; height: 15px !important; box-sizing: border-box; padding: 0 5px !important; font: 500 10px/15px var(--mono) !important; letter-spacing: 0; color: #fff !important; background: var(--u) !important; border-radius: 2px 2px 2px 0 !important; white-space: nowrap !important; opacity: 1 !important; user-select: none; pointer-events: none; }
.loro-selection { background: var(--u) !important; opacity: 0.22 !important; }
.c1 { --u: var(--c1); --me: var(--c1); } .c2 { --u: var(--c2); --me: var(--c2); }
.c3 { --u: var(--c3); --me: var(--c3); } .c4 { --u: var(--c4); --me: var(--c4); }
.c5 { --u: var(--c5); --me: var(--c5); } .c6 { --u: var(--c6); --me: var(--c6); }
.c7 { --u: var(--c7); --me: var(--c7); } .c8 { --u: var(--c8); --me: var(--c8); }

/* panels */
.panel { position: fixed; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16); font-size: 13px; line-height: 1.55; }
.panel.small { top: 56px; right: 20px; width: min(340px, calc(100vw - 32px)); padding: 18px; }
.panel.wide { inset: 56px 20px 20px auto; width: min(760px, calc(100vw - 40px)); padding: 18px; display: flex; flex-direction: column; }
.panel h2 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.panel p { margin: 0 0 12px; color: var(--muted); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.panel input { width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; outline: none; font-family: var(--mono); font-size: 13px; }
.panel input:focus { border-color: var(--accent); }
.error { color: var(--danger) !important; min-height: 1.4em; margin: 6px 0 4px !important; }
.row { display: flex; justify-content: flex-end; gap: 14px; align-items: center; }
.plain { color: var(--muted); font: 12px var(--mono); }
.plain:hover { color: var(--fg); }
.solid { background: var(--accent); color: #fff; padding: 7px 14px; border-radius: 4px; font: 12px var(--mono); }
.muted { color: var(--muted); }
.history-body { display: grid; grid-template-columns: 230px 1fr; gap: 16px; min-height: 0; flex: 1; }
#versions { overflow: auto; border-right: 1px solid var(--line); padding-right: 10px; }
.version { display: block; width: 100%; text-align: left; padding: 8px; border-radius: 4px; }
.version:hover, .version.on { background: var(--soft); }
.version .when { display: block; font: 11px var(--mono); color: var(--muted); }
.version.on .when { color: var(--accent); }
.version .what { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-view { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; align-items: flex-end; }
#version-text { flex: 1; width: 100%; margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.65 var(--mono); color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 8px); background: var(--fg); color: var(--bg); font: 12px var(--mono); padding: 8px 12px; border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity 0.16s, transform 0.16s; z-index: 30; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* phones */
@media (max-width: 640px) {
  body { font-size: 16px; }
  header { gap: 0; padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); height: 48px; overflow: hidden; }
  /* every control is a full-height, finger-sized target */
  header button, header a.tool { height: 48px; padding: 0 7px; display: inline-flex; align-items: center; flex: none; }
  .slug { flex: 0 1 auto !important; min-width: 56px; padding-left: 10px !important; overflow: hidden; text-overflow: ellipsis; display: block !important; line-height: 48px; }
  .status { flex: none; padding: 0 6px 0 2px; }
  .gap { min-width: 0; }
  .me { font-size: 0; gap: 0; padding: 0 12px !important; } /* just the colour dot; tap to rename */
  .me::before { width: 9px; height: 9px; border-radius: 2px; }
  .cm-content { padding: 24px 18px 45vh !important; }
  .ln-h1 { font-size: 1.5em; }
  .ln-h2 { font-size: 1.25em; }
  .ln-pre { font-size: 0.82em; padding: 0 10px !important; }
  .ln-img img { max-height: 60vh; }

  .panel.small { top: 56px; left: 10px; right: 10px; width: auto; }
  .panel.wide { inset: 0; width: auto; border: 0; border-radius: 0; padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom)); }
  .panel input { font-size: 16px; padding: 11px 12px; } /* 16px stops iOS from zooming in */
  .panel h2 { font-size: 15px; }
  .panel p { font-size: 14px; }
  .plain, .solid { font-size: 14px; min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; }
  .plain { padding: 0 6px; }
  .history-body { grid-template-columns: 1fr; grid-template-rows: minmax(110px, 32%) 1fr; }
  #versions { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 8px; }
  .version { padding: 11px 8px; }
  #version-text { font-size: 13px; }
  .version-view { align-items: stretch; }
  #restore { justify-content: center; }
  #toast { bottom: calc(18px + env(safe-area-inset-bottom)); font-size: 13px; }
}
/* narrow phones: drop the least used controls so the note name stays readable.
   "new" is the same as opening the site's front page; the theme follows the system. */
@media (max-width: 400px) {
  header a.tool[href="/"] { display: none; }
}
@media (max-width: 340px) {
  #theme { display: none; }
}
/* touch screens: nothing depends on hover */
@media (hover: none) {
  .slug:hover, .tool:hover, .me:hover { color: inherit; }
  .tool.on { color: var(--accent); }
  .version:hover { background: none; }
  .version.on { background: var(--soft); }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
