@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: "IBM Plex Sans", -apple-system, "system-ui", Arial, sans-serif;
  --text: #444444;
  --blue: #2872fa;
  --yellow: #ffbe36;
  --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 ---------- */
.shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
}
.sidebar {
  width: 241px;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--white);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}
.logo {
  display: block;
  margin: 20px 0 0 32px;
  width: 168px;
  height: 31px;
}
.logo svg, .logo img { display: block; width: 168px; height: 31px; }
.side-nav {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  width: 220px;
  row-gap: 4px;
  column-gap: 12px;
  margin: 60px 0 20px 20px;
  min-height: 0;
}
.nav-sections { width: 165px; }
.nav-list li { margin-bottom: 7.6px; }
.nav-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 10px;
  font-size: 16px;
  line-height: normal;
  color: var(--text);
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
}
.nav-link .icon { margin-top: 2px; }
.nav-link .label { border-bottom: 3px solid transparent; padding-bottom: 2px; margin-bottom: -5px; }
.nav-link:hover .label { color: #222; }
.nav-link.active .label { font-weight: 700; border-bottom-color: var(--yellow); }
.nav-divider { height: 1px; background: var(--line); margin: 9.4px 10px 0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  min-width: 101px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  font-size: 16px;
  line-height: 1;
  border: 1px solid transparent;
  background: var(--white);
}
.btn .icon { width: 20px; height: 20px; }
.btn-yellow { background: var(--yellow); border-color: var(--yellow); color: var(--text); }
.btn-yellow:hover { filter: brightness(0.97); }
.btn-outline { border-color: var(--blue); color: var(--blue); background: var(--white); }
.btn-outline:hover { background: #f1f6ff; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-plain { border-color: var(--border); }
.buy-wrap { margin: 28px 0 0 12px; }
.buy-wrap .btn { justify-content: flex-start; padding: 0 0 0 24px; }
.side-bottom li { margin-bottom: 7.6px; position: relative; }
.side-bottom .chev { margin-left: auto; }
.side-bottom .nav-link { width: 200px; }
.side-bottom .nav-link.options { width: 200px; padding-right: 0; }
.side-bottom li:first-child { margin-bottom: 5.6px; }
.side-bottom .login-wrap { margin: 18.8px 0 11.6px 12px; }
.login-wrap .btn { justify-content: flex-start; padding: 0 4px 0 16px; width: 101px; }

.categories {
  width: 240px;
  flex: none;
  background: var(--panel);
  padding: 90px 0 30px 30px;
  overflow-y: auto;
  height: 100%;
}
.search {
  position: relative;
  width: 180px;
  height: 30px;
}
.search input {
  width: 180px;
  height: 30px;
  border: 1px solid #f5f7f9;
  border-radius: 2px;
  background: var(--white);
  padding: 3px 34px 3px 6px;
  font-size: 11.9px;
  outline: none;
}
.search input:focus { border-color: var(--blue); }
.search input::placeholder { color: #757575; }
.search button {
  position: absolute;
  right: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 0 2px 2px 0;
  background: var(--button-grey);
  opacity: 0.7;
  color: #101010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.search button .icon { width: 18px; height: 18px; stroke: #6b6b6b; }
.cat-list { margin-top: 16px; padding-bottom: 4px; }
.cat-list li { line-height: 26px; }
.cat-list button {
  background: none;
  border: 0;
  padding: 0;
  font-size: 14px;
  line-height: 26px;
  color: var(--text);
  text-align: left;
}
.cat-list button:hover { color: var(--blue); }
.cat-list button.active { color: var(--blue); font-weight: 700; }

.main {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--page);
  padding: 55px 80px 60px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 29px;
  margin: 0 0 36px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title .crumb { font-weight: 400; font-size: 14px; color: var(--blue); background: none; border: 0; padding: 0; }
.section-title { font-size: 16px; font-weight: 700; margin: 0 0 20px; }
.section-gap { height: 40px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 40px;
}
.card {
  position: relative;
  width: 100%;
  max-width: 250px;
  justify-self: center;
  aspect-ratio: 1 / 1;
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  border: 0;
  padding: 0;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: rgba(0, 0, 0, 0.22) 0px 6px 14px 0px; }
.card:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.card .art {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6.8% 10% 0;
  min-height: 0;
}
.card .art svg { width: 100%; height: 100%; }
.card .card-label {
  border-radius: 0 0 12px 12px;
  background: var(--glass);
  padding: 7px 10px 11px;
  font-size: 14px;
  line-height: 18.2px;
}
.card .card-label span {
  display: block;
  max-width: 150px;
  margin: 0 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .card-sub { display: block; font-size: 12px; color: #888; margin-top: 2px; }
.card .star {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 0;
  background: var(--glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
}
.card .star.on { color: var(--yellow); }
.card .star.on svg { fill: var(--yellow); }
.card .more {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 0;
  background: var(--glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #777;
}
.card .thumb { width: 100%; height: 100%; border-radius: 12px 12px 0 0; }
.doc-card .art { padding: 12px 12px 0; align-items: center; }

.empty {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 30px;
  max-width: 560px;
  line-height: 1.6;
}
.empty p { margin: 0 0 16px; }
.prose { max-width: 640px; line-height: 1.6; font-size: 14px; }
.prose h2 { font-size: 16px; margin: 24px 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-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 20px;
}
.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, .popover label:hover { background: var(--page); }
.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; }
.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: top "Menu" bar ---------- */
.topbar { display: none; }
.drawer-scrim { display: none; }
@media (max-width: 1023px) {
  .shell { flex-direction: column; }
  .topbar {
    display: flex;
    align-items: center;
    height: 41px;
    flex: none;
    background: var(--glass);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
  }
  .menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: none;
    padding: 0;
    font-size: 14px;
    font-weight: 700;
    height: 40px;
  }
  .menu-btn .icon { width: 18px; height: 18px; }
  .body-row { flex: 1; min-height: 0; display: flex; }
  .sidebar, .categories {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-110%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    box-shadow: rgba(0, 0, 0, 0.18) 3px 0 12px;
  }
  .sidebar { left: 0; }
  .categories { left: 241px; transform: translateX(calc(-110% - 241px)); }
  .shell.drawer-open .sidebar, .shell.drawer-open .categories { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .shell.drawer-open .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(30, 34, 40, 0.35); }
  .main {
    border-left: 1px solid var(--border);
    padding: 14px 20px 40px 19px;
  }
}
@media (max-width: 520px) {
  .categories { left: 0; top: auto; height: auto; max-height: 45vh; width: 100%; padding: 16px 20px; transform: translateY(110%); }
  .sidebar { width: 100%; max-width: 280px; bottom: 45vh; }
  .shell.drawer-open .categories { transform: none; }
}
@media (min-width: 1024px) {
  .body-row { display: contents; }
}

/* ---------- 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: #e8f0ff; color: var(--blue); border-color: #c9dbff; }
.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: #e8f0ff; border-color: #c9dbff; 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;
}
@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: #e8f0ff; border-color: #c9dbff; color: var(--blue); }
.rb-checks { display: flex; flex-direction: column; justify-content: center; gap: 4px; 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: #ffd66b; border-color: #f2c14e; color: #333; }
.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: #fff4d6; }
.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: #f1f6ff; border-color: #d6e4ff; }
.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: #fff4d6; }
.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); }
.host-link { margin: 14px 0; }
.host-link label { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 14px; }
.host-link label .icon { width: 17px; height: 17px; }
.host-link .row2 { flex-wrap: nowrap; }
.host-link input { flex: 1; min-width: 0; height: 34px; border: 1px solid #ccc; border-radius: 6px; padding: 0 10px; font-size: 13px; margin: 0 !important; }
.host-edit { border: 1px solid #f2c6c6; background: #fff7f7; border-radius: 8px; padding: 10px 12px; }
.host-edit .warn { display: flex; gap: 6px; align-items: flex-start; color: #a02020; font-size: 13px; margin: 0 0 8px; }
.host-edit .warn .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.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: #eef3ff; color: #1f4fb8; 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: #5b9bff;
  --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: #5a4a1a; border-color: #8a7020; color: #ffe3a0; }
[data-theme="dark"] :is(.tb-btn.on, .rb-mini.on) { background: #1f3354; border-color: #2d4f86; color: #9cc2ff; }
[data-theme="dark"] :is(.side-item.on, .layer-row.on) { background: #3a3220; }
[data-theme="dark"] .lib-list { border-color: var(--border); }
[data-theme="dark"] .sym:hover { border-color: #2d4f86; }
[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: #1f2c40; }
[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: #2f6fe0; border-color: #2f6fe0; }
[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: #1f3354; color: #9cc2ff; }
[data-theme="dark"] .host-edit { background: #2a1d1f; border-color: #5a2f33; }
[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: #8fb8ff; }
[data-theme="dark"] .page-title .crumb, [data-theme="dark"] .sym-more { color: #8fb8ff; }
[data-theme="dark"] .nav-divider { background: #343a42; }
[data-theme="dark"] .btn-outline { color: #8fb8ff; border-color: #5b9bff; }
[data-theme="dark"] .empty, [data-theme="dark"] .panel { color: var(--text); }
[data-theme="dark"] .prose a { color: #8fb8ff; }

/* 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(40, 114, 250, .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: #2f6fe0; border-color: #2f6fe0; color: #fff; box-shadow: none; }
.viewer-pages[hidden] { display: none; }
