/* JT Notes base styles. Plain CSS, no framework; colors are tokens so dark
   mode only redefines them. */

:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  /* The default text colour (JT-259); dark mode sets --text itself. */
  --text-default: rgb(44 44 43);
  --text: var(--text-default);
  --muted: #5f6b7a;
  --border: #d9dde3;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #c62828;
  --success: #2e7d32;
  --row-alt: #fafbfc;
  /* Syntax highlighting (GitHub-like). */
  --hl-comment: #57606a;
  --hl-keyword: #cf222e;
  --hl-string: #0a3069;
  --hl-number: #0550ae;
  --hl-function: #8250df;
  --hl-type: #953800;
  --hl-attr: #116329;
  /* The shared palette (JT-187, js/colors.ts): text colours readable on
     --bg, backgrounds light enough for --text. */
  --color-text-gray: #6b6b6b;
  --color-text-brown: #8a5a44;
  --color-text-orange: #b45309;
  --color-text-yellow: #8f6508;
  --color-text-green: #2f7d4f;
  --color-text-blue: #1f6fa8;
  --color-text-purple: #7c4dab;
  --color-text-pink: #b0306f;
  --color-text-red: #c0392b;
  --color-bg-gray: #efefed;
  --color-bg-brown: #f3ebe7;
  --color-bg-orange: #fbecdc;
  --color-bg-yellow: #fbf3d6;
  --color-bg-green: #e6f2e9;
  --color-bg-blue: #e3f0f8;
  --color-bg-purple: #f0e9f7;
  --color-bg-pink: #f9e8f1;
  --color-bg-red: #fce7e6;
  /* Selected blocks and the box drag (JT-176). */
  --block-selected: rgb(35 131 226 / 0.14);
  --block-marquee-border: rgb(35 131 226 / 0.5);
  --radius: 6px;
  /* A favorite's filled star (JT-247 follow-up), readable in both themes. */
  --favorite: #f6c050;
  /* Placeholder text: the title and empty blocks (JT-251, JT-250). */
  --placeholder: #e1e1e0;
  /* The site-wide text font (JT-232); code keeps its monospace stack. */
  --font-sans:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica,
    "Apple Color Emoji", "Noto Sans Arabic", "Noto Sans Hebrew", Arial, sans-serif, "Segoe UI Emoji",
    "Segoe UI Symbol";
  /* Sidebar palette (JT-259, light theme; dark keeps --bg / --surface). */
  --sidebar-bg: #f9f8f7;
  --sidebar-text: rgb(95 94 89);
  --sidebar-hover: #e4e1e0;
  /* Heading Anchor (JT-304): the current dash, the others, the current item. */
  --anchor-current: rgb(44 44 43);
  --anchor-dash: rgb(28 19 1 / 0.11);
  --anchor-active-text: rgb(39 131 222);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --surface: #1f2329;
    --text: #e6e8eb;
    --muted: #9aa4b2;
    --border: #343a43;
    --accent: #4f8cff;
    --danger: #ef5350;
    --success: #66bb6a;
    --row-alt: #1a1d22;
    --hl-comment: #8b949e;
    --hl-keyword: #ff7b72;
    --hl-string: #a5d6ff;
    --hl-number: #79c0ff;
    --hl-function: #d2a8ff;
    --hl-type: #ffa657;
    --hl-attr: #7ee787;
    --color-text-gray: #a3a3a3;
    --color-text-brown: #c49a84;
    --color-text-orange: #e09050;
    --color-text-yellow: #d9b44a;
    --color-text-green: #5fb883;
    --color-text-blue: #66a6e0;
    --color-text-purple: #b38be0;
    --color-text-pink: #e07aae;
    --color-text-red: #ec6a63;
    --color-bg-gray: #2e3034;
    --color-bg-brown: #3d2e27;
    --color-bg-orange: #4a3020;
    --color-bg-yellow: #463b1e;
    --color-bg-green: #1f3a2b;
    --color-bg-blue: #1b3448;
    --color-bg-purple: #352a47;
    --color-bg-pink: #43263a;
    --color-bg-red: #4a2526;
    --block-selected: rgb(66 150 240 / 0.28);
    --block-marquee-border: rgb(102 170 245 / 0.7);
    /* The sidebar as before JT-259. */
    --sidebar-bg: var(--bg);
    --sidebar-hover: var(--surface);
    /* #e1e1e0 would be bright on the dark background. */
    --placeholder: var(--muted);
    --anchor-current: var(--text);
    --anchor-dash: rgb(255 255 255 / 0.13);
    --anchor-active-text: #66a6e0;
  }
}

/* Palette classes (JT-187): text colour and background, for spans in notes
   (data-color / data-bg) and table cells (JT-173). Classes, not style=: the
   CSP has no 'unsafe-inline' for styles. */
.jt-text-gray { color: var(--color-text-gray); }
.jt-text-brown { color: var(--color-text-brown); }
.jt-text-orange { color: var(--color-text-orange); }
.jt-text-yellow { color: var(--color-text-yellow); }
.jt-text-green { color: var(--color-text-green); }
.jt-text-blue { color: var(--color-text-blue); }
.jt-text-purple { color: var(--color-text-purple); }
.jt-text-pink { color: var(--color-text-pink); }
.jt-text-red { color: var(--color-text-red); }
.jt-bg-gray { --jt-bg: var(--color-bg-gray); }
.jt-bg-brown { --jt-bg: var(--color-bg-brown); }
.jt-bg-orange { --jt-bg: var(--color-bg-orange); }
.jt-bg-yellow { --jt-bg: var(--color-bg-yellow); }
.jt-bg-green { --jt-bg: var(--color-bg-green); }
.jt-bg-blue { --jt-bg: var(--color-bg-blue); }
.jt-bg-purple { --jt-bg: var(--color-bg-purple); }
.jt-bg-pink { --jt-bg: var(--color-bg-pink); }
.jt-bg-red { --jt-bg: var(--color-bg-red); }

/* A swatch's frame colour in the colour panel (JT-255): the hue's text
   colour, for both its text and its background swatch. */
.jt-text-gray, .jt-bg-gray { --swatch-edge: var(--color-text-gray); }
.jt-text-brown, .jt-bg-brown { --swatch-edge: var(--color-text-brown); }
.jt-text-orange, .jt-bg-orange { --swatch-edge: var(--color-text-orange); }
.jt-text-yellow, .jt-bg-yellow { --swatch-edge: var(--color-text-yellow); }
.jt-text-green, .jt-bg-green { --swatch-edge: var(--color-text-green); }
.jt-text-blue, .jt-bg-blue { --swatch-edge: var(--color-text-blue); }
.jt-text-purple, .jt-bg-purple { --swatch-edge: var(--color-text-purple); }
.jt-text-pink, .jt-bg-pink { --swatch-edge: var(--color-text-pink); }
.jt-text-red, .jt-bg-red { --swatch-edge: var(--color-text-red); }
[class*="jt-bg-"] { background-color: var(--jt-bg); }
/* A background span on text: a little room around the letters. */
span[data-bg] {
  border-radius: 3px;
  padding: 0 0.1em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Menu swatches (colors.ts swatch()). */
.color-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
}

* {
  box-sizing: border-box;
}

/* `hidden` wins over component display rules (e.g. the tree actions shown
   on hover), so a viewer's hidden controls stay hidden (JT-85). */
[hidden] {
  display: none !important;
}

/* Read by screen readers, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

body {
  margin: 0;
  /* Installed on a phone (JT-282, viewport-fit=cover): keep the page off
     the notch and the home bar. The insets are 0 everywhere else, so the
     desktop layout does not change. The header adds the top one itself, so
     its background runs up behind the status bar. */
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
}

/* Thin, quiet scrollbars everywhere, in the design's colour (JT-261, the
   literal #a19e99 by request); every element its own stacking context, so
   a z-index never reaches outside its parent. */
