/* =============================================================================
   animation STUDIO — interface styles

   One system, top to bottom:
     1. Tokens (colours, sizes) for the dark and light themes
     2. Base elements
     3. Controls: buttons, inputs, tooltips
     4. Layout: top bar, tool strip, media library, canvas, inspector
     5. Panels' contents: sections, fields, layers, filters, exports
     6. Dialogs and the sign-in screen
     7. On-canvas editing handles

   Rules of the system:
     - 4px spacing steps. Controls are 28px or 32px tall.
     - Docked regions are flat and separated by one hairline. Only things that
       float over the canvas (zoom, export result, dialogs, tooltips) get a
       shadow and a larger radius.
     - One accent colour, marigold. It marks the primary action, the current
       selection and focus, and nothing else. It is warm on purpose: most
       diagrams are blue and grey, so selection handles stay easy to see.
     - Sentence case everywhere; no all-caps labels.
   ============================================================================= */

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

/* Firjar (Arabic and Latin) and Roboto, from Google Fonts (SIL Open Font License).
   Variable fonts: Firjar weights 100-800, Roboto 100-900. */
@font-face {
  font-family: "Firjar";
  src: url("/fonts/firjar-arabic.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: "Firjar";
  src: url("/fonts/firjar-latin-ext.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Firjar";
  src: url("/fonts/firjar-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Roboto";
  src: url("/fonts/roboto-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Roboto";
  src: url("/fonts/roboto-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Bold headline fonts from Google Fonts (SIL Open Font License): Montserrat,
   Poppins, Inter and Outfit. Latin and Latin Extended only. */
@font-face {
  font-family: "Montserrat";
  src: url("/fonts/montserrat-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Montserrat";
  src: url("/fonts/montserrat-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-400-latin-ext.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-500-latin-ext.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-600-latin-ext.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-600-latin.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-700-latin-ext.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-800-latin-ext.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-800-latin.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-900-latin-ext.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/poppins-900-latin.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Outfit";
  src: url("/fonts/outfit-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Outfit";
  src: url("/fonts/outfit-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Boldonse from Google Fonts (SIL Open Font License). It has a single ultra-heavy
   face, declared for every weight so browsers never add a fake bold on top. */
@font-face {
  font-family: "Boldonse";
  src: url("/fonts/boldonse-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Boldonse";
  src: url("/fonts/boldonse-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ----------------------------- 1. tokens ----------------------------- */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --canvas: #17181b; /* the area around the artwork */
  --surface: #1f2024; /* bars and panels */
  --surface-2: #292a30; /* inputs, hover */
  --surface-3: #33353c; /* pressed, counters */
  --line: #2d2f35;
  --line-strong: #43464e;

  --text: #ededf0;
  --text-2: #adb0b9;
  --text-3: #7b7f8a;

  --accent: #f5a524;
  --accent-hover: #ffb84a;
  --accent-ink: #f5a524; /* accent used as text or a thin line */
  --accent-soft: rgba(245, 165, 36, 0.14);
  --on-accent: #1e1604;

  --danger: #f27272;
  --danger-soft: rgba(242, 114, 114, 0.14);
  --ok: #5fcf8a;

  --checker-a: #2a2b31;
  --checker-b: #35373e;
  --scroll-thumb: rgba(255, 255, 255, 0.24);
  --scroll-track: rgba(255, 255, 255, 0.05);
  --artwork-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
  --float-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --dialog-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  --backdrop: rgba(8, 8, 10, 0.6);

}

/* Sizes are the same in both themes. */
:root {
  --bar-height: 48px;
  --footer-height: 28px;
  --rail-width: 52px;
  --media-width: 236px;
  --inspector-width: 304px;

  /* A name the editor script still refers to. */
  --muted-2: var(--text-3);
}

:root[data-theme="light"] {
  color-scheme: light;

  --canvas: #e8e8ec;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e6e6eb;
  --line: #e4e4e9;
  --line-strong: #cdced6;

  --text: #1b1c21;
  --text-2: #565963;
  --text-3: #868995;

  --accent: #f5a524;
  --accent-hover: #eb9a14;
  --accent-ink: #a86500;
  --accent-soft: rgba(245, 165, 36, 0.18);
  --on-accent: #1e1604;

  --danger: #cf3f3f;
  --danger-soft: rgba(207, 63, 63, 0.1);
  --ok: #1f9d57;

  --checker-a: #f4f4f7;
  --checker-b: #e4e4ea;
  --scroll-thumb: rgba(20, 22, 30, 0.28);
  --scroll-track: rgba(20, 22, 30, 0.06);
  --artwork-shadow: 0 2px 14px rgba(20, 22, 30, 0.16);
  --float-shadow: 0 8px 28px rgba(20, 22, 30, 0.16);
  --dialog-shadow: 0 24px 64px rgba(20, 22, 30, 0.24);
  --backdrop: rgba(20, 22, 30, 0.4);
}

/* ----------------------------- 2. base ----------------------------- */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

::selection {
  background: var(--accent-soft);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--scroll-thumb);
  background-clip: content-box;
}

.ico {
  display: block;
  flex: none;
  width: 16px;
  height: 16px;
}

/* ----------------------------- 3. controls ----------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
}

.btn-ghost {
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn-outline {
  border-color: var(--line-strong);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-link {
  height: auto;
  padding: 2px 4px;
  color: var(--accent-ink);
  font-size: 12.5px;
}

.btn-link:hover:not(:disabled) {
  background: transparent;
  text-decoration: underline;
}

.btn-block {
  width: 100%;
}

.btn-square {
  width: 32px;
  padding: 0;
}

.btn-danger-outline {
  color: var(--danger);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn .ico {
  width: 14px;
  height: 14px;
}

.input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  transition: border-color 120ms ease;
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus,
.input:focus-visible {
  outline: none;
  border-color: var(--accent-ink);
}

.input:disabled {
  opacity: 0.45;
}

.input::placeholder {
  color: var(--text-3);
}

.input[type="number"] {
  -moz-appearance: textfield;
}

.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* Sliders: a thin neutral track with a round thumb that turns marigold in use. */
.input[type="range"] {
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
}

.input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
}

.input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  -webkit-appearance: none;
  transition: background 120ms ease, transform 120ms ease;
}

.input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

.input[type="range"]:hover::-webkit-slider-thumb,
.input[type="range"]:focus-visible::-webkit-slider-thumb {
  background: var(--accent);
  transform: scale(1.15);
}

.input[type="range"]:hover::-moz-range-thumb,
.input[type="range"]:focus-visible::-moz-range-thumb {
  background: var(--accent);
}

.input[type="range"]:focus-visible {
  outline: none;
}

.input[type="color"] {
  padding: 3px;
  cursor: pointer;
}

/* Tooltips: put the text in data-tip. They sit under the control by default. */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 60;
  transform: translateX(-50%);
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  transition-delay: 350ms;
}

/* A greyed-out control would show a greyed-out tooltip, so it shows none. */
[data-tip]:disabled::after {
  display: none;
}

@media (hover: none) {
  [data-tip]::after {
    display: none;
  }
}

/* ----------------------------- 4. layout ----------------------------- */

.app {
  display: grid;
  grid-template-rows: var(--bar-height) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
}

/* ---- top bar ---- */

.topbar {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.topbar-sep {
  flex: none;
  width: 1px;
  height: 20px;
  margin: 0 8px;
  background: var(--line);
}

.topbar-end [data-tip]::after {
  right: 0;
  left: auto;
  transform: none;
}

.topbar-end .btn-primary {
  margin-left: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* The mark is a dashed outline, the app's own subject. It marches while a GIF renders. */
.brand-mark {
  flex: none;
  width: 20px;
  height: 20px;
}

.brand-mark rect {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
}

body.is-exporting .brand-mark rect {
  animation: mark-march 500ms linear infinite;
}

@keyframes mark-march {
  to {
    stroke-dashoffset: -10;
  }
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.brand-text strong {
  font-size: 13px;
  font-weight: 600;
}

.brand-text span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.project-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease;
}

.project-switch:hover {
  background: var(--surface-2);
}

.project-switch > .btn-icon {
  color: var(--text-3);
}

.project-switch-name {
  max-width: 280px;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-switch-caret .ico {
  width: 14px;
  height: 14px;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  margin-left: 4px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.save-state:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.save-state:has(#asset-chip-size:empty) {
  display: none;
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}

.save-state[data-state="saved"] .save-dot {
  background: var(--ok);
}

.save-state[data-state="saving"] .save-dot,
.save-state[data-state="dirty"] .save-dot {
  background: var(--accent);
}

.save-state[data-state="error"] {
  color: var(--danger);
}

.save-state[data-state="error"] .save-dot {
  background: var(--danger);
}

:root[data-theme="dark"] .theme-icon-light,
:root[data-theme="light"] .theme-icon-dark {
  display: none;
}

/* ---- workspace: tools | media | canvas | inspector ---- */

.workspace {
  display: grid;
  grid-template-columns: var(--rail-width) var(--media-width) minmax(0, 1fr) var(--inspector-width);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "tools media canvas inspector";
  min-width: 0;
  min-height: 0;
}

.workspace.media-closed {
  grid-template-columns: var(--rail-width) 0 minmax(0, 1fr) var(--inspector-width);
}

.workspace.media-closed .media-dock {
  display: none;
}

/* ---- tool strip ---- */

.rail {
  grid-area: tools;
  position: relative;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.rail-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.rail-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.rail-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.rail-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.rail-glyph {
  display: grid;
  place-items: center;
}

.rail-glyph .ico {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.rail-divider {
  width: 20px;
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

.rail-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.rail [data-tip]::after {
  top: 50%;
  left: calc(100% + 10px);
  transform: translateY(-50%);
}

/* ---- media library ---- */

.media-dock {
  grid-area: media;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 8px 9px 14px;
}

.dock-head strong {
  font-size: 13px;
  font-weight: 600;
}

.media-dock > .btn-block {
  width: auto;
  margin: 0 12px;
}

.dock-note {
  margin: 8px 14px 2px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-list {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px 8px;
  min-height: 0;
  padding: 8px 12px 14px;
  overflow-y: auto;
}

.upload-list .layers-empty {
  grid-column: 1 / -1;
  padding: 4px 2px;
}

.media-card {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.media-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%),
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%);
  background-position: 0 0, 6px 6px;
  background-size: 12px 12px;
  cursor: pointer;
  transition: border-color 120ms ease;
}

.media-thumb:hover {
  border-color: var(--text-3);
}

.media-card.active .media-thumb {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.media-thumb img {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
}

.media-meta {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding-left: 2px;
}

.media-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-meta .icon-btn {
  width: 22px;
  height: 22px;
}

.upload-active-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px;
  font-weight: 600;
}

/* ---- canvas ---- */

.stage {
  grid-area: canvas;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) var(--footer-height);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--canvas);
}

.preview-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: default;
}

.preview-frame.pan-ready {
  cursor: grab;
}

.preview-frame.panning {
  cursor: grabbing;
}

/* Room around the artwork, and space at the bottom for the zoom control. */
.preview-surface {
  position: absolute;
  inset: 24px 28px 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 140ms ease;
  will-change: transform;
}

.preview-surface.is-panning,
.preview-surface.is-scaling {
  transition: none;
}

.preview-surface svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(var(--artwork-shadow));
}

.canvas-scrollbar {
  position: absolute;
  top: 8px;
  right: 5px;
  bottom: 8px;
  z-index: 5;
  width: 8px;
  border-radius: 999px;
  background: var(--scroll-track);
  cursor: pointer;
}

.canvas-scroll-thumb {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  min-height: 28px;
  border-radius: 999px;
  background: var(--scroll-thumb);
  cursor: grab;
  touch-action: none;
  transition: background 120ms ease;
}

.canvas-scroll-thumb:hover,
.canvas-scrollbar.dragging .canvas-scroll-thumb {
  background: var(--accent);
}

.canvas-scrollbar.dragging .canvas-scroll-thumb {
  cursor: grabbing;
}

.canvas-scrollbar.idle .canvas-scroll-thumb {
  opacity: 0.45;
}

.zoom-controls {
  position: absolute;
  bottom: calc(var(--footer-height) + 14px);
  left: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--float-shadow);
  transform: translateX(-50%);
}

.zoom-btn {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.zoom-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.zoom-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.zoom-btn.zoom-display {
  min-width: 52px;
  color: var(--text);
}

.zoom-divider {
  width: 1px;
  height: 16px;
  margin: 0 3px;
  background: var(--line);
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.empty-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 36px 40px 30px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  text-align: center;
  pointer-events: auto;
}

.empty-card > strong {
  font-size: 17px;
  font-weight: 600;
}

.empty-card > span {
  color: var(--text-2);
  line-height: 1.5;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.empty-card > .empty-hint {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 12px;
}

/* Dropping a file: the outline marches, like a selection waiting for its content. */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  pointer-events: none;
}

.preview-frame.drag-over .drop-overlay {
  display: flex;
}

.drop-card {
  display: grid;
  gap: 4px;
  padding: 30px 52px;
  background-color: var(--surface);
  background-image:
    linear-gradient(90deg, var(--accent) 50%, transparent 50%),
    linear-gradient(90deg, var(--accent) 50%, transparent 50%),
    linear-gradient(0deg, var(--accent) 50%, transparent 50%),
    linear-gradient(0deg, var(--accent) 50%, transparent 50%);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-size: 16px 2px, 16px 2px, 2px 16px, 2px 16px;
  text-align: center;
  animation: border-march 500ms linear infinite;
}

@keyframes border-march {
  to {
    background-position: 16px 0, -16px 100%, 0 -16px, 100% 16px;
  }
}

.drop-card strong {
  font-size: 15px;
  font-weight: 600;
}

.drop-card span {
  color: var(--text-2);
  font-size: 12px;
}

.result-block {
  position: absolute;
  bottom: calc(var(--footer-height) + 14px);
  left: 14px;
  z-index: 5;
  display: grid;
  gap: 8px;
  width: 292px;
  max-width: calc(100% - 28px);
  padding: 10px 12px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--float-shadow);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-head strong {
  font-size: 12.5px;
  font-weight: 600;
}

.result-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.result-card img {
  width: 96px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--checker-a);
  object-fit: contain;
}

.download-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}

.download-link:hover {
  background: var(--accent-hover);
}

.stage-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
}

.status-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-chip {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- inspector ---- */

.inspector {
  grid-area: inspector;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.inspector-tabs {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  gap: 2px;
  padding: 0 6px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 120ms ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent-ink);
}

.tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.inspector-body {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.tab-panel {
  display: none;
  padding-bottom: 20px;
}

.tab-panel.active {
  display: block;
}

/* ----------------------------- 5. panel contents ----------------------------- */

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 2px;
  padding: 14px 14px 12px;
}

.panel-head strong {
  font-size: 13px;
  font-weight: 600;
}

.panel-sub {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}

/* Collapsible sections */
.group {
  border-top: 1px solid var(--line);
}

.group-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 13px;
  font-size: 12.5px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.group-summary::-webkit-details-marker {
  display: none;
}

.group-summary::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin: 0 3px 2px 1px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}

.group[open] > .group-summary::before {
  transform: rotate(45deg);
}

.group-summary:hover::before {
  border-color: var(--text);
}

.group-hint {
  max-width: 58%;
  margin-left: auto;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 10px;
  padding: 2px 14px 14px;
}

/* Fields: label beside the control in a section, label above it in a pair or a dialog. */
.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field-label {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.3;
}

.group-body > .field,
.filter-adjustment-fields > .field {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.group-body > .text-content-field {
  grid-template-columns: minmax(0, 1fr);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.range-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  align-items: center;
  gap: 8px;
}

.range-field .input[type="number"] {
  padding: 0 6px;
  text-align: right;
}

.field-row .range-field {
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 6px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.check-field input[type="checkbox"],
.filter-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.hint-card,
.empty-inspector {
  display: grid;
  gap: 2px;
  margin: 0 14px 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

.hint-card strong,
.empty-inspector strong {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.tab-panel > .field-row,
.tab-panel > .btn-block {
  margin: 14px 14px 0;
}

.tab-panel > .btn-block {
  width: auto;
}

.layers-empty {
  padding: 14px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}

/* Layers */
.layers-list {
  display: grid;
  gap: 1px;
  padding: 8px;
}

.layers-list .layers-empty {
  padding: 6px;
}

.layer-card {
  display: grid;
  grid-template-columns: 10px 16px 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 4px 0 6px;
  border-radius: 6px;
  cursor: pointer;
}

.layer-card:hover {
  background: var(--surface-2);
}

.layer-card.active {
  background: var(--accent-soft);
}

.layer-select { margin: 0; accent-color: var(--accent); cursor: pointer; }
.layers-selection-tools, .bulk-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.layers-selection-tools { position: sticky; top: -8px; z-index: 1; background: var(--surface); padding: 4px 0; }
.layers-selection-tools > span { margin-right: auto; color: var(--text-2); font-size: 11px; }
.selection-hint { color: var(--text-3); font-size: 11px; padding: 4px 6px 8px; }
.bulk-actions { padding: 8px 12px; }
.multi-selection-outline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 7 4; pointer-events: none; }

.layer-glyph {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--text-2);
}

.layer-card.active .layer-glyph {
  color: var(--accent-ink);
}

.layer-meta {
  display: grid;
  min-width: 0;
}

.layer-name {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-kind {
  color: var(--text-3);
  font-size: 11px;
}

.layer-actions {
  display: flex;
  opacity: 0;
  transition: opacity 100ms ease;
}

.layer-card:hover .layer-actions,
.layer-card.active .layer-actions,
.layer-card:focus-within .layer-actions {
  opacity: 1;
}

/* Exports */
.history {
  display: grid;
  gap: 1px;
  padding: 0 8px;
}

.history a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 6px;
  color: var(--text);
  font-size: 12.5px;
  text-decoration: none;
}

.history a:hover {
  background: var(--surface-2);
}

.history a span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history a small {
  flex: none;
  color: var(--text-3);
  font-size: 11px;
}

.history .layers-empty {
  padding: 6px;
}

/* Filters */
.filter-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.filter-preset {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 4px 4px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.filter-preset:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.filter-preset.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.filter-swatch {
  position: relative;
  display: block;
  height: 42px;
  overflow: hidden;
  border-radius: 5px;
  background: linear-gradient(155deg, #4b9ccc, #b4d8da 48%, #f3b982 49%, #e8a66b);
}

.filter-swatch::before {
  content: "";
  position: absolute;
  top: 7px;
  right: 13px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffe4a1;
}

.filter-swatch::after {
  content: "";
  position: absolute;
  inset: 18px -8px -10px;
  background: #368275;
  clip-path: polygon(0 100%, 0 65%, 38% 0, 60% 60%, 80% 10%, 100% 65%, 100% 100%);
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.filter-adjustments > summary {
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

.filter-adjustments > summary:hover {
  color: var(--text);
}

.filter-adjustment-fields {
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

/* ----------------------------- 6. dialogs and sign-in ----------------------------- */

.account-name { color: var(--text-2); font-size: 12px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
.users-dialog { width: min(680px, calc(100vw - 32px)) !important; max-height: calc(100dvh - 40px); overflow-y: auto; }
.users-heading, .user-row, .user-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.users-list { max-height: 280px; overflow-y: auto; border-block: 1px solid var(--line); }
.user-row { padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.user-row:last-child { border: 0; }
.user-row strong, .user-row small { display: block; overflow-wrap: anywhere; }
.user-row small, .account-form small { color: var(--text-2); font-size: 12px; }
.account-form { display: grid; gap: 14px; padding-top: 8px; }
.account-form[hidden] { display: none; }
.account-form h3 { font-size: 14px; }
.users-status { min-height: 18px; font-size: 12px; color: var(--text-2); }
.users-status.error { color: var(--danger); }
@media (max-width: 700px) { .account-name { display: none; } .account-form .field-row { grid-template-columns: 1fr; } }

.blank-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--dialog-shadow);
  color: var(--text);
}

.blank-dialog::backdrop {
  background: var(--backdrop);
}

.blank-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.blank-form h2 {
  font-size: 16px;
  font-weight: 600;
}

.blank-note {
  margin-top: -8px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.blank-form .input {
  height: 32px;
}

.blank-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.projects-dialog {
  width: min(560px, calc(100vw - 32px));
}

.projects-list {
  display: grid;
  gap: 2px;
  max-height: min(52vh, 420px);
  margin: 0 -8px;
  overflow-y: auto;
}

.projects-list .layers-empty {
  padding: 8px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
}

.project-row:hover {
  background: var(--surface-2);
}

.project-row.active {
  background: var(--accent-soft);
}

.project-main {
  display: grid;
  min-width: 0;
}

.blank-form .project-name {
  height: 26px;
  padding: 0 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.blank-form .project-name:focus {
  background: var(--surface);
}

.project-meta {
  padding-left: 7px;
  color: var(--text-3);
  font-size: 11.5px;
}

.project-row .btn {
  height: 28px;
}

.project-row .icon-btn.confirming {
  width: auto;
  padding: 0 8px;
  background: var(--danger);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
}

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

.projects-spacer {
  flex: 1;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(380px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--dialog-shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand .brand-mark {
  width: 28px;
  height: 28px;
}

.auth-brand-copy {
  display: grid;
}

.auth-brand-copy strong {
  font-size: 16px;
  font-weight: 600;
}

.auth-brand-copy span {
  color: var(--text-3);
  font-size: 12.5px;
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

.auth-form .input {
  height: 34px;
  font-size: 13px;
}

.auth-form .btn-primary {
  height: 36px;
  margin-top: 2px;
}

.auth-status {
  min-height: 18px;
  color: var(--text-3);
  font-size: 12.5px;
}

.auth-status.error {
  color: var(--danger);
}

.auth-status.success {
  color: var(--ok);
}

/* ----------------------------- 7. on-canvas editing ----------------------------- */

/* The moving lines themselves. app.js sets --ants-shift so the preview loops like the export. */
.ants {
  animation-name: marching-ants;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes marching-ants {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: var(--ants-shift, -68);
  }
}

.selected-connector,
.selected-shape {
  filter: drop-shadow(0 0 5px rgba(245, 165, 36, 0.85));
}

.handle,
.handle.active {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2;
  cursor: grab;
}

.center-handle,
.center-handle.active {
  fill: var(--accent);
  stroke: #ffffff;
  stroke-width: 1.5;
  cursor: grab;
}

.image-hit {
  fill: transparent;
  stroke: transparent;
  cursor: move;
}

.image-hit:hover {
  stroke: rgba(245, 165, 36, 0.6);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.image-hit.selected {
  stroke: var(--accent);
  stroke-width: 1.75;
  stroke-dasharray: 6 4;
}

.delete-action,
.duplicate-action {
  cursor: pointer;
}

.delete-action circle,
.duplicate-action circle {
  fill: #1f2024;
  stroke: #ffffff;
  stroke-width: 1.5;
  transition: fill 120ms ease;
}

.duplicate-action:hover circle {
  fill: #3a3c44;
}

.delete-action:hover circle {
  fill: #cf3f3f;
}

/* ---- brush, eraser and layer order ---- */

/* Floating options bar for the brush and eraser, at the top of the canvas. */
.tool-options {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--float-shadow);
  color: var(--text-2);
  font-size: 12px;
  transform: translateX(-50%);
}

.tool-options[hidden] {
  display: none;
}

.tool-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

.tool-name .ico {
  width: 16px;
  height: 16px;
  color: var(--accent-ink);
}

.tool-sep {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
}

.tool-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-field input[type="range"] {
  width: 96px;
  accent-color: var(--accent);
}

.tool-field output {
  min-width: 38px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tool-note {
  color: var(--text-3);
}

.tool-done {
  height: 28px;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.swatch {
  position: relative;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
}

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

/* The last swatch opens the system colour picker. */
.swatch-custom {
  overflow: hidden;
  background: conic-gradient(from 90deg, #e5484d, #ffc53d, #30a46c, #0090ff, #8e4ec6, #e5484d);
}

.swatch-custom.active {
  background: var(--swatch);
}

.swatch-custom input {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
}

.preview-frame.drawing .draw-surface {
  cursor: crosshair;
}

.preview-frame.drawing.pan-ready .draw-surface {
  cursor: grab;
}

.tool-cursor {
  stroke: #ffffff;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  paint-order: stroke;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.8));
}

.tool-cursor.eraser {
  stroke: #1b1c21;
  stroke-dasharray: 4 3;
}

.stroke-hit {
  cursor: move;
}

.stroke-outline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.arrange-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.arrange-btn {
  justify-content: flex-start;
  gap: 6px;
}

.arrange-btn .ico {
  width: 14px;
  height: 14px;
}

.layer-grip {
  display: grid;
  place-items: center;
  color: var(--text-3);
  cursor: grab;
  opacity: 0.6;
}

.layer-grip .ico {
  width: 12px;
  height: 12px;
}

.layer-card:hover .layer-grip {
  opacity: 1;
}

.layer-card.dragging {
  opacity: 0.45;
}

.layer-card.drop-above {
  box-shadow: inset 0 2px 0 var(--accent);
}

.layer-card.drop-below {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.layer-actions .icon-btn {
  width: 22px;
}

.layer-actions .icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: transparent;
}

.layer-paint .ico {
  width: 16px;
  height: 16px;
}

/* ----------------------------- small screens and motion ----------------------------- */
.blank-dialog.template-mode { width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; }
.template-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.template-content { display: grid; gap: 12px; min-width: 0; }
.blank-form .template-items { height: auto; min-height: 120px; resize: vertical; line-height: 1.5; padding: 8px 10px; }
.template-preview-column { min-width: 0; }
.template-preview { background: var(--canvas); border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.template-preview svg { display: block; width: 100%; max-height: 360px; }
.template-preview-column .blank-note { margin-top: 12px; }
.template-error { color: var(--danger); font-size: 12px; }
.template-logos { font-size: 12px; }
.template-logos summary { cursor: pointer; padding: 6px 0; color: var(--text-2); }
#template-item-logos { display: grid; gap: 8px; max-height: 200px; overflow-y: auto; padding: 8px 0; }
.text-hit { fill: transparent; cursor: move; }
.text-hit.selected { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }
@media (max-width: 640px) { .template-editor { grid-template-columns: minmax(0, 1fr); } }

@media (max-width: 1180px) {
  :root {
    --media-width: 204px;
    --inspector-width: 280px;
  }

  .brand-text {
    display: none;
  }

  .inspector-tabs {
    gap: 0;
    padding: 0 4px;
  }

  .inspector-tabs .tab-btn {
    gap: 4px;
    padding: 0 6px;
  }
}

@media (max-width: 920px) {
  .workspace,
  .workspace.media-closed {
    grid-template-columns: var(--rail-width) 0 minmax(0, 1fr) 264px;
  }

  .media-dock {
    display: none;
  }

  .stage-chip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drop-card,
  body.is-exporting .brand-mark rect {
    animation: none;
  }

  .preview-surface,
  .btn,
  .input {
    transition: none;
  }
}
