@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-latin.woff2") format("woff2");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text: #2f363d;
  --ink: #1b2228;
  --muted: #66707a;
  --accent-soft: #e4f4f1;
  --accent-strong: #0a6b60;
  --blue: #0e8577;
  --yellow: #f4a62a;
  --white: #ffffff;
  --line: #eeeeee;
  --border: #e3e3e3;
  --panel: #fbfbfc;
  --page: #f5f6f7;
  --button-grey: #dddddd;
  --glass: #ffffff99;
  --radius-card: 12px;
  --radius-btn: 6px;
  --shadow-card: rgba(0, 0, 0, 0.18) 0px 3px 6px 0px;
  --sp-2: 2px;
  --sp-3: 3px;
  --sp-4: 4px;
  --sp-6: 6px;
  --sp-10: 10px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-20: 20px;
  --sp-30: 30px;
  --sp-40: 40px;
  --sp-60: 60px;
  --sp-80: 80px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3 { margin: 0; }
svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Dashboard shell: app bar on top, page below ---------- */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100%; background: var(--page); }
.appbar { flex: none; display: flex; align-items: center; gap: 24px; min-height: 60px; padding: 0 24px; background: var(--white); border-bottom: 1px solid var(--border); }
.logo { display: block; flex: none; }
.logo img { display: block; height: 28px; width: auto; }
.appnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.appnav::-webkit-scrollbar { display: none; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 8px; font-size: 14.5px; font-weight: 500; color: var(--muted); background: none; border: 0; white-space: nowrap; }
.nav-link .icon { width: 18px; height: 18px; }
.nav-link:hover { background: var(--page); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.appbar-end { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--muted); padding: 0; }
.icon-btn:hover { background: var(--page); color: var(--ink); }
.icon-btn .icon { width: 18px; height: 18px; }
.btn {
  display: inline-flex;
  white-space: nowrap; /* labels stay on one line; the button grows instead */
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 96px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  background: var(--white);
}
.btn .icon { width: 18px; height: 18px; }
.btn-yellow { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.btn-yellow:hover { filter: brightness(0.97); }
.btn-outline { border-color: var(--blue); color: var(--blue); background: var(--white); }
.btn-outline:hover { background: #eef8f6; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-plain { border-color: var(--border); }
.new-btn { min-width: 0; }
.new-btn .icon { stroke-width: 2; }

.main { flex: 1; min-height: 0; overflow-y: auto; padding: 32px 32px 64px; }
.main-inner { max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 0 0 22px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; color: var(--ink); margin: 0; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.section-title { font-size: 16px; font-weight: 650; color: var(--ink); margin: 0; }
.section-gap { height: 36px; }
.text-link { display: inline-flex; align-items: center; gap: 2px; color: var(--blue); font-size: 14px; font-weight: 600; }
.text-link .icon { width: 15px; height: 15px; }
.search { position: relative; width: 300px; max-width: 100%; }
.search .icon { position: absolute; left: 11px; top: 10px; width: 18px; height: 18px; color: #98a0a8; pointer-events: none; }
.search input { width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px 0 36px; font-size: 14px; background: var(--white); outline: none; }
.search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(14, 133, 119, 0.15); }
.search input::placeholder { color: #8a929a; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 24px; }
.chip { height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--white); font-size: 13.5px; font-weight: 500; color: var(--muted); }
.chip:hover { color: var(--ink); border-color: #c8ced4; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: #c5d6d2; box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08); }
.card:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.card .art {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
  background: #f8fafa radial-gradient(circle, #dde3e3 1px, transparent 1.3px) 0 0 / 14px 14px;
  border-bottom: 1px solid var(--border);
}
.card .art svg { width: 100%; height: 100%; }
.card .blank-art { width: 56px; height: 56px; border: 1.5px dashed #a9c9c3; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--blue); background: rgba(255, 255, 255, 0.7); }
.card .blank-art .icon { width: 26px; height: 26px; }
.card .card-label { padding: 11px 14px 13px; font-size: 14px; line-height: 1.3; }
.card .card-label span { display: block; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .card-label .card-sub { display: flex; align-items: center; gap: 4px; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.card .card-sub .icon { width: 14px; height: 14px; }
.card .star, .card .more {
  position: absolute;
  top: 8px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8a929a;
  opacity: 0;
  transition: opacity 0.15s;
}
.card .star { right: 8px; }
.card .more { left: auto; right: 44px; }
.card .star .icon, .card .more .icon { width: 17px; height: 17px; }
.card:hover :is(.star, .more), .card:focus-within :is(.star, .more), .card .star.on { opacity: 1; }
@media (hover: none) { .card :is(.star, .more) { opacity: 1; } }
.card .star.on { color: var(--yellow); }
.card .star.on svg { fill: var(--yellow); }
.card .thumb { width: 100%; height: 100%; }

.empty {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  max-width: 560px;
  line-height: 1.6;
}
.empty p { margin: 0 0 16px; }
.prose { max-width: 680px; line-height: 1.65; font-size: 14.5px; }
.prose h2 { font-size: 16px; color: var(--ink); margin: 26px 0 8px; }
.prose p { margin: 0 0 12px; }
.prose kbd { font-family: inherit; background: #fff; border: 1px solid #ddd; border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font-size: 12px; }
.prose table { border-collapse: collapse; }
.prose td { padding: 4px 16px 4px 0; vertical-align: top; }
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.panel h2 { color: var(--ink); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* menus & dialogs */
.popover {
  position: fixed;
  z-index: 50;
  background: #fff;
  border-radius: 6px;
  box-shadow: rgba(0, 0, 0, 0.18) 0px 3px 12px 0px;
  padding: 6px 0;
  min-width: 190px;
}
.popover button, .popover label {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
.popover button:hover:not(:disabled), .popover label:hover { background: var(--page); }
.popover button:disabled { opacity: .45; cursor: default; }
.popover[role="menu"] { max-width: calc(100vw - 16px); max-height: min(68vh, calc(100vh - 16px)); overflow: auto; }
.popover .danger { color: #c62828; }
.popover hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(30, 34, 40, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog {
  background: #fff;
  border-radius: 12px;
  box-shadow: rgba(0, 0, 0, 0.25) 0 10px 30px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  line-height: 1.6;
}
.dialog h2 { font-size: 18px; margin-bottom: 10px; }
.dialog p { margin: 0 0 12px; }
.dialog input[type=text] {
  width: 100%;
  height: 34px;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 14px;
  margin-bottom: 16px;
}
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.pdf-page-label { display: flex; align-items: center; gap: 8px; }
.pdf-page-label input {
  width: 5em;
  padding: 4px 8px;
  font: inherit;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.pdf-page-preview {
  display: grid;
  place-items: center;
  height: min(35vh, 240px);
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.pdf-page-preview img { max-width: 100%; max-height: min(35vh, 240px); object-fit: contain; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  z-index: 80;
  font-size: 14px;
  pointer-events: none;
}

/* ---------- Narrow screens: links move under the logo row ---------- */
@media (max-width: 860px) {
  .appbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px 6px; }
  .appnav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .appbar-end { margin-left: auto; }
  .main { padding: 22px 16px 48px; }
  .page-title { font-size: 22px; }
  .search { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
@media (max-width: 420px) {
  .new-btn span { display: none; }
  .new-btn { width: 36px; padding: 0; }
  .nav-link { padding: 0 10px; }
}

/* ---------- Editor ---------- */
.editor {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--page);
}
.ed-top {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex: none;
  min-width: 0;
}
.ed-top .back { border: 0; background: none; display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 6px; font-size: 14px; }
.ed-top .back:hover { background: var(--page); }
.ed-logo { width: 26px; height: 26px; flex: none; }
.ed-title {
  font-size: 16px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 60px;
  width: 260px;
  max-width: 34vw;
  background: transparent;
}
.ed-title:hover { border-color: var(--border); }
.ed-title:focus { border-color: var(--blue); outline: none; background: #fff; }
.ed-saved { font-size: 12px; color: #888; white-space: nowrap; }
.ed-spacer { flex: 1; }
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  font-size: 14px;
  white-space: nowrap;
}
.tb-btn:hover { background: var(--page); }
.tb-btn:disabled { opacity: 0.35; cursor: default; background: none; }
.tb-btn.on { background: #e4f4f1; color: var(--blue); border-color: #c4ebe4; }
.ed-body { flex: 1; display: flex; min-height: 0; position: relative; }
.palette {
  width: 72px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  overflow-y: auto;
}
.palette .tool {
  width: 56px;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  padding: 4px 0;
  flex: none;
}
.palette .tool svg { width: 26px; height: 22px; }
.palette .tool:hover { background: var(--page); }
.palette .tool.on { background: #e4f4f1; border-color: #c4ebe4; color: var(--blue); }
.palette hr { width: 40px; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.stage { flex: 1; position: relative; overflow: hidden; touch-action: none; min-width: 0; }
.stage svg.canvas { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.stage.panning { cursor: grabbing; }
.stage.connecting, .stage.placing { cursor: crosshair; }
.shape { cursor: move; }
.shape-text { pointer-events: none; font-family: var(--font); }
.link-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.handle { fill: #fff; stroke: var(--blue); stroke-width: 1.5; }
.handle.resize { cursor: nwse-resize; }
.port { fill: var(--blue); stroke: #fff; stroke-width: 2; cursor: crosshair; }
.zoom-box {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  padding: 2px;
}
.zoom-box span { font-size: 12px; width: 46px; text-align: center; }
.hint {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.props {
  width: 230px;
  flex: none;
  background: #fff;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  font-size: 13px;
}
.props h3 { font-size: 13px; font-weight: 700; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: #777; }
.props .group { margin-bottom: 18px; }
.swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.15); padding: 0; }
.swatch.on { outline: 2px solid var(--blue); outline-offset: 1px; }
.props select, .props input[type=number] { width: 100%; height: 30px; border: 1px solid #ddd; border-radius: 6px; padding: 0 6px; font-size: 13px; background: #fff; }
.props .row2 { display: flex; gap: 6px; flex-wrap: wrap; }
.props .row2 .tb-btn { border-color: var(--border); }
.props .muted { color: #888; line-height: 1.5; }
.text-editor {
  position: absolute;
  z-index: 10;
  border: 2px solid var(--blue);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.96);
  resize: none;
  text-align: center;
  font-family: var(--font);
  padding: 4px;
  outline: none;
  line-height: 1.25;
}
/* Editing a shape's words happens right on the shape: same spot, angle, font and colours. */
.text-editor.in-place { border-width: 1.5px; border-radius: 3px; padding: 4px 6px; overflow: hidden; box-shadow: 0 0 0 3px rgba(14, 133, 119, 0.18); }
.shape[data-editing] .shape-text { visibility: hidden; }
.stage.dark-canvas .text-editor.in-place { filter: invert(0.9) hue-rotate(180deg); }
@media (max-width: 760px) {
  .ed-body { flex-direction: column-reverse; }
  .palette { width: 100%; flex-direction: row; height: 64px; border-right: 0; border-top: 1px solid var(--border); padding: 4px 8px; overflow-x: auto; overflow-y: hidden; }
  .palette hr { width: 1px; height: 40px; border-top: 0; border-left: 1px solid var(--line); margin: 0 4px; }
  .props { position: absolute; left: 8px; right: 8px; bottom: 72px; width: auto; max-height: 45%; border: 0; border-radius: 12px; box-shadow: var(--shadow-card); z-index: 5; }
  .props.collapsed { display: none; }
  .ed-saved, .tb-label { display: none; }
  .ed-title { max-width: 40vw; }
  .ed-top { gap: 2px; padding: 0 6px; }
}

/* sync / retry notices */
.notice[hidden] { display: none; }
.notice { position: fixed; inset: 0; z-index: 90; background: rgba(30, 34, 40, 0.35); display: flex; align-items: center; justify-content: center; padding: 20px; }
#retry-notice { inset: auto 0 24px 0; background: none; pointer-events: none; }
.notice-box { background: #fff; border-radius: 12px; box-shadow: var(--shadow-card); padding: 24px; max-width: 380px; text-align: center; line-height: 1.5; }
.notice-box h3 { font-size: 16px; }
.notice-box h1 { font-size: 16px; }
.notice-box p { margin: 10px 0 14px; color: #666; }

.props input[type=text] { width: 100%; height: 30px; border: 1px solid #ddd; border-radius: 6px; padding: 0 6px; font-size: 13px; background: #fff; }
.props input:focus, .props select:focus { border-color: var(--blue); outline: none; }
.props label.muted { display: block; margin-bottom: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; cursor: pointer; }
.palette .pal-title { font-size: 10px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: .04em; flex: none; }
@media (max-width: 760px) { .palette .pal-title { writing-mode: vertical-rl; transform: rotate(180deg); } }

/* rulers */
.ruler { position: absolute; z-index: 3; background: #fff; overflow: hidden; pointer-events: none; font-size: 9.5px; color: #777; }
.ruler-x { top: 0; left: 20px; right: 0; height: 20px; border-bottom: 1px solid #dde1e7; }
.ruler-y { top: 20px; left: 0; bottom: 0; width: 20px; border-right: 1px solid #dde1e7; }
.ruler-corner { position: absolute; z-index: 4; top: 0; left: 0; width: 20px; height: 20px; background: #fff; border-right: 1px solid #dde1e7; border-bottom: 1px solid #dde1e7; }
.ruler[hidden], .ruler-corner[hidden] { display: none; }
.ruler-x span, .ruler-x i { position: absolute; left: calc(var(--p) - 20px); bottom: 0; border-left: 1px solid #b9c0ca; }
.ruler-x span { height: 20px; padding-left: 3px; line-height: 12px; white-space: nowrap; }
.ruler-x i { height: 5px; }
.ruler-y span, .ruler-y i { position: absolute; top: calc(var(--p) - 20px); right: 0; border-top: 1px solid #b9c0ca; }
.ruler-y span { width: 20px; height: 0; }
.ruler-y span { writing-mode: vertical-rl; transform: rotate(180deg); height: auto; padding: 3px 0 0; border-top: 0; border-bottom: 1px solid #b9c0ca; line-height: 12px; white-space: nowrap; transform-origin: center; }
.ruler-y i { width: 5px; }
.stage.with-rulers .hint { top: 30px; }
/* palette search */
.palette { width: 84px; }
.palette .tool { width: 66px; }
.pal-search { width: 74px; height: 26px; border: 1px solid #ddd; border-radius: 6px; padding: 0 6px; font-size: 11px; flex: none; margin-bottom: 4px; }
.pal-search:focus { border-color: var(--blue); outline: none; }
.palette [hidden] { display: none !important; }
.pal-none { font-size: 11px; color: #888; text-align: center; margin: 8px 4px; }
.palette .tool span { text-align: center; line-height: 1.1; }
@media (max-width: 760px) { .palette { width: 100%; } .pal-search { width: 90px; margin: 0 4px 0 0; align-self: center; } }
/* settings and dialogs */
.dialog.dialog-wide { max-width: 560px; max-height: 88vh; overflow-y: auto; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; font-size: 13px; }
.settings section { margin-bottom: 10px; }
.settings h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #777; margin: 6px 0 6px; }
.settings label { display: block; margin: 6px 0; }
.settings label.check-row { display: flex; }
.settings select, .settings input[type=number], .settings input[type=text] { width: 100%; height: 30px; border: 1px solid #ccc; border-radius: 6px; padding: 0 6px; font-size: 13px; background: #fff; margin: 3px 0 0; }
.settings .row2 input { margin: 0; }
@media (max-width: 560px) { .settings { grid-template-columns: 1fr; } }
.list-input { width: 100%; font-family: inherit; font-size: 13px; border: 1px solid #ccc; border-radius: 6px; padding: 8px; line-height: 1.5; resize: vertical; }

/* ---------- Editor workspace: tabs, ribbon, side panel ---------- */
.editor .ed-top { display: block; height: auto; padding: 0; border-bottom: 1px solid var(--border); }
.ed-bar { display: flex; align-items: center; gap: 6px; height: 46px; padding: 0 12px; min-width: 0; }
.ed-tabs { display: flex; align-items: stretch; height: 46px; overflow-x: auto; scrollbar-width: none; flex: none; }
.ed-tab { border: 0; background: none; padding: 0 12px; font-size: 14px; color: var(--text); display: flex; align-items: center; white-space: nowrap; }
.ed-tab:hover { background: var(--page); }
.ed-tab.on { background: #e9ecf0; font-weight: 600; }
.share-btn { min-width: 0; height: 32px; font-size: 14px; padding: 0 12px; }
.side-toggle { display: none; }
.ribbon { display: flex; align-items: stretch; gap: 2px; padding: 6px 10px; min-height: 64px; border-top: 1px solid #eef0f3; overflow-x: auto; background: #fff; scrollbar-width: thin; }
.ribbon[hidden] { display: none; }
.rb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 52px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: none; font-size: 11.5px; color: #555; white-space: nowrap; flex: none; }
.rb .icon { width: 20px; height: 20px; }
.rb:hover:not(:disabled) { background: var(--page); color: #222; }
.rb:disabled, .rb-mini:disabled, .ribbon select:disabled { opacity: .38; cursor: default; }
.rb small { font-size: 9px; }
.rb-sep { width: 1px; background: #e6e8ec; margin: 4px 6px; flex: none; }
.rb-font { display: flex; flex-direction: column; justify-content: center; gap: 4px; flex: none; }
.rb-row { display: flex; gap: 3px; align-items: center; }
.ribbon select { height: 26px; border: 1px solid #dcdfe4; border-radius: 4px; font-size: 12px; background: #fff; padding: 0 4px; }
.ribbon select[data-font="font"] { width: 130px; }
.rb-mini { min-width: 26px; height: 24px; border: 1px solid transparent; border-radius: 4px; background: none; font-size: 13px; padding: 0 4px; }
.rb-mini:hover:not(:disabled) { background: var(--page); }
.rb-mini.on { background: #e4f4f1; border-color: #c4ebe4; color: var(--blue); }
/* Checkboxes fill columns two deep, so the ribbon keeps its normal height however many there are. */
.rb-checks { display: grid; grid-template-rows: repeat(2, auto); grid-auto-flow: column; align-content: center; column-gap: 18px; row-gap: 6px; padding: 0 8px; flex: none; font-size: 12.5px; }
.rb-check { display: flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }
.rb-check input { accent-color: var(--blue); width: 15px; height: 15px; }
.rb-nums { display: flex; flex-direction: column; justify-content: center; gap: 4px; font-size: 12px; flex: none; padding-right: 6px; }
.rb-nums label { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.rb-nums input { width: 56px; height: 24px; border: 1px solid #dcdfe4; border-radius: 4px; padding: 0 6px; font-size: 12px; }
.ed-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.page-bar { display: flex; align-items: center; height: 34px; background: #fff; border-bottom: 1px solid var(--border); padding: 0 6px; gap: 2px; flex: none; }
.page-tabs { display: flex; overflow-x: auto; height: 100%; scrollbar-width: none; }
.page-tab { border: 0; border-right: 1px solid #eef0f3; background: #f3f4f6; padding: 0 22px; font-size: 13px; white-space: nowrap; }
.page-tab.on { background: #e4e7eb; font-weight: 600; }
.layer-btn { position: absolute; left: 30px; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid #dfe3e8; border-radius: 6px; background: #fff; box-shadow: var(--shadow-card); font-size: 13px; }
.zoom-range { width: 110px; accent-color: var(--blue); }
.palette.side { width: 260px; flex: none; display: block; padding: 10px 12px 30px; overflow-y: auto; background: #fff; border-right: 1px solid var(--border); gap: 0; }
.palette.side .side-head h2 { font-size: 18px; font-weight: 600; margin: 4px 2px 10px; }
.tool-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.palette.side .tool.big { width: 100%; min-height: 50px; border-radius: 6px; font-size: 12px; }
.palette.side .tool.big .icon { width: 20px; height: 20px; }
.palette.side .tool.on { background: var(--accent-soft); border-color: #a9d9d0; color: var(--accent-strong); }
.split { position: relative; }
.split .caret, .side-split .caret { position: absolute; top: 2px; right: 0; border: 0; background: none; font-size: 10px; color: #777; padding: 2px 3px; border-radius: 4px; }
.split .caret:hover, .side-split .caret:hover { background: var(--page); }
.side-split { position: relative; }
.side-split .caret { top: 6px; right: 4px; font-size: 12px; }
.side-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: 6px; font-size: 13px; text-align: left; color: var(--text); }
.side-item .icon { width: 16px; height: 16px; color: #555; }
.side-item:hover:not(:disabled) { background: var(--page); }
.side-item:disabled { opacity: .4; cursor: default; }
.side-item.on { background: var(--accent-soft); color: var(--accent-strong); }
.side-check { cursor: pointer; }
.side-check span { flex: 1; }
.side-check input { accent-color: var(--blue); width: 16px; height: 16px; }
.side-sec { margin: 6px 0; }
.side-sec > summary, .lib > summary { list-style: none; cursor: pointer; background: #f3f4f6; border-radius: 6px; padding: 7px 10px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.side-sec > summary::before, .lib > summary::before { content: '›'; display: inline-block; width: 10px; transition: transform .15s; }
.side-sec[open] > summary::before, .lib[open] > summary::before { transform: rotate(90deg); }
.side-sec > summary::-webkit-details-marker, .lib > summary::-webkit-details-marker { display: none; }
.side-sec-body { padding: 4px 0 0 8px; }
.side-sec .muted { font-size: 12px; color: #888; margin: 4px 8px; }
.sym-search { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.sym-search input { flex: 1; min-width: 0; height: 32px; border: 1px solid #e2e5ea; background: #f5f6f7; border-radius: 6px; padding: 0 10px; font-size: 13px; }
.sym-search input:focus { outline: none; border-color: var(--blue); background: #fff; }
.sym-find { height: 32px; width: 34px; border: 0; border-radius: 6px; background: #e3e5e8; display: flex; align-items: center; justify-content: center; }
.sym-find .icon { width: 16px; height: 16px; }
.sym-more { border: 0; background: none; color: var(--blue); font-size: 13px; white-space: nowrap; padding: 0 2px; }
.lib-list { border: 1px solid #eef0f3; border-radius: 8px; padding: 6px; }
.lib { margin: 0 0 6px; }
.lib > summary span { flex: 1; }
.lib-x { border: 0; background: none; color: #777; font-size: 16px; line-height: 1; padding: 0 2px; }
.sym-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px 0 2px; }
.sym { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid transparent; border-radius: 6px; background: none; padding: 6px 2px; font-size: 10.5px; line-height: 1.15; color: #444; text-align: center; min-height: 58px; }
.sym svg { width: 30px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.sym:hover { background: #eef8f6; border-color: #c4ebe4; }
.palette.side hr { display: none; }
.stage.painting { cursor: copy; }
/* floating panels */
.panel-pop { padding: 10px; min-width: 210px; max-width: 280px; }
.panel-pop h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #888; margin: 6px 2px 6px; }
.pop-swatches { display: grid; grid-template-columns: repeat(7, 26px); gap: 5px; }
.panel-pop .swatch { width: 26px; height: 26px; padding: 0; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); }
.pop-custom { display: flex !important; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; padding: 0 !important; }
.pop-custom input { width: 34px; height: 24px; border: 0; padding: 0; background: none; }
.pop-row { display: flex; gap: 4px; flex-wrap: wrap; }
.panel-pop .pop-row button { width: auto; border: 1px solid #e2e5ea; border-radius: 5px; padding: 4px 8px; font-size: 12px; }
.pop-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.panel-pop .pop-styles button { border: 1.5px solid; border-radius: 6px; padding: 10px 6px; font-size: 12.5px; justify-content: center; }
.pop-list button { justify-content: flex-start; }
.theme-dots { display: inline-flex; gap: 2px; margin-right: 8px; }
.theme-dots i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); }
.layers-pop h3 { font-size: 13px; margin: 0 0 6px; }
.layer-row { display: flex; align-items: center; gap: 2px; border-radius: 6px; padding: 2px; }
.layer-row.on { background: var(--accent-soft); }
.panel-pop .layer-row button { width: auto; padding: 5px 7px; font-size: 13px; border-radius: 5px; }
.panel-pop .layer-row .ly-name { flex: 1; text-align: left; }
.panel-pop .layer-row button.on { color: #c62828; }
.panel-pop .layer-row button.off { opacity: .5; }
.layers-pop .tb-btn { border: 1px solid #e2e5ea; width: auto !important; }
.fr { display: block; margin-bottom: 10px; font-size: 13px; }
.fr input { display: block; width: 100%; height: 34px; border: 1px solid #ccc; border-radius: 6px; padding: 0 10px; margin-top: 4px; font-size: 14px; }
.fr-msg { min-height: 18px; font-size: 12.5px; color: #777; }
@media (max-width: 900px) {
  .palette.side { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; transform: translateX(-105%); transition: transform .2s; box-shadow: rgba(0,0,0,.18) 3px 0 12px; }
  .editor.side-open .palette.side { transform: none; }
  .side-toggle { display: inline-flex; }
  .ed-title { width: 140px; }
  .ed-body { position: relative; }
}
@media (max-width: 760px) {
  .ed-bar { flex-wrap: wrap; height: auto; padding: 4px 6px; }
  .ed-tabs { order: 3; width: 100%; height: 38px; }
  .share-btn span { display: none; }
  .zoom-range { display: none; }
  .layer-btn { left: 10px; bottom: 76px; }
  .palette.side { width: 86vw; max-width: 300px; flex-direction: column; height: auto; overflow-y: auto; border-top: 0; }
}

/* icons in menus and the layers panel */
.popover .pop-check { color: var(--blue); width: 16px; height: 16px; }
.panel-pop .layer-row button.ly-ico { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; color: #666; }
.panel-pop .layer-row button.ly-ico .icon { width: 17px; height: 17px; }
.panel-pop .layer-row button.ly-ico:hover { background: rgba(0, 0, 0, .06); color: #222; }
.panel-pop .layer-row button.ly-ico.off { color: #aaa; opacity: 1; }
.panel-pop .layer-row button.ly-ico.on { color: #c62828; }
.layers-pop .tb-btn .icon, .pop-list button .icon { width: 16px; height: 16px; }
.props .row2 .tb-btn .icon { width: 17px; height: 17px; }
.sym-more .icon { width: 15px; height: 15px; vertical-align: -3px; }

/* ---------- hosted drawings ---------- */
.cloud-status { font-size: 12px; color: #2e7d32; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.cloud-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.cloud-status[data-state="saving"], .cloud-status[data-state="pending"] { color: #8a6d00; }
.cloud-status[data-state="offline"], .cloud-status[data-state="error"], .cloud-status[data-state="toobig"], .cloud-status[data-state="gone"] { color: #b25b00; }
.cloud-status[data-state="conflict"], .cloud-status[data-state="denied"] { color: #c62828; }
.cloud-status[hidden] { display: none; }
.host-btn.on { color: var(--blue); }
/* Hosted links dialog */
.host-dialog h2 { margin-bottom: 4px; }
.host-dialog .host-sub { color: #6b7280; font-size: 13.5px; margin: 0 0 16px; }
.host-link { border: 1px solid #e3e6ea; border-radius: 10px; padding: 12px 14px 14px; margin: 0 0 12px; }
.hl-head { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 9px; }
.hl-head .icon { width: 17px; height: 17px; flex: none; }
.hl-tag { font-size: 11.5px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px; background: #e4f4f1; color: #0a6b60; }
.hl-note { margin-left: auto; font-size: 12.5px; color: #6b7280; }
.link-field { display: flex; align-items: stretch; height: 38px; border: 1px solid #cfd4da; border-radius: 8px; overflow: hidden; background: #fff; }
.link-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(14, 133, 119, 0.16); }
.dialog .link-field input[type=text] { flex: 1; min-width: 0; height: 100%; border: 0; border-radius: 0; margin: 0; padding: 0 12px; font-size: 13px; background: transparent; text-overflow: ellipsis; outline: none; }
.lf-copy { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 96px; padding: 0 14px; border: 0; border-left: 1px solid #cfd4da; background: #f5f7fa; color: #0a6b60; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.lf-copy .icon { width: 15px; height: 15px; }
.lf-copy:hover { background: #e4f4f1; }
.host-view .lf-copy { background: var(--blue); border-left-color: var(--blue); color: #fff; }
.host-view .lf-copy:hover { background: #0a6b60; }
.lf-copy.done, .host-view .lf-copy.done { background: #2e9d5b; border-left-color: #2e9d5b; color: #fff; }
.host-edit { border-color: #f2c6c6; background: #fff8f8; }
.host-edit .hl-tag { background: #fde4e4; color: #a02020; }
.host-edit .link-field, .host-edit .lf-copy { border-color: #ebc3c3; }
.host-edit .lf-copy { color: #a02020; background: #fdf0f0; }
.host-edit .lf-copy:hover { background: #fbe2e2; }
.host-edit .warn { display: flex; gap: 6px; align-items: flex-start; color: #a02020; font-size: 12.5px; line-height: 1.45; margin: 9px 0 0; }
.host-edit .warn .icon { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.host-dialog .actions { align-items: center; margin-top: 16px; }
.host-link .share-note { margin: 9px 0 0; font-size: 12.5px; line-height: 1.45; color: #6b7280; }
[data-theme="dark"] .host-link .share-note { color: #a3acb7; }
.host-status { display: flex; align-items: center; gap: 7px; margin-right: auto; font-size: 12.5px; color: #6b7280; }
.host-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #2e9d5b; flex: none; }
.host-status[data-kind="saving"] .dot { background: #e0a100; }
.host-status[data-kind="error"] .dot { background: #d93838; }
.viewer { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--page); }
.viewer-top { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--border); flex: none; min-width: 0; }
.viewer-top img { display: block; }
.viewer-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.viewer-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; background: #e4f4f1; color: #095c53; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.viewer-badge .icon { width: 14px; height: 14px; }
.viewer-when { font-size: 12px; color: #888; white-space: nowrap; }
.viewer-stage { flex: 1; cursor: grab; }
.viewer-msg { padding: 48px; font-size: 15px; color: #666; }
@media (max-width: 700px) { .viewer-when, .viewer-top .btn span { display: none; } .viewer-top .btn { min-width: 0; } }

/* ---------- Dark mode (Settings, Options or the moon button; "Match my computer" by default) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #e3e6eb; --white: #1e2228; --line: #343a42; --border: #343a42; --panel: #23282f;
  --page: #16191e; --button-grey: #3a4049; --glass: #1e222899; --blue: #3fbfad;
  --shadow-card: rgba(0, 0, 0, 0.5) 0px 3px 8px 0px;
}
[data-theme="dark"] body { background: var(--page); }
[data-theme="dark"] .logo img, [data-theme="dark"] .viewer-top img { content: url("logo-dark.svg"); }
/* surfaces */
[data-theme="dark"] :is(.dialog, .popover, .notice-box, .toast, .ed-top, .ribbon, .page-bar, .palette, .palette.side, .props, .zoom-box, .layer-btn, .viewer-top, .ruler, .ruler-corner, .ruler-x, .ruler-y) { background: var(--white); color: var(--text); border-color: var(--border); }
[data-theme="dark"] :is(.ruler-x span, .ruler-x i, .ruler-y span, .ruler-y i) { border-color: #4a515b; color: #9aa3ad; }
[data-theme="dark"] .ribbon { border-top-color: var(--border); }
[data-theme="dark"] .rb-sep { background: var(--border); }
[data-theme="dark"] :is(.side-sec > summary, .lib > summary, .page-tab) { background: #262b33; color: var(--text); border-color: var(--border); }
[data-theme="dark"] :is(.page-tab.on, .ed-tab.on) { background: #313843; }
[data-theme="dark"] :is(.ed-tab, .rb, .side-item, .sym, .tb-btn, .nav-link, .cat-list button, .menu-btn, .back, .rb-mini) { color: var(--text); }
[data-theme="dark"] :is(.rb, .side-item, .sym, .ed-tab, .tb-btn, .rb-mini, .popover button, .popover label):hover:not(:disabled) { background: #2b3139; }
[data-theme="dark"] :is(.palette .tool.on, .palette.side .tool.on) { background: rgba(63, 191, 173, 0.16); border-color: #2f6b63; color: #6fd6c6; }
[data-theme="dark"] :is(.tb-btn.on, .rb-mini.on) { background: #163f3b; border-color: #1f5f58; color: #6fd6c6; }
[data-theme="dark"] :is(.side-item.on, .layer-row.on) { background: rgba(63, 191, 173, 0.14); }
[data-theme="dark"] .lib-list { border-color: var(--border); }
[data-theme="dark"] .sym:hover { border-color: #1f5f58; }
[data-theme="dark"] .sym-find { background: #2f353e; color: var(--text); }
/* inputs */
[data-theme="dark"] :is(input[type=text], input[type=search], input[type=number], select, textarea, .ed-title, .search input, .pal-search, .list-input, .fr input, .host-link input, .props select, .settings select, .ribbon select, .rb-nums input) { background: #151a20; color: var(--text); border-color: #3d444e; }
[data-theme="dark"] .ed-title { background: transparent; border-color: transparent; }
[data-theme="dark"] .ed-title:hover { border-color: var(--border); }
[data-theme="dark"] .ed-title:focus { background: #151a20; border-color: var(--blue); }
[data-theme="dark"] .text-editor { background: rgba(21, 26, 32, 0.96); color: var(--text); }
[data-theme="dark"] .prose kbd { background: #262b33; border-color: #444b55; color: var(--text); }
/* buttons and accents */
[data-theme="dark"] .btn-outline { background: transparent; }
[data-theme="dark"] .btn-outline:hover { background: #17302e; }
[data-theme="dark"] .btn-plain { border-color: #444b55; color: var(--text); background: #262b33; }
[data-theme="dark"] .btn-yellow { color: #222; }
[data-theme="dark"] .btn-blue { background: #14917f; border-color: #14917f; }
[data-theme="dark"] :is(.muted, .props .muted, .ed-saved, .viewer-when, .card .card-sub) { color: #9aa3ad; }
[data-theme="dark"] .nav-link.active .label { color: #fff; }
[data-theme="dark"] .viewer-badge { background: #163f3b; color: #6fd6c6; }
[data-theme="dark"] .host-link { border-color: #353c46; }
[data-theme="dark"] :is(.host-dialog .host-sub, .hl-note, .host-status) { color: #a3acb7; }
[data-theme="dark"] .hl-tag { background: rgba(14, 133, 119, 0.2); color: #6fd6c6; }
[data-theme="dark"] .link-field { background: #151a20; border-color: #3d444e; }
[data-theme="dark"] .dialog .link-field input[type=text] { background: transparent; }
[data-theme="dark"] .lf-copy { background: #222831; border-left-color: #3d444e; color: #6fd6c6; }
[data-theme="dark"] .lf-copy:hover { background: #2a313b; }
[data-theme="dark"] .host-view .lf-copy { background: #14917f; border-left-color: #14917f; color: #fff; }
[data-theme="dark"] .host-view .lf-copy:hover { background: #0b6e63; }
[data-theme="dark"] .host-edit { background: #2a1d1f; border-color: #5a2f33; }
[data-theme="dark"] .host-edit .hl-tag { background: rgba(255, 90, 90, 0.16); color: #ffa3a3; }
[data-theme="dark"] .host-edit .link-field { border-color: #5a2f33; }
[data-theme="dark"] .host-edit .lf-copy { background: #352326; border-left-color: #5a2f33; color: #ffa3a3; }
[data-theme="dark"] .host-edit .lf-copy:hover { background: #432a2e; }
[data-theme="dark"] .lf-copy.done { background: #2e9d5b; border-left-color: #2e9d5b; color: #fff; }
[data-theme="dark"] .host-edit .warn { color: #ff9e9e; }
[data-theme="dark"] .popover .danger { color: #ff8a80; }
[data-theme="dark"] .cloud-status { color: #7bd88f; }
[data-theme="dark"] .cloud-status[data-state="saving"], [data-theme="dark"] .cloud-status[data-state="pending"] { color: #f2c94c; }
[data-theme="dark"] .cloud-status[data-state="conflict"], [data-theme="dark"] .cloud-status[data-state="denied"] { color: #ff8a80; }
[data-theme="dark"] .panel-pop .layer-row button.ly-ico { color: #b4bcc6; }
[data-theme="dark"] .panel-pop .layer-row button.ly-ico:hover { background: rgba(255, 255, 255, .08); color: #fff; }
[data-theme="dark"] .scrim, [data-theme="dark"] .shell.drawer-open .drawer-scrim { background: rgba(0, 0, 0, 0.55); }
/* drawing thumbnails on the Documents pages use the dark page too */
[data-theme="dark"] .doc-card .art svg { filter: invert(0.88) hue-rotate(180deg); }
[data-theme="dark"] .doc-card .art svg image { filter: invert(1) hue-rotate(180deg); }
.theme-pick { display: flex; gap: 6px; }
.theme-pick button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--border); border-radius: 8px; background: none; color: inherit; font-size: 12.5px; }
.theme-pick button.on { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; }
.theme-pick .icon { width: 20px; height: 20px; }
/* Dark drawing area: flip the drawing's lightness but keep its hues; pictures are flipped back. */
.stage.dark-canvas svg.canvas { filter: invert(0.9) hue-rotate(180deg); }
.stage.dark-canvas svg.canvas image { filter: invert(1) hue-rotate(180deg); }
/* Dark mode: text and icon colours that were fixed for the light theme. */
[data-theme="dark"] .nav-link:hover .label, [data-theme="dark"] .nav-link.active .label { color: #ffffff; }
[data-theme="dark"] .nav-link { color: #d6dae0; }
[data-theme="dark"] .nav-link .icon, [data-theme="dark"] .side-item .icon, [data-theme="dark"] .rb .icon { color: #b8c0ca; }
[data-theme="dark"] .nav-link:hover .icon, [data-theme="dark"] .nav-link.active .icon { color: #ffffff; }
[data-theme="dark"] .search input::placeholder, [data-theme="dark"] .sym-search input::placeholder { color: #8b94a0; }
[data-theme="dark"] .search button { background: #3a4049; color: #e3e6eb; opacity: 1; }
[data-theme="dark"] .search button .icon { stroke: #c4cbd4; }
[data-theme="dark"] :is(.card .card-sub, .ed-saved, .props .muted, .pal-none, .side-sec .muted, .viewer-when, .fr-msg, .notice-box p, .viewer-msg) { color: #a3acb7; }
[data-theme="dark"] :is(.props h3, .settings h3, .panel-pop h4, .palette .pal-title) { color: #a3acb7; }
[data-theme="dark"] .card .star { color: #a3acb7; }
[data-theme="dark"] .card .more { color: #c4cbd4; }
[data-theme="dark"] .cat-list button { color: #d6dae0; }
[data-theme="dark"] .cat-list button:hover, [data-theme="dark"] .cat-list button.active { color: #6fd6c6; }
[data-theme="dark"] .page-title .crumb, [data-theme="dark"] .sym-more { color: #6fd6c6; }
[data-theme="dark"] .nav-divider { background: #343a42; }
[data-theme="dark"] .btn-outline { color: #6fd6c6; border-color: #3fbfad; }
[data-theme="dark"] .empty, [data-theme="dark"] .panel { color: var(--text); }
[data-theme="dark"] .prose a { color: #6fd6c6; }

/* View-only page tabs: rounded tabs, the current page highlighted. */
.viewer .viewer-pages { height: auto; min-height: 46px; padding: 8px 14px; gap: 6px; background: var(--white); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.viewer .viewer-pages .page-tab { flex: none; height: 30px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text); font-size: 13px; font-weight: 500; transition: background .12s, border-color .12s; }
.viewer .viewer-pages .page-tab:hover { background: var(--page); border-color: #c9d2de; }
.viewer .viewer-pages .page-tab.on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(14, 133, 119, .35); }
.viewer .viewer-pages .page-tab:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[data-theme="dark"] .viewer .viewer-pages .page-tab { background: transparent; border-color: #3a414b; color: #c9d0d8; }
[data-theme="dark"] .viewer .viewer-pages .page-tab:hover { background: #262b33; border-color: #4a525d; color: #fff; }
[data-theme="dark"] .viewer .viewer-pages .page-tab.on { background: #14917f; border-color: #14917f; color: #fff; box-shadow: none; }
.viewer-pages[hidden] { display: none; }

/* ---------- Editor top bar: one consistent set of controls ---------- */
.ed-bar { gap: 4px; }
.ed-bar .bar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; flex: none; }
.ed-bar .tb-btn { flex: none; height: 32px; min-width: 32px; padding: 0 8px; gap: 6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); font-size: 13.5px; }
.ed-bar .tb-btn .icon { width: 18px; height: 18px; }
.ed-bar .tb-btn:hover { background: var(--page); }
.ed-bar .tb-btn.on { background: rgba(14, 133, 119, 0.1); border-color: transparent; color: var(--blue); }
/* a favourite is shown by a filled star, not a box */
.ed-bar [data-a="favorite"].on { background: none; color: #e0a100; }
.ed-bar [data-a="favorite"].on:hover { background: var(--page); }
/* hosted: blue cloud and label, no box */
.ed-bar .host-btn.on { background: none; color: var(--blue); }
.ed-bar .host-btn.on:hover { background: var(--page); }
/* Share is the one main action */
.ed-bar .share-btn { flex: none; height: 32px; min-width: 0; padding: 0 14px; gap: 6px; border-radius: 6px; font-size: 13.5px; font-weight: 600; background: var(--blue); border: 1px solid var(--blue); color: #fff; margin-left: 4px; }
.ed-bar .share-btn .icon { width: 17px; height: 17px; }
.ed-bar .share-btn:hover { filter: brightness(1.06); }
/* the drawing name reads as a title until you hover or edit it */
.ed-bar input.ed-title { height: 32px; border: 1px solid transparent; background: transparent; color: var(--text); }
.ed-bar input.ed-title:hover { border-color: var(--border); }
.ed-bar input.ed-title:focus { border-color: var(--blue); background: var(--white); }
.ed-bar .ed-saved, .ed-bar .cloud-status { margin: 0 4px; }
[data-theme="dark"] .ed-bar input.ed-title { background: transparent; border-color: transparent; color: var(--text); }
[data-theme="dark"] .ed-bar input.ed-title:hover { border-color: #3d444e; }
[data-theme="dark"] .ed-bar input.ed-title:focus { border-color: var(--blue); background: #151a20; }
[data-theme="dark"] .ed-bar .tb-btn { color: #d6dae0; }
[data-theme="dark"] .ed-bar .tb-btn:hover { background: #2b3139; color: #fff; }
[data-theme="dark"] .ed-bar .tb-btn.on { background: rgba(63, 191, 173, 0.16); color: #6fd6c6; }
[data-theme="dark"] .ed-bar [data-a="favorite"].on { background: none; color: #ffc940; }
[data-theme="dark"] .ed-bar .host-btn.on { background: none; color: #6fd6c6; }
[data-theme="dark"] .ed-bar .share-btn { background: #14917f; border-color: #14917f; color: #fff; }
[data-theme="dark"] .ed-bar .bar-sep { background: #3a414b; }
@media (max-width: 760px) { .ed-bar .bar-sep { display: none; } }
/* The title and status share the space between the document controls and Share. */
.editor .ed-bar { flex-wrap: nowrap; min-height: 46px; }
.ed-identity { display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; }
.ed-bar .ed-identity .ed-title { flex: 1; min-width: 0; max-width: 25rem; width: 100%; text-overflow: ellipsis; }
.ed-identity .save-status { min-width: 0; }
.ed-identity .st-text { overflow: hidden; text-overflow: ellipsis; }
.ed-menus { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 35px; padding: 2px 10px 4px; }
.ed-menus button { flex: none; border: 0; border-radius: 5px; padding: 5px 9px; background: transparent; color: var(--text); font-size: 13px; }
.ed-menus button:hover, .ed-menus button[aria-expanded="true"] { background: var(--page); }
.ed-menus button:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.palette.side .side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.palette.side .side-head h2 { margin: 0; }
.props[hidden] { display: none; }
.wall-thickness { margin: 8px 0; }
.lane-list { display: grid; gap: 10px; list-style: none; padding: 0; margin: 0 0 14px; }
.lane-list li { display: grid; gap: 4px; }
.lane-list label { color: var(--muted); font-size: 12px; }
.lane-list input { display: block; margin-top: 3px; }
.lane-list .tb-btn { height: 27px; min-width: 27px; }
.lane-list .tb-btn:disabled { opacity: .4; cursor: default; }
@media (max-width: 600px) {
  .editor .ed-bar { gap: 1px; padding-inline: 4px; }
  .ed-bar .back { padding-inline: 4px; }
  .ed-bar .ed-logo, .ed-bar .host-btn .tb-label { display: none; }
  .ed-bar .tb-btn { min-width: 29px; padding-inline: 5px; }
  .ed-bar .share-btn { padding-inline: 8px; }
  .ed-menus { gap: 0; padding-inline: 5px; }
  .ed-menus button { padding-inline: 6px; }
  .ed-identity .save-status .st-text { max-width: 0; margin-left: 0; }
}

/* ---------- Save status: dot + words; "Saved" folds away to just the dot ---------- */
.ed-bar .save-status { display: inline-flex; align-items: center; font-size: 12px; white-space: nowrap; color: #2e7d32; cursor: default; margin: 0 4px; }
.ed-bar .save-status::before { content: none; }
.save-status .st-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; transition: background-color .3s; }
.save-status .st-text { display: inline-block; max-width: 260px; margin-left: 6px; overflow: hidden; opacity: 1; transition: max-width .45s ease, margin-left .45s ease, opacity .3s ease; }
.save-status.collapsed .st-text { max-width: 0; margin-left: 0; opacity: 0; }
.save-status[data-kind="saving"] { color: #a07800; }
.save-status[data-kind="saving"] .st-dot { animation: st-pulse 1s ease-in-out infinite; }
.save-status[data-kind="warn"] { color: #b25b00; }
.save-status[data-kind="error"] { color: #c62828; }
@keyframes st-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .save-status .st-text, .save-status .st-dot { transition: none; animation: none; } }
[data-theme="dark"] .ed-bar .save-status { color: #6fd08a; }
[data-theme="dark"] .ed-bar .save-status[data-kind="saving"] { color: #f2c94c; }
[data-theme="dark"] .ed-bar .save-status[data-kind="warn"] { color: #ffb066; }
[data-theme="dark"] .ed-bar .save-status[data-kind="error"] { color: #ff8a80; }
/* Only one status shows: a hidden one must stay hidden even with the dot styling. */
.ed-bar .save-status[hidden] { display: none; }
/* Save status details (opened by clicking the dot) */
.ed-bar .save-status { cursor: pointer; border-radius: 6px; padding: 4px 4px; }
.ed-bar .save-status:hover { background: var(--page); }
.ed-bar .save-status:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.save-pop { width: 280px; }
.save-pop h4 { margin: 2px 2px 8px; }
.save-pop .ss-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 2px; }
.save-pop .ss-row .icon { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--blue); }
.save-pop .ss-row b { display: block; font-size: 13px; font-weight: 600; }
.save-pop .ss-row span { display: block; font-size: 12px; color: #777; margin-top: 2px; line-height: 1.4; }
.save-pop .ss-actions { margin-top: 8px; gap: 6px; }
.panel-pop .save-pop .ss-actions .tb-btn { width: auto; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; height: 30px; font-size: 13px; }
[data-theme="dark"] .ed-bar .save-status:hover { background: #2b3139; }
[data-theme="dark"] .save-pop .ss-row span { color: #a3acb7; }
[data-theme="dark"] .save-pop .ss-row .icon { color: #6fd6c6; }
.save-pop .ss-actions { display: flex; flex-wrap: wrap; }

/* Dark drawing area: colour buttons and previews are flipped like the drawing, so what you click is what you see. */
.flip-colors :is(.swatch, .pop-styles button, .theme-dots i) { filter: invert(0.9) hue-rotate(180deg); }
.settings .set-hint { font-size: 12px; line-height: 1.45; margin: 4px 0 0 24px; color: #888; }

/* Side panel: small hints and a foldable quick-tips list instead of a wall of text. */
.props .side-hint { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: #888; }
.props details.tips summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.props details.tips summary::-webkit-details-marker { display: none; }
.props details.tips summary h3 { margin: 0; }
.props details.tips .chev { width: 14px; height: 14px; color: #888; transition: transform 0.15s; }
.props details.tips[open] .chev { transform: rotate(90deg); }
.props details.tips ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; font-size: 12.5px; line-height: 1.5; color: #666; }
.props details.tips kbd { font: inherit; font-size: 11.5px; font-weight: 600; white-space: nowrap; padding: 1px 6px; border-radius: 4px; background: #f0f2f5; border: 1px solid #e3e6ea; color: #333; }
[data-theme="dark"] .props .side-hint, [data-theme="dark"] .props details.tips ul { color: #a3acb7; }
[data-theme="dark"] .props details.tips kbd { background: #262c35; border-color: #3d444e; color: #e1e5ea; }

/* ---------- Dark mode: dashboard ---------- */
:root[data-theme="dark"] { --ink: #eef1f4; --muted: #a3acb7; --accent-soft: rgba(63, 191, 173, 0.16); --accent-strong: #6fd6c6; }
[data-theme="dark"] .appbar { background: var(--white); border-color: var(--border); }
[data-theme="dark"] .nav-link { color: #b8c0ca; }
[data-theme="dark"] .nav-link:hover { background: #262b33; color: #fff; }
[data-theme="dark"] .nav-link.active { background: var(--accent-soft); color: #6fd6c6; }
[data-theme="dark"] .nav-link .icon { color: inherit; }
[data-theme="dark"] .icon-btn { background: transparent; border-color: #3a414b; color: #c9d0d8; }
[data-theme="dark"] .icon-btn:hover { background: #262b33; color: #fff; }
[data-theme="dark"] .btn-blue:hover { background: #0f7c6e; border-color: #0f7c6e; }
[data-theme="dark"] .chip { background: transparent; border-color: #3a414b; color: #c9d0d8; }
[data-theme="dark"] .chip:hover { border-color: #4a525d; color: #fff; }
[data-theme="dark"] .chip.on { background: #eef1f4; border-color: #eef1f4; color: #16191e; }
[data-theme="dark"] .card .art { background: #1a1e23 radial-gradient(circle, #30363e 1px, transparent 1.3px) 0 0 / 14px 14px; }
[data-theme="dark"] .card:hover { border-color: #3f5a56; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }
[data-theme="dark"] .card .art svg { filter: invert(0.88) hue-rotate(180deg); }
[data-theme="dark"] .card .art svg image { filter: invert(1) hue-rotate(180deg); }
[data-theme="dark"] .card .blank-art { background: transparent; border-color: #3f6b64; color: #6fd6c6; }
[data-theme="dark"] .card :is(.star, .more) { background: #262b33; border-color: #3a414b; }
[data-theme="dark"] .search .icon { color: #8b94a0; }
[data-theme="dark"] .empty, [data-theme="dark"] .panel { border-color: var(--border); }
[data-theme="dark"] .nav-link .label, [data-theme="dark"] .nav-link:hover .label, [data-theme="dark"] .nav-link.active .label { color: inherit; }

/* ---------- Kitedraw editor: canvas first, tools where you work ---------- */
.ed-bar .tb-btn:disabled { opacity: .35; cursor: default; }
@media (min-width: 901px) { .editor:not(.side-open) .palette.side { display: none; } }

/* Floating tool dock on the canvas. */
.dock { position: absolute; z-index: 6; left: 32px; top: 32px; display: flex; flex-direction: column; gap: 2px; padding: 5px; max-height: calc(100% - 48px); overflow-y: auto; scrollbar-width: thin; background: var(--white); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 6px 20px rgba(16, 24, 40, 0.10); }
.dk { flex: none; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: none; color: var(--muted); padding: 0; }
.dk .icon { width: 20px; height: 20px; }
.dk:hover { background: var(--page); color: var(--ink); }
.dk.on { background: var(--blue); color: #fff; }
.dock [data-c="toggle-side"].on { background: var(--accent-soft); color: var(--accent-strong); }
.dk-sep { flex: none; height: 1px; background: var(--border); margin: 3px 6px; }
.stage:not(.with-rulers) .dock { left: 14px; top: 14px; }

/* The bar that follows the selection. */
.qbar { position: absolute; z-index: 7; left: 0; top: 0; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--ink); color: #fff; border-radius: 12px; box-shadow: 0 10px 28px rgba(16, 24, 40, 0.22); white-space: nowrap; }
.qbar[hidden] { display: none; }
.qbar button { height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: none; color: #e9eef1; padding: 0 6px; font-size: 13px; }
.qbar button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }
.qbar button:disabled { opacity: .4; }
.qbar button.on { background: rgba(255, 255, 255, 0.18); }
.qbar .icon { width: 18px; height: 18px; }
.qbar .qb-swatch { width: 18px; height: 18px; border-radius: 5px; border: 2px solid rgba(255, 255, 255, 0.85); }
.qbar .qb-text span { font-weight: 700; border-bottom: 3px solid; line-height: 1.1; padding: 0 1px; }
.qbar .qb-word { font-weight: 600; }
.qbar .qb-danger:hover { background: rgba(232, 80, 91, 0.25); color: #ffd3d6; }
.qb-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.18); margin: 0 3px; }

/* Command search. */
.cmdk-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(16, 22, 28, 0.32); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.cmdk { width: 100%; max-width: 560px; background: var(--white); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.28); overflow: hidden; }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.cmdk-in .icon { width: 18px; height: 18px; color: var(--muted); }
.cmdk-in input { flex: 1; min-width: 0; height: 52px; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--ink); }
.cmdk-in kbd { font: inherit; font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); }
.cmdk-list { max-height: min(56vh, 420px); overflow-y: auto; padding: 6px; margin: 0; list-style: none; }
.cmdk-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.cmdk-list li small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cmdk-list li.on { background: var(--accent-soft); color: var(--accent-strong); }
.cmdk-list li.off { opacity: .55; }
.cmdk-list li.none { color: var(--muted); cursor: default; }
.cmdk-anchor { position: absolute; left: 50%; top: 40px; width: 1px; height: 1px; pointer-events: none; }

@media (max-width: 760px) {
  .dock { left: 8px; top: 8px; padding: 4px; border-radius: 12px; }
  .dk { width: 34px; height: 34px; }
  .editor .props { left: 64px; }
  .editor:has(.props:not(.collapsed):not([hidden])) .qbar { display: none; }
}

[data-theme="dark"] .cmdk-in kbd { background: transparent; border-color: #3a414b; color: #a3acb7; }
[data-theme="dark"] .dock { background: var(--white); border-color: #3a414b; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
[data-theme="dark"] .dk { color: #b8c0ca; }
[data-theme="dark"] .dk:hover { background: #2b3139; color: #fff; }
[data-theme="dark"] .dk.on { background: #14917f; color: #fff; }
[data-theme="dark"] .qbar { background: #eef1f4; color: #16191e; }
[data-theme="dark"] .qbar button { color: #2f363d; }
[data-theme="dark"] .qbar button:hover:not(:disabled) { background: rgba(0, 0, 0, 0.08); color: #000; }
[data-theme="dark"] .qbar .qb-swatch { border-color: rgba(0, 0, 0, 0.5); }
[data-theme="dark"] .qb-sep { background: rgba(0, 0, 0, 0.15); }
[data-theme="dark"] .cmdk { background: var(--white); border-color: #3a414b; }
[data-theme="dark"] .cmdk-scrim { background: rgba(0, 0, 0, 0.55); }

.dialog .actions .btn-danger-text { color: #c62828; border-color: transparent; background: none; margin-right: auto; }
.dialog .actions .btn-danger-text:hover { background: #fdecec; }
[data-theme="dark"] .dialog .actions .btn-danger-text { color: #ff8a80; background: none; border-color: transparent; }
.host-dialog .actions .btn-danger-text { margin-right: 0; }

/* "A newer version is ready" bar for tabs left open across a publish. */
.update-bar { position: fixed; z-index: 80; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; background: var(--ink); color: #fff; border-radius: 12px; box-shadow: 0 12px 30px rgba(16, 24, 40, 0.28); font-size: 14px; max-width: calc(100vw - 24px); }
.update-bar .btn { min-width: 0; }
.update-x { border: 0; background: none; color: rgba(255, 255, 255, 0.7); font-size: 20px; line-height: 1; padding: 0 4px; }
.update-x:hover { color: #fff; }
[data-theme="dark"] .update-bar { background: #eef1f4; color: #16191e; }
[data-theme="dark"] .update-x { color: #4a525d; }