* {
  scrollbar-color: color-mix(in srgb, #a19e99 50%, transparent) transparent;
  isolation: isolate;
}

/* Form controls take the page font instead of the browser's own (JT-232). */
input,
textarea,
button,
select {
  font-family: inherit;
}

.container {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1rem;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button.danger {
  color: var(--danger);
}

button.danger.primary {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--accent-text);
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
}

input[type="text"],
textarea {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

textarea {
  resize: vertical;
}

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

/* Text fields show no focus ring (JT-154): the caret marks where you are;
   the border stays as it is. Buttons and links keep the ring above; so do
   checkboxes and radios (task lists), which have no caret. */
input:not([type="checkbox"]):not([type="radio"]):focus,
input:not([type="checkbox"]):not([type="radio"]):focus-visible,
textarea:focus,
textarea:focus-visible,
select:focus,
select:focus-visible,
[contenteditable]:focus,
[contenteditable]:focus-visible {
  outline: none;
  outline-offset: 0;
  box-shadow: none;
}

.muted {
  color: var(--muted);
}

/* Header and page chrome */
.app-header {
  /* Under the status bar of an installed app (JT-282). */
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 0.6rem;
}

/* Signed-in email and sign-out (components/account.rs, JT-53). */
.account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  font-size: 0.9rem;
}

.account-email {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account button {
  flex: none;
  padding: 0.2rem 0.7rem;
}

.brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

/* "JT Notes ▾" (JT-135): a menu button that still reads as the brand. Its
   text keeps the header's left edge (the padding is pulled back). */
button.brand {
  margin-left: -0.4rem;
  padding: 0.15rem 0.4rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.brand:hover,
button.brand[aria-expanded="true"] {
  background: var(--border);
}

.empty {
  padding: 2rem 0;
  text-align: center;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

.notice p {
  margin: 0;
}

/* Sign-in page (components/sign_in.rs, JT-113): signed-out visitors and a
   failed callback. A narrow centred card with the three ways in. */
.sign-in {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(24rem, 100%);
  margin: 4rem auto;
  text-align: center;
}

.sign-in h1 {
  margin: 0;
  font-size: 1.5rem;
}

.sign-in p {
  margin: 0;
}

.sign-in .notice {
  justify-content: center;
  text-align: left;
}

.sign-in-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.sign-in-options > button {
  min-height: 2.5rem;
}

/* Google's sign-in button branding: white, #747775 border, #1F1F1F text, the
   18px "G" 12px from the label, 4px corners. Same in dark mode (Google's
   light variant), so the colours are fixed rather than theme tokens. */
.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0 0.75rem;
  border: 1px solid #747775;
  border-radius: 4px;
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 500;
}

.google-button:hover:not(:disabled) {
  background: #f8f8f8;
}

.google-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.google-mark {
  flex: none;
}

.sign-in-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.sign-in-or::before,
.sign-in-or::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.sign-in-sign-up {
  color: var(--muted);
  font-size: 0.9rem;
}

/* A button that reads as a link (e.g. 「以 email 註冊」). */
button.link-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Signed-in layout (components/note_tree.rs, JT-48, JT-96). Pages without the
   sidebar (/status, /auth/callback) keep a centred 68rem column. */
:root {
  /* Desktop only (JT-231); the narrow-screen drawer has its own width. */
  --sidebar-width: 270px;
}

.app-header .container,
.app-main {
  max-width: 68rem;
}

.notes-main {
  min-width: 0;
}

/* Page bar right under the header (components/page_bar.rs, JT-141): the
   breadcrumb on the left, under "JT Notes", the page's "⋯" on the right,
   under "登出". It sits outside the centred .notes-main, so its edges are
   the main area's, like the header's. */
.page-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2rem;
  margin-bottom: 1rem;
}

.page-actions {
  flex: none;
  display: flex;
  align-items: center;
}

.page-actions .more-trigger {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* "已儲存" (components/page_bar.rs, JT-155): the full line (version, time)
   floats under it, right-aligned, on hover or keyboard focus. */
.page-save-status {
  position: relative;
  margin-right: 0.35rem;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: default;
}

.page-save-status.alert {
  color: var(--danger);
}

.page-save-status:focus {
  outline: none;
}

.page-save-status:focus-visible {
  background: var(--surface);
}

.page-save-status::after {
  content: attr(data-full);
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  display: none;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
}

.page-save-status:hover::after,
.page-save-status:focus-visible::after {
  display: block;
}

/* ★ (JT-157): filled and accent-coloured when the note is a favorite. */
.page-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}

.page-star:hover {
  background: var(--surface);
  color: var(--text);
}

/* 「已加入最愛」 (JT-247 follow-up): the filled star is yellow wherever it
   shows (the page bar, the sidebar row menu). */
.icon-star-fill {
  color: var(--favorite);
}

/* The personal workspace's 私人 lock, before its name (switcher and list). */
.workspace-lock {
  display: inline-flex;
  flex: none;
  align-items: center;
  margin-right: 0.3rem;
  font-size: 1rem;
}

.workspace-current .workspace-lock {
  margin-right: 0;
}

.page-actions .more-trigger:hover,
.page-actions .more-trigger[aria-expanded="true"] {
  background: var(--surface);
  color: var(--text);
}

/* Breadcrumb (components/breadcrumb.rs, JT-104): small and muted, one line;
   a long path scrolls sideways within its side of the bar instead of
   wrapping or pushing "⋯" out. */
.breadcrumb {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--muted);
  overflow-x: auto;
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  min-width: 0;
}

.breadcrumb li + li::before {
  content: "/";
  margin-inline: 0.4rem;
  color: var(--border);
}

.breadcrumb .crumb {
  display: inline-block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.breadcrumb a.crumb {
  color: inherit;
  text-decoration: none;
}

.breadcrumb a.crumb:hover {
  color: var(--text);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--text);
}

/* A locked page's mark after its name (JT-132); not a control. */
/* The note's emoji before its title (JT-162). */
.breadcrumb .crumb-icon {
  margin-right: 0.3rem;
}

.breadcrumb .crumb-lock {
  flex: none;
  margin-left: 0.3rem;
  font-size: 0.8rem;
  cursor: default;
  user-select: none;
}

.breadcrumb .crumb-more {
  padding: 0 0.3rem;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.breadcrumb .crumb-more:hover {
  background: var(--surface);
  color: var(--text);
}

/* A breadcrumb step's level (JT-203, components/crumb_menu.rs): fixed and
   portalled (the breadcrumb scrolls sideways), placed through CSSOM; the
   children of a hovered row open in the next list to its right. */
.crumb-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: 16rem;
  max-width: calc(100vw - 8px);
  padding: 0.25rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.18);
  font-size: 0.85rem;
}

.crumb-menu-heading {
  padding: 0.3rem 0.5rem 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  user-select: none;
}

.crumb-menu-item,
.crumb-menu-more {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.85rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.crumb-menu-item:hover,
.crumb-menu-item.on-path {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

/* The open page. */
.crumb-menu-item.current,
.crumb-menu-item.current:hover {
  background: var(--block-selected);
}

.crumb-menu-icon {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  color: var(--muted);
}

.crumb-menu-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb-menu-caret,
.workspace-caret {
  display: inline-flex;
  flex: none;
  align-items: center;
  color: var(--muted);
}

.crumb-menu-more {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.crumb-menu-more:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
}

/* Pages with the sidebar (JT-261): the header and the page bar stay put and
   only the page under them scrolls, in .notes-scroll, which reaches the
   window's right edge so its scrollbar sits there, beside the content
   only. The sidebar scrolls on its own (below). The window never scrolls,
   so menus on <body> are placed in viewport terms and follow the anchor
   with autoUpdate (js/block-menu.ts placeMenu). */
body:has(.notes-layout) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body:has(.notes-layout) .app-header {
  flex: none;
}

body:has(.notes-layout) .app-main,
.notes-layout {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

body:has(.notes-layout) .app-main {
  /* Full width: .container's auto margins would shrink it in the flex
     column (wide screens set the left one to the sidebar's width below). */
  margin-inline: 0;
  /* .notes-scroll keeps the bottom room, so it scrolls into view. */
  padding-bottom: 0;
  /* The page bar sits right under the header. */
  padding-top: 0;
}

.notes-layout > .page-bar {
  flex: none;
}

.notes-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Out to the main area's edges (its 1rem padding): the scrollbar at the
     window's right edge, and presses beside the note still start a box
     selection (js/block-select.ts). */
  margin-inline: -1rem;
  padding: 0 1rem 1rem;
}

/* Wide screens (JT-96): the sidebar is pinned to the left edge at full height
   and scrolls on its own; the header and the page sit to its right, and the
   page scrolls in .notes-scroll (JT-261), so the sidebar never moves. The 48rem
   reading column is centred in what is left. `body:has(.notes-layout)` limits
   this to pages that have the sidebar. Below 48rem it is a drawer (see the
   narrow-screen block). */
@media (min-width: 48rem) {
  body:has(.notes-layout) .app-header,
  body:has(.notes-layout) .app-main {
    margin-left: var(--sidebar-width);
  }

  body:has(.notes-layout) .app-header .container,
  body:has(.notes-layout) .app-main {
    max-width: none;
  }

  .notes-main {
    max-width: 48rem;
    margin-inline: auto;
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    left: 0;
    /* Under the editor menus (20), dialogs (50) and toasts (100). */
    z-index: 10;
    width: var(--sidebar-width);
    height: 100dvh;
    overflow-y: auto;
    /* Scrolling past the end of the sidebar does not scroll the page. */
    overscroll-behavior: contain;
    padding: 1rem 0.75rem;
    /* Fixed to the window's edges: clear the notch and home bar (JT-282). */
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left: max(0.75rem, env(safe-area-inset-left));
    border-right: 1px solid var(--border);
    background: var(--sidebar-bg);
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  /* Above the search box and the tree after it (JT-306): every element is
     its own stacking context (JT-261), so the workspace list's z-index
     cannot leave this header, and later siblings painted over the list and
     took its clicks. */
  position: relative;
  z-index: 1;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* Workspace switcher (components/workspace.rs, JT-80) */
.workspace-switcher {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  margin-right: 0.25rem;
}

.workspace-current {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.25rem 0.4rem;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
}

.workspace-current:hover {
  background: var(--border);
}

.workspace-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.workspace-options {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 25;
  width: max(100%, 14rem);
  max-width: calc(100vw - 2rem);
  max-height: 20rem;
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

.workspace-options li {
  padding: 0.35rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.workspace-options li:hover,
.workspace-options li.highlighted {
  background: var(--surface);
}

.workspace-options li.current {
  font-weight: 600;
}

.workspace-options .workspace-new {
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
  color: var(--accent);
}

.dialog label {
  display: block;
  margin-bottom: 0.3rem;
}

.dialog input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

.sidebar-note {
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
}

.sidebar-note p {
  margin: 0 0 0.5rem;
}

/* Favorites / Recents / Private sections (components/note_tree.rs, JT-153) */
.sidebar-section + .sidebar-section {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.sidebar-subheading {
  display: flex;
  align-items: center;
  margin: 0.25rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

/* A section's action (Private's "+", JT-206): at the heading's right,
   faded in while the heading is hovered or focused (always on touch). */
.section-action {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-right: 0.25rem;
  padding: 0;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  opacity: 0;
  cursor: pointer;
}

.sidebar-subheading:hover .section-action,
.section-action:focus-visible {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.section-action:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

@media (hover: none) {
  .section-action {
    opacity: 1;
  }
}

/* The heading is the toggle: text only, no frame or fill. */
.section-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  padding: 0.15rem 0.5rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.section-toggle:hover {
  color: var(--text);
}

.section-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.75rem;
}

.flat-list .tree-link {
  padding-left: 0.2rem;
}

button.icon,
.tree-toggle,
.tree-actions button {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

button.icon:hover:not(:disabled),
.tree-toggle:hover,
.tree-actions button:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.tree-actions button.danger {
  color: var(--danger);
}

/* "+" and "⋯" are SVGs (components/icons.rs, JT-202): centred in their
   buttons, about the size the characters were. */
.tree-actions button,
.page-actions .more-trigger,
.more-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tree-actions button .icon {
  font-size: 1rem;
}

.page-actions .more-trigger .icon {
  font-size: 1.25rem;
}

/* Note icons in the sidebar (components/note_tree.rs, JT-163): the emoji, or
   the default page drawing. On a row with sub-pages the slot is the toggle
   button: hovering (or focusing) the row swaps the icon for the chevron
   (JT-246; turned right while collapsed). Rows without sub-pages keep the
   icon. */
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

span.tree-toggle:hover {
  background: transparent;
}

.tree-row-icon {
  display: block;
}

.tree-emoji {
  font-size: 0.95rem;
  line-height: 1;
}

.page-icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
  overflow: visible;
}

.tree-caret {
  display: none;
}

.tree-row:hover button.tree-toggle .tree-row-icon,
.tree-row:focus-within button.tree-toggle .tree-row-icon {
  display: none;
}

.tree-row:hover button.tree-toggle .tree-caret,
.tree-row:focus-within button.tree-toggle .tree-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* "Workspace 設定" link beside the switcher (JT-85). */
a.icon-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  line-height: 1;
}

a.icon-link:hover {
  background: var(--border);
  color: var(--text);
}

/* The cog (JT-207): about the size the ⚙ glyph had. */
a.icon-link .icon {
  font-size: 1.1rem;
}

/* 重新整理 (JT-322), left of the cog: a button dressed like the link. The
   margin pushes it right, next to the cog (the header spaces its items
   apart). While a refresh runs it spins, disabled. */
button.sidebar-refresh {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-left: auto;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  line-height: 1;
  cursor: pointer;
}

button.sidebar-refresh:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

button.sidebar-refresh:disabled {
  cursor: default;
}

button.sidebar-refresh .icon {
  font-size: 1.1rem;
}

button.sidebar-refresh[aria-busy="true"] .icon {
  animation: sidebar-refresh-spin 0.8s linear infinite;
}

@keyframes sidebar-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  button.sidebar-refresh[aria-busy="true"] .icon {
    animation-duration: 2.4s;
  }
}

/* Workspace settings page (JT-85). */
.workspace-settings {
  max-width: 40rem;
}

/* Trash link at the bottom of the sidebar (JT-90). */
.sidebar-footer {
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-trash {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  /* 30px tall like the note rows (JT-260). */
  height: 30px;
  padding: 0 0.4rem;
  border-radius: var(--radius);
  color: var(--muted);
  /* Same size as the note titles above it (JT-231). */
  font-size: 0.875rem;
  line-height: 30px;
  text-decoration: none;
}

/* The trash icon (JT-247), then the label, cut with "…". */
.sidebar-trash .icon {
  font-size: 1.1rem;
}

.sidebar-trash-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-trash:hover,
.sidebar-trash[aria-current="page"] {
  background: var(--border);
  color: var(--text);
}

/* Trash page (JT-90). */
.trash-page {
  max-width: 40rem;
}

.trash-filter {
  width: 100%;
  margin-bottom: 0.75rem;
}

.trash-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.trash-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.trash-info {
  min-width: 0;
  flex: 1;
}

.trash-title {
  font-weight: 600;
  margin-right: 0.35rem;
  overflow-wrap: anywhere;
}

.trash-meta {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
}

.trash-actions {
  display: flex;
  gap: 0.4rem;
}

.workspace-settings section {
  margin-bottom: 1.5rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.inline-form input[type="text"],
.inline-form input[type="email"] {
  flex: 1 1 14rem;
  min-width: 0;
}

.member-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.member-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.member-row + .member-row {
  border-top: 1px solid var(--border);
}

.member-email {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.member-role {
  color: var(--muted);
}

/* A viewer's tags on the note page: names only. */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

/* ☰ and 「JT Notes」 on the header's left (JT-307). */
.header-start {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

/* ☰: shown below 48rem only (narrow-screen block). */
.sidebar-toggle {
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  margin-left: -0.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

.sidebar-toggle:hover,
.sidebar-toggle[aria-expanded="true"] {
  background: var(--surface);
}

/* What scrolls inside the drawer (JT-283); no box of its own on wide
   screens, where the whole sidebar scrolls as before. */
.sidebar-body {
  display: contents;
}

/* Page tree */
.tree,
.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Rows exactly 30px tall, 1px apart: between siblings and between a page
   and its first child (JT-260). */
.tree-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  height: 30px;
  border-radius: var(--radius);
}

.tree li + li,
.tree li > ul {
  margin-top: 1px;
}

.tree-row:hover,
.tree-row:focus-within {
  background: var(--sidebar-hover);
}

/* The current page by its background alone: no blue edge (JT-152), no bold
   (JT-259). */
.tree-row.current {
  background: var(--sidebar-hover);
}

.tree-link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  /* The row's full 30px is the link (JT-260): no vertical padding. */
  padding: 0 0.2rem;
  color: var(--text);
  /* 14px note titles in every sidebar section (JT-231). */
  font-size: 0.875rem;
  line-height: 30px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Light theme sidebar text and the hovers set elsewhere with --border
   (JT-259); dark mode keeps its colours. After the rules they override. */
@media (prefers-color-scheme: light) {
  .sidebar,
  .sidebar .tree-link,
  .sidebar-header h2,
  .sidebar-subheading,
  .sidebar .section-toggle:hover,
  .sidebar-trash,
  .sidebar-trash:hover,
  .sidebar-trash[aria-current="page"],
  .workspace-current {
    color: var(--sidebar-text);
  }

  .sidebar-trash:hover,
  .sidebar-trash[aria-current="page"],
  .workspace-current:hover {
    background: var(--sidebar-hover);
  }
}

/* Sidebar drag and drop (JT-100): where the note will land. */
.tree-row[draggable="true"] {
  cursor: grab;
}

.tree-row.dragging {
  opacity: 0.45;
}

/* Above / below: a straight 2px line of its own (JT-318), not the row's
   box-shadow, which followed the row's rounded corners. It starts at the
   level the note lands on (`--drop-indent`, set on the row). */
.tree-row {
  position: relative;
}

.tree-row.drop-before::before,
.tree-row.drop-after::after,
.tree-end-drop.drop-after::before {
  content: "";
  position: absolute;
  left: var(--drop-indent, 0);
  right: 0;
  height: 2px;
  border-radius: 0;
  background: var(--accent);
  pointer-events: none;
}

.tree-row.drop-before::before {
  top: -1px;
}

.tree-row.drop-after::after {
  bottom: -1px;
}

/* The space below the tree (JT-318): drops there go last at the top level. */
.tree-end-drop {
  position: relative;
  min-height: 1.5rem;
}

.tree-end-drop.drop-after::before {
  top: 0;
}

.tree-row.drop-inside {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Row actions appear on hover / keyboard focus; always on touch screens. */
.tree-actions {
  display: none;
  flex: none;
}

.tree-row:hover .tree-actions,
.tree-row:focus-within .tree-actions,
/* The menu lives on <body>: keep its "⋯" in place (and focusable) while open. */
.tree-actions:has([aria-expanded="true"]) {
  display: flex;
}

/* Leptos `Portal` puts each menu in a plain <div> on <body>, and every
   element is its own stacking context (JT-261): the menu's z-index stays
   inside that wrapper, a layer at 0, under the heading anchor (20) and the
   other fixed layers. Lift the wrapper of a floating menu instead (JT-295). */
body > div:has(> .more-menu, > .crumb-menu, > .emoji-picker) {
  position: relative;
  z-index: 60;
}

/* "⋯ 更多" menu (components/more_menu.rs, JT-101). */
.more-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 10rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.18);
}

.more-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}

.more-item:hover:not(:disabled),
.more-item:focus-visible {
  background: var(--surface);
  outline: none;
}

.more-item:disabled {
  color: var(--muted);
  opacity: 0.6;
}

.more-item.danger {
  color: var(--danger);
}

.more-item.separated {
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding-top: 0.45rem;
}

/* A toggle ("鎖定頁面", JT-132): a switch on the right (JT-244), blue with
   the knob at the right when on, light grey when off. */
.more-switch {
  flex: none;
  position: relative;
  width: 28px;
  height: 16px;
  margin-left: auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 15%, transparent);
  transition: background-color 0.15s;
}

/* Room between the label and the switch, as in the design. */
.more-item.toggle {
  min-width: 12rem;
}

.more-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform 0.15s;
}

.more-item[aria-checked="true"] .more-switch {
  background: var(--accent);
}

.more-item[aria-checked="true"] .more-switch-knob {
  transform: translateX(12px);
}

@media (prefers-reduced-motion: reduce) {
  .more-switch,
  .more-switch-knob {
    transition: none;
  }
}

/* A menu item's icon (JT-247): 20px, muted; the danger item's is red like
   its label. Items without one keep the empty slot so labels line up. */
.more-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--muted);
  font-size: 20px;
}

.more-item.danger .more-icon {
  color: inherit;
}

@media (hover: none) {
  .tree-actions {
    display: flex;
  }
}

/* Sidebar search and tag filter (components/note_search.rs, JT-50) */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

/* type="search" misses the text-input rule above, so it sets its own frame
   (the browser's default border was dark), in --border (JT-154). */
input.search-input {
  width: 100%;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 100%;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

button.chip:hover {
  border-color: var(--accent);
}

.chip.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.chip-manage {
  border-style: dashed;
  color: var(--muted);
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.85rem;
}

button.link-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.85rem;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.result-list li {
  border-radius: var(--radius);
}

.result-list li:hover,
.result-list li:focus-within {
  background: var(--surface);
}

/* The current page by its background alone, no blue edge (JT-152). */
.result-list li.current {
  background: var(--surface);
}

.result-link {
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.5rem;
  color: var(--text);
  text-decoration: none;
}

.result-title {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-path,
.result-snippet {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.result-snippet {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* Editor tag field (components/tag_input.rs, JT-50) */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.tag-input-label {
  font-weight: 500;
}

.tag-chips {
  display: contents;
  list-style: none;
}

.chip-remove {
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.chip-remove:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.tag-combobox {
  position: relative;
  flex: 1 1 10rem;
  min-width: 8rem;
}

.tag-combobox input {
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
}

.tag-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 25;
  width: max(100%, 12rem);
  max-width: calc(100vw - 2rem);
  max-height: 16rem;
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

.tag-suggestions li {
  padding: 0.3rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.tag-suggestions li:hover,
.tag-suggestions li.highlighted {
  background: var(--surface);
}

.tag-suggestions li.highlighted {
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Tag manager dialog (components/tag_manager.rs, JT-50) */
.tag-manager-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 50vh;
  margin: 0 0 1rem;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.tag-manager-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tag-manager-list input {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.5rem;
}

.tag-usage {
  flex: none;
  font-size: 0.85rem;
}

/* Narrow screens: the sidebar is a drawer over the page. */
@media (max-width: 47.99rem) {
  .notes-main {
    max-width: none;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(22rem, 88vw);
    max-height: none;
    padding: 1rem;
    /* The drawer spans the window's height: clear the notch and home bar
       (JT-282). */
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    border-right: 1px solid var(--border);
    background: var(--sidebar-bg);
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.2s ease,
      visibility 0.2s;
    /* The workspace switcher on top and the trash at the bottom stay put;
       the pages between them scroll (JT-283, JT-307). */
    display: flex;
    flex-direction: column;
  }

  .sidebar > .sidebar-header,
  .sidebar > .sidebar-footer {
    flex: none;
  }

  .sidebar-body {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Room for the rows' focus rings at the edges. */
    margin-inline: -0.25rem;
    padding-inline: 0.25rem;
  }

  .sidebar-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgb(0 0 0 / 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* Edit form */
.note-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Out of sync (JT-323): the note's first line, stuck to the top of
   .notes-scroll while the note scrolls under it. Opaque (the tint is mixed
   into the page colour) so text does not show through. The info variant
   offers the version kept by 重新整理. */
.sync-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 10%, var(--bg));
  color: var(--text);
}

.sync-banner p {
  margin: 0;
  font-weight: 600;
}

.sync-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.sync-banner-info {
  position: static;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.sync-banner-info p {
  font-weight: normal;
}

/* Title and content on a blank page (JT-127): no label or border (and no
   focus ring, JT-154 above); the title stands out by size alone. A blank
   title shows the placeholder 「新頁面」 in --placeholder (JT-251). Its text lines up with the content's (same left padding as
   .editor-input). */
textarea.note-title,
textarea.note-title:focus {
  border: none;
}

textarea.note-title::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

/* Only the left padding (room for the block controls, matching the
   content's); none on the other sides (JT-151 follow-up). A textarea one
   line tall that grows with its text, so a long title wraps (JT-168): the
   height follows the content through field-sizing alone. The global
   textarea font and resize handle do not apply. */
textarea.note-title {
  display: block;
  width: 100%;
  padding: 0 0 0 3.1rem;
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  /* 40px text on a 51px line (JT-211, by request); the box is as tall as
     its lines (field-sizing below, no height set from Rust). The 8px to
     the content is .note-form's gap. */
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 51px;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  field-sizing: content;
}

/* The note's icon above its title (components/note_icon.rs, JT-161),
   laid out as in JT-182's design (JT-201), top to bottom: the large emoji on
   its own line, a row of small grey actions ("Add icon" / "Remove", each
   with its icon), then the title. The rows keep the title's left edge. The
   actions only show (a 0.2s fade) while the head is hovered or focused; the
   row keeps its height, so the title never jumps. */
.note-head {
  display: flex;
  flex-direction: column;
}

.note-icon-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
  padding-left: 3.1rem;
}

/* A 78px square (JT-238), the emoji centred in it. */
.note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: 4rem;
  line-height: 1;
}

button.note-icon {
  cursor: pointer;
}

button.note-icon:hover {
  background: var(--surface);
}

.note-icon-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.6rem;
  margin-left: -0.45rem;
}

.note-icon-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.45rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.2;
  opacity: 0;
  transition: none;
}

.note-icon-action .icon {
  flex: none;
  font-size: 1rem;
}

.note-head:hover .note-icon-action,
.note-head:focus-within .note-icon-action,
.note-icon-action[aria-expanded="true"] {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.note-icon-action:hover {
  background: var(--surface);
  color: var(--text);
}

@media (hover: none) {
  .note-icon-action {
    opacity: 1;
  }
}

/* The picker (components/emoji_picker.rs): on <body>, fixed under the icon
   button; the position comes through CSSOM. */
.emoji-picker {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 20rem;
  max-width: calc(100vw - 16px);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

/* The search, and 「Remove」 at its right when the note has an icon
   (JT-238). */
.emoji-picker-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.emoji-remove {
  flex: none;
  padding: 0.3rem 0.5rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
}

.emoji-remove:hover {
  background: var(--surface);
  color: var(--text);
}

.emoji-search {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}

.emoji-tab {
  flex: 1;
  padding: 0.2rem 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
}

.emoji-tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 15rem;
  overflow-y: auto;
}

.emoji-option {
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.emoji-option:hover,
.emoji-option:focus-visible {
  background: var(--surface);
  outline: none;
}

.emoji-use {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.emoji-empty {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Disabled while it cannot be edited (a viewer or a locked page, JT-132):
   keep the title looking like the title, not a greyed-out field. */
textarea.note-title:disabled {
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  opacity: 1;
  cursor: default;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Tiptap / ProseMirror base styles, copied from @tiptap/core 3.34.0
   (src/style.ts). Tiptap would inject them as a <style> element, which the
   CSP (style-src 'self', JT-56) blocks, so js/editor.ts sets injectCSS: false
   and they live here instead. Only change: the gap cursor uses currentColor
   instead of black so it shows in dark mode. Re-check on Tiptap upgrades. */
.ProseMirror {
  position: relative;
}

.ProseMirror {
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
}

.ProseMirror [contenteditable="false"] {
  white-space: normal;
}

/* Empty H1–H4 and list items (js/block-placeholders.ts, JT-250): the text
   from data-placeholder, in the block's own font, taking no space. Only
   these elements (SHOWN_PLACEHOLDERS there): every empty paragraph carries
   「List」, but only a list item's own paragraph shows it. */
.ProseMirror :is(h1, h2, h3, h4).is-empty[data-placeholder]::before,
.ProseMirror li > p.is-empty[data-placeholder]::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: var(--placeholder);
  pointer-events: none;
}

.ProseMirror [contenteditable="false"] [contenteditable="true"] {
  white-space: pre-wrap;
}

.ProseMirror pre {
  white-space: pre-wrap;
}

/* Code block with its language and copy buttons, top right (JT-124, JT-137). */
.code-block {
  position: relative;
}

.code-block > pre {
  /* Room for the buttons above the first line's end. */
  padding-top: 1.6rem;
}

.code-actions {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.code-language,
.code-copy {
  padding: 0.05rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}

.code-language:hover:not(:disabled),
.code-language:focus-visible,
.code-copy:hover,
.code-copy:focus-visible {
  border-color: var(--border);
  background: var(--bg);
  color: var(--text);
}

/* Read only: just the name. */
.code-language:disabled {
  cursor: default;
}

/* Idle: the duplicate icon, a little larger than the language's text. */
.code-copy .icon {
  display: block;
  font-size: 1rem;
}

.code-copy:not([data-state='done'], [data-state='failed']) {
  padding: 0.15rem 0.3rem;
}

.code-copy[data-state='done'] {
  color: var(--success);
}

.code-copy[data-state='failed'] {
  color: var(--danger);
}

/* Read out (aria-live), not shown. */
.code-copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

img.ProseMirror-separator {
  display: inline !important;
  border: none !important;
  margin: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
  margin: 0;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid currentColor;
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-hideselection *::selection {
  background: transparent;
}

.ProseMirror-hideselection *::-moz-selection {
  background: transparent;
}

.ProseMirror-hideselection * {
  caret-color: transparent;
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}

/* Markdown editor (components::Editor, Tiptap since JT-70). The editable
   element also has .markdown-body, so content looks like the preview; it
   grows with its content. */
.editor-input {
  min-height: 24rem;
  /* A left padding, room for the block controls ("+" and the drag handle);
     none on the top or right (JT-151 follow-up). 30vh of blank space under
     the last block, whose click puts the caret on a blank last line
     (JT-205, js/end-click.ts). */
  padding: 0 0 30vh 3.1rem;
  border: none;
  background: transparent;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Truly centred (JT-167): where the reading column has room on its left
   (sidebar 16rem + column 48rem + 3.1rem each side ≈ 70.2rem), the title and
   its icon row lose the 3.1rem indent and the content is pulled left by it.
   The content keeps its padding for the block controls, which now sit in
   the margin left of the column, so its text starts at the column's edge
   with the title's. Narrower, everything keeps the indent: a negative
   margin would push text off a phone or under the sidebar. */
@media (min-width: 71rem) {
  .note-head .note-title,
  .note-head .note-icon-row {
    padding-left: 0;
  }

  .editor-input {
    margin-left: -3.1rem;
  }
}

/* Heading Anchor (js/heading-anchor.ts, JT-304): one dash per H1–H4 on the
   right, and a panel over them on hover. Only where the column leaves room on
   its right and a mouse can hover (user decision: ≥71rem). A click lands the
   heading just under the page bar. */
.editor-input :is(h1, h2, h3, h4) {
  scroll-margin-top: 1rem;
}

.heading-anchor,
.heading-anchor-panel {
  position: fixed;
  top: 168px;
  right: 35px;
  z-index: 20;
}

/* The panel covers the dashes, 5px further right and 2px higher. */
.heading-anchor-panel {
  top: 166px;
  right: 30px;
}

.heading-anchor-rail {
  box-sizing: border-box;
  width: 48px;
  padding: 0 0 12px 20px;
}

.heading-anchor-dash {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 14px;
}

.heading-anchor-dash::after {
  content: "";
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--anchor-dash);
}

.heading-anchor-dash[data-level="2"]::after {
  width: 12px;
}

.heading-anchor-dash[data-level="3"]::after {
  width: 8px;
}

.heading-anchor-dash[data-level="4"]::after {
  width: 4px;
}

.heading-anchor-dash[data-current]::after {
  background: var(--anchor-current);
}

.heading-anchor-panel {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 240px;
  max-height: calc(100dvh - 166px - 16px);
  padding: 12px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
  /* Closed: faded out a little to the right, not hit by the pointer;
     visibility flips after the fade so screen readers skip it too. */
  opacity: 0;
  transform: translateX(calc(var(--direction, 1) * 8px));
  visibility: hidden;
  pointer-events: none;
  transition-property: opacity, transform, visibility;
  transition-duration: 200ms, 200ms, 0s;
  transition-timing-function: ease;
  transition-delay: 0s, 0s, 200ms;
}

/* Open (hover): slides in to its place as it fades in. */
.heading-anchor-panel[data-open] {
  opacity: 1;
  transform: translateX(calc(var(--direction, 1) * 0px));
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.heading-anchor-item {
  flex: none;
  overflow: hidden;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 18px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.heading-anchor-item[data-level="2"] {
  padding-left: 20px;
}

.heading-anchor-item[data-level="3"] {
  padding-left: 32px;
}

.heading-anchor-item[data-level="4"] {
  padding-left: 44px;
}

.heading-anchor-item:hover {
  background: var(--surface);
}

.heading-anchor-item[data-current] {
  color: var(--anchor-active-text);
}

@media (max-width: 70.99rem), (hover: none) {
  .heading-anchor,
  .heading-anchor-panel {
    display: none !important;
  }
}

/* 播放簡報 (JT-303, js/present.ts): full screen (or over the whole window
   when the browser refuses), one page at a time, top aligned in the note's
   reading width; js scales the content up with `zoom` to fill the screen. */
.presenter {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.presenter-page {
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  height: 100%;
  padding: 6vh 4vw;
  overflow: hidden;
}

.presenter-content {
  width: 48rem;
  max-width: 100%;
  flex: none;
}

/* The first heading of a page starts at the top, not under its padding. */
.presenter-content > :first-child {
  margin-top: 0;
  padding-top: 0;
}

.presenter-counter {
  position: absolute;
  right: calc(1.5rem + env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* ‹ › × at the bottom centre: fade out (with the pointer) after 3 s at rest,
   back in on the next move (js sets data-idle). Kept while one is focused
   from the keyboard. */
.presenter-controls {
  position: absolute;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
  transform: translateX(-50%);
  transition: opacity 300ms ease, visibility 300ms;
}

.presenter[data-idle] {
  cursor: none;
}

.presenter[data-idle] .presenter-controls:not(:focus-within) {
  opacity: 0;
  visibility: hidden;
}

.presenter-button {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text);
  font-size: 1.25rem;
}

.presenter-button:hover:not(:disabled) {
  background: var(--surface);
}

.presenter-button:disabled {
  color: var(--muted);
  opacity: 0.4;
}

/* 編輯簡報 (JT-302, js/slide-lines.ts): the bar above the content stays in
   view while scrolling; between blocks, a gap takes a line on click and a
   line (dashed, accent, labelled, not an <hr>) has a × to remove it. Only
   drawn in this mode. */
.slide-edit-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.08);
}

.slide-edit-hint {
  flex: 1;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Above the blocks around it (some are positioned, and the next one comes
   later in the page), so its whole hit area takes the pointer. */
.slide-gap {
  position: relative;
  z-index: 2;
  height: 0;
}

.slide-gap-add {
  position: absolute;
  inset: -10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.75rem;
  opacity: 0;
  cursor: pointer;
  transition: opacity 120ms ease;
}

/* A thin accent rule across the gap, under the label. */
.slide-gap-add::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  border-top: 1px dashed var(--accent);
}

.slide-gap-add:hover,
.slide-gap-add:focus-visible {
  opacity: 1;
}

.slide-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  color: var(--accent);
  font-size: 0.75rem;
  user-select: none;
  cursor: grab;
  touch-action: none;
}

.slide-line::before,
.slide-line::after {
  content: "";
  flex: 1;
  border-top: 2px dashed var(--accent);
}

.slide-gap-add > *,
.slide-line-label {
  position: relative;
  padding: 0 0.5rem;
  background: var(--bg);
}

.slide-line-label {
  order: 0;
  white-space: nowrap;
}

/* A line drags to another gap (JT-295): it fades while a drop line, fixed
   and placed through CSSOM, shows where it lands (grey on a gap that
   already has one: dropping there changes nothing). */
.slide-line.is-dragging {
  opacity: 0.35;
}

body.slide-line-dragging,
body.slide-line-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.slide-drop-line {
  position: fixed;
  z-index: 60;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}

.slide-drop-line[data-valid="false"] {
  background: var(--muted);
  opacity: 0.5;
}

.slide-line::after {
  order: 1;
}

.slide-line-remove {
  order: 2;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--bg);
  color: inherit;
  line-height: 1;
  cursor: pointer;
}

.slide-line-remove:hover {
  background: var(--accent);
  color: var(--accent-text);
}

/* GFM column alignment (:---:) as classes, not inline style (JT-56). */
.markdown-body .align-left {
  text-align: left;
}

.markdown-body .align-center {
  text-align: center;
}

.markdown-body .align-right {
  text-align: right;
}

/* Text indented with Tab (JT-254): steps of the bullet / numbered list
   indent, which is set to the same width so the two stay equal. */
.editor-input {
  --indent-step: 40px;
}

.editor-input ul:not([data-type="taskList"]),
.editor-input ol {
  padding-inline-start: var(--indent-step);
}

/* A whole code block indented (JT-222): its grey box moves the same steps. */
.editor-input :is(p, .code-block).indent-1 {
  margin-left: var(--indent-step);
}

.editor-input :is(p, .code-block).indent-2 {
  margin-left: calc(2 * var(--indent-step));
}

.editor-input :is(p, .code-block).indent-3 {
  margin-left: calc(3 * var(--indent-step));
}

.editor-input :is(p, .code-block).indent-4 {
  margin-left: calc(4 * var(--indent-step));
}

/* Tiptap wraps list item, task item and table cell text in <p>: a list's
   lines are spaced like text (JT-267), a table cell's text keeps the cell's
   own padding only. */
.editor-input th > p,
.editor-input td > p {
  margin: 0;
  padding: 0;
}


/* The editor host also holds the format toolbar and the drag handle, which
   are positioned against it. */
.editor {
  position: relative;
}

/* Format toolbar (components/editor/format_toolbar.rs, JT-73). BubbleMenu sets
   its visibility and position inline; hidden until then. Five buttons per
   row, so the eight make two rows (JT-220). */
/* Never on a touch screen (JT-285): the toolbar above the keyboard instead. */
html[data-touch] .bubble-menu {
  display: none;
}

.bubble-menu {
  position: absolute;
  z-index: 20;
  visibility: hidden;
  display: grid;
  grid-template-columns: repeat(5, auto);
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 16px);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

/* While the link panel is open (js/link-panel.ts, JT-219); BubbleMenu's
   inline visibility would otherwise keep it under the panel. */
.bubble-menu.bubble-menu-covered {
  visibility: hidden !important;
}

/* Buttons are the ticket's SVGs (JT-255) in currentColor. Applied marks
   turn the SVG blue, no blue background; hover keeps its light fill. */
.bubble-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.3rem 0.4rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.bubble-button .icon {
  font-size: 1.15rem;
}

.bubble-button:hover:not(:disabled) {
  background: var(--surface);
}

.bubble-button.active {
  color: var(--accent);
}

/* The colour button is "active" while its panel is open; its A keeps the
   selection's colours rather than turning blue. */
.bubble-button.bubble-color-button.active {
  color: var(--text);
}

/* Colour button and panel (components/editor/color_picker.rs, JT-186). The
   "A" sits in a framed box showing the selection's text colour and background. */
.bubble-color-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem;
}

/* The ticket's DIV (JT-255): a 20px box, 6px radius, a 1px inset frame,
   a 12px "A" in the selection's text colour (on its background). */
.bubble-color-a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.bubble-color-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 21;
  /* JT-255. */
  width: 190px;
  max-width: calc(100vw - 16px);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

.color-section-title {
  margin: 0.35rem 0.15rem 0.3rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.color-section-title:first-child {
  margin-top: 0;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
}

.color-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
}

/* Each swatch framed in its own colour (--swatch-edge from the palette
   classes, the default text colour for the defaults); hover and the
   applied one (active) thicken the frame in that colour. No blue outline,
   no grey fill (JT-255). An inset shadow, so the size never changes. */
.color-option .color-swatch {
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--swatch-edge, var(--text)) 30%, transparent);
}

.color-option:hover .color-swatch,
.color-option:focus-visible .color-swatch,
.color-option.active .color-swatch {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--swatch-edge, var(--text)) 70%, transparent);
}

.color-option:focus-visible {
  outline: none;
}

/* Link hover bar (js/link-hover.ts, JT-149, JT-219): one row under a hovered
   link (above it while the selection toolbar shows): 🌐 URL, copy, Edit.
   Links show a pointer even while the note is editable. */
.ProseMirror a[href] {
  cursor: pointer;
}

.link-hover {
  position: absolute;
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 16px);
  padding: 4px 4px 4px 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
  font-size: 0.875rem;
}

.link-hover-globe {
  flex: none;
  color: var(--muted);
}

.link-hover-url {
  min-width: 0;
  max-width: 20rem;
  margin: 0 0.35rem 0 0.4rem;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-hover .bubble-button {
  gap: 0.25rem;
  min-width: 1.75rem;
  color: var(--muted);
  font-weight: 500;
}

.link-hover .bubble-button .icon {
  font-size: 1rem;
}

.link-hover .bubble-button[data-state="done"] {
  color: var(--success);
}

.link-hover .bubble-button[data-state="failed"] {
  color: var(--danger);
}

.link-copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Link panel (js/link-panel.ts, JT-219): Page or URL, Link title, then
   Remove link under a divider. Fields are filled light grey; the focused one
   gets an accent frame. */
.link-panel {
  position: absolute;
  z-index: 22;
  display: grid;
  gap: 0.5rem;
  width: 17rem;
  max-width: calc(100vw - 16px);
  padding: 0.6rem 0.5rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
  font-size: 0.875rem;
}

.link-panel-field {
  display: grid;
  gap: 0.3rem;
}

.link-panel-label {
  padding: 0 0.15rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.link-panel-field input {
  width: 100%;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.link-panel-field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 1px var(--accent);
}

/* Page search under "Page or URL" (JT-262): up to five notes, icon and
   title, no breadcrumb; the highlighted (↑↓ or pointer) row is filled. */
.link-panel-results {
  display: grid;
  gap: 1px;
  margin: -0.2rem -0.25rem 0;
}

.link-panel-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.9rem;
  padding: 0.25rem 0.4rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
}

.link-panel-result.active {
  background: var(--surface);
}

.link-panel-result-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.link-panel-result-icon .icon {
  font-size: 1.1rem;
}

.link-panel-result-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-panel-empty {
  margin: -0.2rem 0 0;
  padding: 0 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.link-panel-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.8rem;
}

.link-panel-divider {
  width: calc(100% + 1rem);
  margin: 0 -0.5rem;
  border: none;
  border-top: 1px solid var(--border);
}

.link-panel-remove {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.35rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  text-align: left;
}

.link-panel-remove:hover {
  background: var(--surface);
}

.link-panel-remove .icon {
  font-size: 1.15rem;
  color: var(--muted);
}

/* Block controls (@tiptap/extension-drag-handle, JT-73, JT-118): shown by
   the extension left of the hovered block, inside the editor's left
   padding: "+" (insert menu) then the grip that drags the block. */
.block-controls {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  margin-right: 0.15rem;
  /* 0.25rem further left of the block (JT-169 follow-up). The drag handle
     extension places the element by its box (the margin does not move it),
     so this shifts it; `translate` composes with any transform it sets. */
  translate: -0.25rem 0;
  /* Hidden until a block is hovered, then a 0.2s fade in; leaving hides
     them at once (JT-150). The transition is on the shown state only, so
     there is no fade out. */
  opacity: 0;
  transition: none;
}

.block-controls[data-visible="true"] {
  opacity: 1;
  transition: opacity 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .block-controls[data-visible="true"] {
    transition: none;
  }
}

.block-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.6rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  /* The "+" is an SVG (JT-169) sized by this. */
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.block-add:hover,
.block-add:focus-visible {
  background: var(--surface);
  color: var(--text);
}

/* A button now (JT-120): a click opens "轉換成", a drag still moves the block. */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.6rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: grab;
}

.drag-handle:focus-visible {
  background: var(--surface);
  color: var(--text);
}

/* The grip's six dots, an SVG (JT-169), about as big as the old "⋮⋮". */
.drag-handle {
  font-size: 1.05rem;
}

/* Inline SVG icons (js/icons.ts): 1em square in currentColor; they never
   take the pointer, so a click or drag lands on the button. */
.icon {
  flex: none;
  pointer-events: none;
}

.icon-sideways {
  transform: rotate(90deg);
}

/* The chevron (JT-246): 12px, muted, pointing down; it turns to point right
   when its holder is collapsed (sidebar sections and pages) or marks a
   submenu / a row with children, over 200ms. */
.icon-chevron {
  width: 12px;
  height: 12px;
  color: var(--muted);
  transition: transform 200ms ease-out;
}

.is-collapsed > .icon-chevron,
.chevron-right > .icon-chevron,
.icon-chevron.chevron-right {
  transform: rotate(-90deg);
}

@media (prefers-reduced-motion: reduce) {
  .icon-chevron {
    transition: none;
  }
}

.slash-menu-submenu {
  display: inline-flex;
  flex: none;
  align-items: center;
}

.drag-handle:hover {
  background: var(--surface);
  color: var(--text);
}

.drag-handle:active {
  cursor: grabbing;
}

/* Read only (a viewer or a locked page, JT-85, JT-118): no "+" and no
   handle. The extension hides them too; the controls are the editable
   element's sibling, so the rule keys off their shared `.editor`. */
.editor:has(> .editor-input[contenteditable="false"]) .block-controls {
  display: none;
}

/* The "+" insert menu (JT-118): a filter box over the slash menu's list. */
.block-menu {
  position: absolute;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 16rem;
  max-width: calc(100vw - 16px);
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

.block-menu-filter {
  width: 100%;
  padding: 0.3rem 0.45rem;
}

/* 取代 → 填入連結 (js/block-replace.ts, JT-195/196): a URL field and 套用. */
.url-form {
  width: 20rem;
}

.url-form-row {
  display: flex;
  gap: 0.35rem;
}

.url-form-row .block-menu-filter {
  flex: 1;
  min-width: 0;
}

.url-form-apply {
  flex: none;
  padding: 0.25rem 0.6rem;
}

.url-form-error {
  padding: 0 0.15rem;
  color: var(--danger, #c0392b);
  font-size: 0.8rem;
}

/* The list inside sits flat in the menu box. */
.block-menu .slash-menu {
  width: auto;
  max-height: 18rem;
  padding: 0;
  border: none;
  box-shadow: none;
}

/* Toggle list (JT-117): ▸ / ▾ button, summary, then the content, which the
   extension hides with the `hidden` attribute while closed. */
.editor-input [data-type="details"] {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  margin: 0.25rem 0;
}

.editor-input [data-type="details"] > button {
  flex: none;
  width: 1.4rem;
  height: 1.6em;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.editor-input [data-type="details"] > button:hover {
  background: var(--surface);
  color: var(--text);
}

.editor-input [data-type="details"] > button::before {
  content: "▸";
}

.editor-input [data-type="details"].is-open > button::before {
  content: "▾";
}

.editor-input [data-type="details"] > div {
  flex: 1;
  min-width: 0;
}

.editor-input [data-type="details"] summary {
  display: block;
  font-weight: 500;
  list-style: none;
}

.editor-input [data-type="details"] summary::-webkit-details-marker {
  display: none;
}

/* Attachments (JT-94): uploaded images, file cards, upload progress. */
/* Images are centred (JT-171, after the reference on JT-165). */
.editor-input .attachment-image {
  position: relative;
  margin: 0.5rem 0;
  text-align: center;
}

/* The image wrapper (the reference's .notion-image-wrapper): an
   inline-block that follows its width. Without a size it takes the image's
   own width; resized, `scale`% of the content width set through CSSOM (so a
   small image can grow to the full width), animated between steps. */
.editor-input .attachment-image-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  user-select: none;
  transition: width 0.15s ease;
}

.editor-input .attachment-image-frame.sized {
  min-width: 100px;
}

.editor-input .attachment-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.editor-input .attachment-image-frame:not(.sized) img {
  width: auto;
}

/* The resize handles, as in the reference: a small dark bar on each side,
   shown while the image is hovered or being resized. */
.editor-input .resize-handle {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 6px;
  height: 48px;
  box-sizing: border-box;
  border: 1px solid rgb(255 255 255 / 0.8);
  border-radius: 4px;
  background-color: rgb(0 0 0 / 0.6);
  opacity: 0;
  cursor: ew-resize;
  transform: translateY(-50%);
  transition: opacity 0.2s;
}

.editor-input .attachment-image-frame:hover .resize-handle,
.editor-input .attachment-image-frame.is-resizing .resize-handle {
  opacity: 1;
}

.editor-input .resize-handle.left {
  left: 8px;
}

.editor-input .resize-handle.right {
  right: 8px;
}

.editor-input[contenteditable="false"] .resize-handle {
  display: none;
}

/* The image menu's "⋯" (JT-172): top right, on hover or keyboard focus;
   also for viewers (查看, 下載). */
.editor-input .attachment-image-more {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.editor-input .attachment-image-frame:hover .attachment-image-more,
.editor-input .attachment-image-frame.menu-open .attachment-image-more,
.editor-input .attachment-image-more:focus-visible {
  opacity: 1;
}

.editor-input .attachment-image-more:hover {
  background: var(--surface);
}

.editor-input .attachment-image-more[hidden] {
  display: none;
}

@media (hover: none) {
  .editor-input .attachment-image-more {
    opacity: 1;
  }
}

/* 查看 (JT-172): the image enlarged and centred over a grey backdrop;
   clicking the backdrop or Escape closes it. */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgb(40 44 52 / 0.72);
  cursor: zoom-out;
  animation: image-viewer-fade 0.18s ease;
}

.image-viewer:focus {
  outline: none;
}

.image-viewer-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.35);
  cursor: default;
  animation: image-viewer-zoom 0.22s ease;
}

@keyframes image-viewer-fade {
  from {
    opacity: 0;
  }
}

@keyframes image-viewer-zoom {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-viewer,
  .image-viewer-img {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .editor-input .attachment-image-frame,
  .editor-input .resize-handle {
    transition: none;
  }
}

.editor-input .attachment-image.broken img {
  min-width: 8rem;
  min-height: 3rem;
  border: 1px dashed var(--border);
}

.editor-input .attachment-image.ProseMirror-selectednode img,
.editor-input .attachment-card.ProseMirror-selectednode {
  outline: 2px solid var(--accent);
}

.editor-input .attachment-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.attachment-card-name {
  flex: 1 1 10rem;
  min-width: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.attachment-card-size {
  color: var(--muted);
  font-size: 0.85rem;
}

.attachment-card-download {
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
}

.attachment-status {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.85rem;
}

.attachment-status progress {
  flex: 1;
  height: 0.4rem;
}

.attachment-status.failed {
  color: var(--danger);
}

.attachment-status button {
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}

/* Sub-page block (JT-105): a page icon and the title as a link. A page that
   is gone has no block (JT-263), so there is no "deleted" look. */
.editor-input .page-link-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 0;
  border-radius: var(--radius);
}

.editor-input .page-link-block.ProseMirror-selectednode {
  outline: 2px solid var(--accent);
}

.editor-input a.page-link {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.editor-input a.page-link:hover {
  background: var(--surface);
}

/* The sidebar's page icon (JT-163), at the sidebar's size. */
.page-link-icon {
  display: inline-flex;
  flex: none;
}

.page-link-icon .icon-page {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
  overflow: visible;
}

.page-link-title {
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.page-link-title.untitled {
  color: var(--muted);
}

.read-only-badge {
  display: inline-block;
  width: fit-content;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}

/* Slash command menu (js/slash/, JT-72): positioned by the Suggestion plugin. */
.slash-menu {
  z-index: 20;
  width: 16rem;
  max-width: calc(100vw - 16px);
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

.slash-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
}

.slash-menu-item code {
  color: var(--muted);
  font-size: 0.8rem;
}

/* A row's key shortcut (the grip menu's ⌘D / Del, JT-271): grey, at the right. */
.slash-menu-item .slash-menu-shortcut {
  margin-left: auto;
  color: rgb(161, 158, 153);
  font-family: inherit;
  text-align: right;
  white-space: nowrap;
}

/* Icon, then the title taking the room, then the hint. */
.slash-menu-icon {
  flex: none;
  width: 1.6rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* The shared menu SVGs (JT-247) at 20px, centred in the icon column. */
.slash-menu-icon .icon-menu {
  display: block;
  margin: 0 auto;
  font-size: 20px;
}

.slash-menu-item > span:not(.slash-menu-icon, .slash-menu-check) {
  flex: 1;
  min-width: 0;
}

/* "轉換成" (JT-120): the block's current type. */
.slash-menu-item.current {
  font-weight: 600;
}

.slash-menu-check {
  flex: none;
  color: var(--accent);
}

.slash-menu-item[aria-selected="true"],
.slash-menu-item:hover {
  background: var(--surface);
}

/* The grip menu (js/grip-menu.ts, JT-190): the block's type above the list,
   like the sidebar's section headings, and a line between groups. The
   highlighted row is shown by its background only (no outline). */
/* A group heading inside a menu list (the "+" menu's Blocks / Media, JT-198). */
.slash-menu-group {
  padding: 0.25rem 0.6rem 0.15rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  user-select: none;
}

.block-menu-type {
  padding: 0.15rem 0.6rem 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  user-select: none;
}

.slash-menu-separator {
  margin: 0.25rem 0;
  border-top: 1px solid var(--border);
}

.slash-menu-empty {
  padding: 0.35rem 0.6rem;
  color: var(--muted);
}


/* Note typography inside the editor (its editable element has
   .markdown-body). */
.markdown-body {
  overflow-wrap: break-word;
}

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

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

/* Lines (JT-267, from its ticket comment): the space between blocks is each
   line's own padding (6px at the sides and below, more above a heading), so
   no block margins. A whole block indented (JT-222, JT-254) still uses
   margin-left. */
.markdown-body :is(h1, h2, h3, h4) {
  margin: 0;
  padding: 6px 6px 6px;
  font-weight: 600;
}

.markdown-body h1 {
  padding-top: 30px;
  font-size: 30px;
  line-height: 43px;
}

.markdown-body h2 {
  padding-top: 26px;
  font-size: 24px;
  line-height: 35.1875px;
}

.markdown-body h3 {
  padding-top: 22px;
  font-size: 20px;
  line-height: 30px;
}

.markdown-body h4 {
  padding-top: 18px;
  font-size: 18px;
  line-height: 27.3906px;
}

/* Text, and the lines of bulleted, numbered and task lists. */
.markdown-body p {
  margin: 0;
  padding: 6px;
  font-size: 16px;
  line-height: 28px;
}

.markdown-body :is(ul, ol) {
  margin-block: 0;
}

/* Bulleted and numbered lists (JT-267): 2px above and below each item's
   lines, so items sit closer than paragraphs; the outermost list adds 4px
   at its top and bottom, keeping the 6px around the whole list. */
.markdown-body :is(ul:not([data-type="taskList"]), ol) > li > p {
  padding-block: 2px;
}

.markdown-body :is(ul:not([data-type="taskList"]), ol):not(li *) {
  padding-block: 4px;
}

.markdown-body code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--surface);
}

.markdown-body pre {
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.markdown-body pre code {
  padding: 0;
  background: none;
}

.markdown-body blockquote {
  /* Spaced by its lines' padding (JT-267). */
  margin: 0;
  padding: 0 1em;
  border-left: 4px solid var(--border);
  color: var(--muted);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
}

/* In the editor (JT-297) a divider is a box one control tall with its 1px
   line drawn in the middle: something to point at, and the "+ ⋮⋮" are
   centred on its box, so on the line. */
.editor-input hr {
  height: 1.6rem;
  margin: 0.25rem 0;
  border: none;
  background: linear-gradient(var(--border), var(--border)) center / 100% 1px no-repeat;
}

.markdown-body img {
  max-width: 100%;
}

.markdown-body s {
  color: var(--muted);
}

/* GFM tables: scroll sideways instead of overflowing narrow screens. */
.markdown-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 1em 0;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.markdown-body th,
.markdown-body td {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
}

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

.markdown-body tbody tr:nth-child(even) {
  background: var(--row-alt);
}

/* A cell's palette background (JT-173) wins over the header surface and
   the striping; .jt-bg-<id> sets --jt-bg. */
.markdown-body th[data-bg],
.markdown-body td[data-bg] {
  background-color: var(--jt-bg);
}

/* GFM task lists: the checkbox replaces the bullet; done items fade out.
   Tiptap's task items are
   ul[data-type="taskList"] > li[data-checked] > label (checkbox) + div. */
.editor-input ul[data-type="taskList"] {
  list-style: none;
  padding-left: 0.25rem;
}

.editor-input ul[data-type="taskList"] ul[data-type="taskList"] {
  padding-left: 1.5rem;
}

.editor-input ul[data-type="taskList"] > li {
  display: flex;
  align-items: flex-start;
  gap: 0.45em;
}

.editor-input ul[data-type="taskList"] > li > label {
  flex: none;
  user-select: none;
  /* Level with the text's first line (JT-267): below its 6px padding, one
     28px line tall, the checkbox centred in it. */
  display: flex;
  align-items: center;
  height: 28px;
  margin-top: 6px;
}

.editor-input ul[data-type="taskList"] > li > div {
  flex: 1;
  min-width: 0;
}

.editor-input ul[data-type="taskList"] > li[data-checked="true"] > div {
  color: var(--muted);
  text-decoration: line-through;
}

/* Selected blocks (js/block-select.ts, JT-176): a light-blue background on
   each whole block, and the box being dragged. */
.editor-input > .block-selected {
  border-radius: 4px;
  background-color: var(--block-selected);
  box-shadow: 0 0 0 2px var(--block-selected);
}

.editor-input > .block-selected ::selection {
  background: transparent;
}

.block-marquee {
  position: fixed;
  z-index: 40;
  border: 1px solid var(--block-marquee-border);
  border-radius: 2px;
  background: var(--block-selected);
  pointer-events: none;
}

/* Inline checkboxes (js/inline-checkbox.ts, JT-180): sit on the text line. */
.inline-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  margin: 0 0.15em;
  vertical-align: -0.1em;
  user-select: none;
}

.inline-checkbox {
  width: 1em;
  height: 1em;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.editor-input[contenteditable="false"] .inline-checkbox {
  cursor: default;
}

/* Editor tables (js/table.ts, js/table-controls.ts, JT-158): the wrapper is a
   2×2 grid, the table with the "add column" bar to its right (as tall as
   the table) and the "add row" bar under it (as wide); the corner is empty
   (the table options are in the block grip's menu). It scrolls sideways when the table is wider than the page. Column widths
   come from the table view's <colgroup>, set through CSSOM (CSP-safe). */
.editor-input .tableWrapper {
  display: grid;
  grid-template-columns: max-content 1.25rem;
  grid-template-rows: auto 1.25rem;
  gap: 2px;
  /* Room above and to the left for the row / column handles (JT-170),
     which sit on the table's edges; the wrapper scrolls, so they would be
     clipped. The negative margin keeps the table where it was. */
  margin: calc(1em - 0.6rem) 0 1em -0.6rem;
  padding: 0.6rem 0 0 0.6rem;
  overflow-x: auto;
}

.editor-input .tableWrapper > table {
  grid-area: 1 / 1;
  display: table;
  max-width: none;
  margin: 0;
  overflow: visible;
  table-layout: fixed;
}

/* A new empty table needs room to click into its cells; a dragged width
   (the colwidth attribute) may go narrower. */
.editor-input th,
.editor-input td {
  position: relative;
}

.editor-input th:not([colwidth]),
.editor-input td:not([colwidth]) {
  min-width: 5rem;
}

.table-control {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  /* Shown on hover, fading in like the block controls (JT-150). */
  opacity: 0;
  transition: none;
}

.tableWrapper:hover .table-control,
.table-control:focus-visible {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.table-control:hover {
  background: var(--border);
  color: var(--text);
}

.table-add-column {
  grid-area: 1 / 2;
}

.table-add-row {
  grid-area: 2 / 1;
}

/* Touch screens have no hover: keep them visible. */
@media (hover: none) {
  .table-control {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tableWrapper:hover .table-control {
    transition: none;
  }
}

/* Row and column handles (js/table-handles.ts, JT-170): a small grip on
   the top edge of the hovered (or caret) cell's column and on the left
   edge of its row; clicking one outlines that column / row and opens its
   menu. They are widgets inside the first row's / first column's cell.
   At rest a handle is a short thin bar on the border (::before); hovered,
   focused or with its menu open it becomes the bordered six-dot grip (as
   in the ticket's screenshots). */
.table-handle {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.table-handle::before {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.45;
}

.table-handle-column::before {
  width: 1rem;
  height: 3px;
}

.table-handle-row::before {
  width: 3px;
  height: 1rem;
}

.table-handle .icon {
  opacity: 0;
}

.table-handle:hover,
.table-handle:focus-visible,
.table-handle.open {
  border-color: var(--border);
  background: var(--bg);
  color: var(--text);
}

.table-handle:hover::before,
.table-handle:focus-visible::before,
.table-handle.open::before {
  opacity: 0;
}

.table-handle:hover .icon,
.table-handle:focus-visible .icon,
.table-handle.open .icon {
  opacity: 1;
}

.table-handle:hover {
  background: var(--surface);
}

/* The caret's cell (JT-170 follow-up): a solid accent frame, while the
   editor has focus. */
.editor-input.ProseMirror-focused .table-cell-current {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.table-handle-column {
  top: 0;
  left: 50%;
  width: 1.5rem;
  height: 0.9rem;
  transform: translate(-50%, -50%);
}

.table-handle-row {
  top: 50%;
  left: 0;
  width: 0.9rem;
  height: 1.5rem;
  transform: translate(-50%, -50%);
}

/* The picked column / row, outlined in the accent colour. */
.editor-input .table-axis-picked {
  /* Over the cell's own background (header surface or JT-173 colour), not instead of it. */
  background-image: linear-gradient(
    color-mix(in srgb, var(--accent) 6%, transparent),
    color-mix(in srgb, var(--accent) 6%, transparent)
  );
}

.editor-input .table-axis-column {
  box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent);
}

.editor-input .table-axis-column.table-axis-first {
  box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent), inset 0 2px 0 var(--accent);
}

.editor-input .table-axis-column.table-axis-last {
  box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent), inset 0 -2px 0 var(--accent);
}

.editor-input .table-axis-row {
  box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent);
}

.editor-input .table-axis-row.table-axis-first {
  box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent), inset 2px 0 0 var(--accent);
}

.editor-input .table-axis-row.table-axis-last {
  box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent), inset -2px 0 0 var(--accent);
}

/* A one-cell column / row is both first and last. */
.editor-input .table-axis-column.table-axis-first.table-axis-last,
.editor-input .table-axis-row.table-axis-first.table-axis-last {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Read only (a viewer, a locked page): no controls, no resizing. */
.editor-input[contenteditable="false"] .table-handle,
.editor-input[contenteditable="false"] .table-control,
.editor-input[contenteditable="false"] .column-resize-handle {
  display: none;
}

/* Column resizing (prosemirror-tables): a line on the border being dragged. */
.editor-input.resize-cursor {
  cursor: col-resize;
}

.editor-input .column-resize-handle {
  position: absolute;
  top: 0;
  right: -2px;
  bottom: -1px;
  width: 4px;
  background: var(--accent);
  pointer-events: none;
}

.editor-input .selectedCell {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.editor-input img.ProseMirror-selectednode {
  outline: 2px solid var(--accent);
}

/* Syntax highlighting: lowlight (CodeBlockLowlight, js/extensions.ts) adds
   highlight.js's hljs-* classes to fenced code with a language; colors are
   tokens per scheme. */
.markdown-body .hljs-comment,
.markdown-body .hljs-quote {
  color: var(--hl-comment);
  font-style: italic;
}

.markdown-body .hljs-keyword,
.markdown-body .hljs-selector-tag,
.markdown-body .hljs-meta .hljs-keyword,
.markdown-body .hljs-doctag {
  color: var(--hl-keyword);
}

.markdown-body .hljs-string,
.markdown-body .hljs-regexp,
.markdown-body .hljs-meta .hljs-string,
.markdown-body .hljs-addition {
  color: var(--hl-string);
}

.markdown-body .hljs-number,
.markdown-body .hljs-literal,
.markdown-body .hljs-symbol,
.markdown-body .hljs-variable.constant_ {
  color: var(--hl-number);
}

.markdown-body .hljs-title,
.markdown-body .hljs-title.function_,
.markdown-body .hljs-section {
  color: var(--hl-function);
}

.markdown-body .hljs-title.class_,
.markdown-body .hljs-type,
.markdown-body .hljs-built_in,
.markdown-body .hljs-selector-class,
.markdown-body .hljs-selector-id {
  color: var(--hl-type);
}

.markdown-body .hljs-attr,
.markdown-body .hljs-attribute,
.markdown-body .hljs-property,
.markdown-body .hljs-name,
.markdown-body .hljs-tag,
.markdown-body .hljs-meta {
  color: var(--hl-attr);
}

.markdown-body .hljs-deletion {
  color: var(--danger);
}

.markdown-body .hljs-emphasis {
  font-style: italic;
}

.markdown-body .hljs-strong {
  font-weight: 600;
}

/* Confirm dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 0.45);
  z-index: 50;
}

.dialog {
  width: min(26rem, 100%);
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}

.dialog h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* "關於" (components/brand_menu.rs, JT-135). */
.about-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.about-close {
  padding: 0.1rem 0.45rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.about-close:hover {
  background: var(--surface);
  color: var(--text);
}

.about-info {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0 0 1.25rem;
}

.about-info dt {
  color: var(--muted);
}

.about-info dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.about .dialog-actions {
  align-items: center;
}

.about-copied {
  margin-right: auto;
  font-size: 0.9rem;
}

/* 「安裝 App」 steps (components/brand_menu.rs, JT-280). */
.install-steps p {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.9rem;
}

.install-steps-list {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding-left: 1.4rem;
}

/* 「分享」 (components/share_dialog.rs, JT-226). */
.share-dialog {
  width: min(30rem, 100%);
}

.share-hint {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.85rem;
}

.share-add {
  display: flex;
  gap: 0.5rem;
}

.share-add input {
  flex: 1;
  min-width: 0;
}

/* 「匯出」 (components/export_dialog.rs, JT-298): two format rows, the step
   under way and any error, 取消 / 匯出. */
.export-formats {
  display: grid;
  gap: 0.5rem;
  margin: 0.5rem 0 0.25rem;
  padding: 0;
  border: none;
}

/* .dialog .export-format: above `.dialog label { display: block }`. */
.dialog .export-format {
  display: flex;
  margin: 0;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.export-format:has(input:checked) {
  border-color: var(--accent);
}

.export-formats:disabled .export-format {
  cursor: default;
  opacity: 0.6;
}

.export-format input {
  margin: 0.2rem 0 0;
  accent-color: var(--accent);
}

.export-format-text {
  display: grid;
  gap: 0.15rem;
}

.export-format-text .muted {
  font-size: 0.85rem;
}

.export-progress {
  min-height: 1.2em;
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
}

.share-error {
  min-height: 1.2em;
  margin: 0.3rem 0;
  color: var(--danger, #c0392b);
  font-size: 0.85rem;
}

.share-recipients {
  max-height: 12rem;
  margin: 0 0 0.5rem;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.share-recipients li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.share-email {
  overflow-wrap: anywhere;
}

.share-public {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0.25rem 0 1rem;
  padding: 0.5rem 0;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.share-public-label {
  display: flex;
  flex-direction: column;
}

.share-public-label .muted {
  font-size: 0.85rem;
}

.share-public[aria-checked="true"] .more-switch {
  background: var(--accent);
}

.share-public[aria-checked="true"] .more-switch-knob {
  transform: translateX(12px);
}

.share-actions {
  align-items: center;
}

.share-stop {
  margin-right: auto;
}

.share-confirm,
.share-private {
  margin-right: auto;
  font-size: 0.9rem;
}

.share-link {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

/* Toasts: fixed bottom right, newest last. */
.toasts {
  position: fixed;
  /* Above the home bar of an installed app (JT-282). */
  right: calc(1rem + env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(24rem, calc(100vw - 2rem));
  z-index: 100;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
}

.toast span {
  flex: 1;
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-close {
  padding: 0 0.4rem;
  border: none;
  background: none;
  font-size: 1.1rem;
  line-height: 1.4;
}

/* "復原" on the delete toast (JT-90). */
.toast-action {
  padding: 0.1rem 0.6rem;
  font-weight: 600;
  white-space: nowrap;
}

/* A list item dragged by its own grip (JT-274): this line shows where it
   lands, indented to its depth; the default drop cursor is hidden then. */
.list-drop-line {
  position: fixed;
  z-index: 60;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.6;
  pointer-events: none;
}

body.list-dragging .jt-dropcursor {
  display: none;
}

/* A shared note (pages/shared_note.rs, JT-227). Read without signing in it
   has no sidebar, so the page starts at the left edge. */
@media (min-width: 48rem) {
  body:has(.shared-alone) .app-header,
  body:has(.shared-alone) .app-main {
    margin-left: 0;
  }
}

.shared-crumbs .crumb {
  cursor: default;
}

.shared-icon {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 2.5rem;
  line-height: 1.2;
}

.shared-title {
  margin: 0 0 0.5rem;
}

.shared-denied {
  margin-top: 4rem;
  text-align: center;
}

.shared-denied h1 {
  font-size: 1.4rem;
}

/* A phone's page (JT-283), last in the file so it wins over the rules
   above: a smaller title and icon, a shorter page bar and breadcrumb, and
   less padding around the page. */
@media (max-width: 47.99rem) {
  .container {
    padding: 0.75rem;
  }

  .notes-scroll {
    margin-inline: -0.75rem;
    padding: 0 0.75rem 0.75rem;
  }

  .page-bar {
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .breadcrumb .crumb {
    max-width: 8rem;
  }

  /* 「已儲存」 goes; a problem (unsaved, conflict) still shows. */
  .page-save-status:not(.alert) {
    display: none;
  }

  textarea.note-title {
    font-size: 1.75rem;
    line-height: 1.25;
  }

  .note-icon {
    width: 56px;
    height: 56px;
    font-size: 2.5rem;
  }

  /* No room kept for the "+ ⋮⋮" block controls on a touch screen, which
     never shows them (JT-285). */
  html[data-touch] textarea.note-title,
  html[data-touch] .note-icon-row,
  html[data-touch] .editor-input {
    padding-left: 0;
  }
}

/* The toolbar above the on-screen keyboard (JT-284, keyboard_bar.rs): fixed
   to the bottom, lifted above the keyboard by js/keyboard-bar.ts. Buttons
   44px; 關閉鍵盤 at the right, the rest scrolls sideways. */
.keyboard-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  border-top: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 -2px 8px rgb(0 0 0 / 0.06);
}

.keyboard-bar[hidden] {
  display: none;
}

.keyboard-bar-row {
  display: flex;
  align-items: center;
}

.keyboard-bar-scroll,
.keyboard-bar-sub {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.keyboard-bar-scroll {
  display: flex;
  flex: 1;
  min-width: 0;
}

.keyboard-bar-sub {
  border-bottom: 1px solid var(--border);
}

.keyboard-bar-scroll::-webkit-scrollbar,
.keyboard-bar-sub::-webkit-scrollbar {
  display: none;
}

.keyboard-bar .keyboard-bar-button,
.keyboard-bar .bubble-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

.keyboard-bar .icon {
  font-size: 1.25rem;
}

.keyboard-bar .keyboard-bar-button.active {
  color: var(--accent);
}

.keyboard-bar .keyboard-bar-close {
  border-left: 1px solid var(--border);
}

/* 顏色 (A): one row scrolling sideways (.keyboard-bar-sub), three groups
   side by side, 最近使用, 文字顏色 and 背景顏色, split by two vertical
   dividers. Each: its name on top, its swatches below, no line between. */
.keyboard-bar-colors {
  display: flex;
  align-items: stretch;
  padding: 0.25rem 0.25rem 0;
}

.keyboard-bar-color-group {
  display: flex;
  flex: none;
  flex-direction: column;
  padding: 0 0.25rem;
}

.keyboard-bar-color-title {
  padding: 0.15rem 0.25rem 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.keyboard-bar-color-swatches {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  min-height: 44px;
}

.keyboard-bar-color-empty {
  padding: 0 0.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.keyboard-bar-color-divider {
  flex: none;
  width: 1px;
  margin: 0.25rem 0.25rem 0.5rem;
  background: var(--border);
}

.keyboard-bar .color-option {
  flex: none;
  width: 40px;
  height: 40px;
}

.keyboard-bar .color-option .color-swatch {
  width: 1.75rem;
  height: 1.75rem;
}

/* The note's end can scroll up above the toolbar. */
html.keyboard-open .notes-scroll {
  padding-bottom: 6rem;
}
/* A menu above the keyboard toolbar is only as tall as the room there
   (block-menu.ts `top-start`); its list scrolls. */
.block-menu .slash-menu {
  min-height: 0;
}

/* Touch (JT-287). Image resize handles: no hover, so they show on the
   selected image, with a larger hit area (28×56px) around the bar, and the
   page does not pan under them (js/attachments.ts uses pointer events). */
.editor-input .resize-handle {
  touch-action: none;
}

.editor-input .resize-handle::before {
  position: absolute;
  inset: -4px -11px;
  content: "";
}

html[data-touch] .editor-input .attachment-image.ProseMirror-selectednode .resize-handle {
  opacity: 1;
}

/* Code blocks keep their lines and scroll sideways (as on a desktop). */
html[data-touch] .editor-input pre {
  overflow-x: auto;
  white-space: pre;
  overscroll-behavior-x: contain;
}

/* A long press in a table selects cells (js/table-touch.ts), not text. */
html[data-touch] .editor-input td,
html[data-touch] .editor-input th {
  -webkit-touch-callout: none;
}

/* 拖曳模式 (JT-286, js/drag-mode.ts): a grip left of every block and list
   item; the note moves right to make room. Only a grip drags: it takes the
   finger (no panning), the rest of the page scrolls as usual. */
.editor-input.drag-mode,
html[data-touch] .editor-input.drag-mode {
  padding-left: 2.75rem;
}

.editor-input .drag-mode-grip {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-left: -2.6rem;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.editor-input .drag-mode-grip .icon {
  font-size: 1.25rem;
}

.editor-input .drag-mode-grip.is-dragging {
  background: var(--surface);
  color: var(--accent);
  cursor: grabbing;
}

.editor-input .drag-mode-source {
  opacity: 0.45;
}

/* The copy following the finger (JT-320), like the desktop grip's drag
   image: half transparent, the original's width, never in the way of
   where it lands. Placed through the CSSOM (left, top, width, transform). */
.drag-mode-ghost {
  position: fixed;
  z-index: 61;
  margin: 0;
  padding: 0;
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

.drag-mode-ghost > :first-child,
.drag-mode-ghost > ul > li:first-child,
.drag-mode-ghost > ol > li:first-child {
  margin-top: 0;
}

.drag-mode-ghost > :last-child {
  margin-bottom: 0;
}

/* Grips sit at the start of a list item's content, left of its bullet. */
.editor-input.drag-mode li > .drag-mode-grip {
  margin-left: -4rem;
}

/* 復原 / 重做 (icons) left of 完成, at the right of the mode's bar. */
.drag-mode-bar .drag-mode-history {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
}

.drag-mode-bar .drag-mode-history .icon {
  font-size: 1.25rem;
}

.drag-mode-bar .drag-mode-history:disabled {
  color: var(--muted);
  opacity: 0.4;
  cursor: default;
}

.drag-mode-bar .primary {
  margin-left: 0.25rem;
}
