/* shadcn/ui components, ported to plain CSS (no React, no Tailwind, no build step).
   Source of the values: the shadcn registry, style "new-york-v4" (https://ui.shadcn.com/r/styles/new-york-v4/<name>.json,
   read 2026-11-11): button, input, label, card, badge, separator, textarea, dialog, tabs, accordion, switch, slider,
   toggle-group, dropdown-menu, progress, alert (the last three read 2026-11-12). Each Tailwind class was turned into the CSS it stands for (h-9 = 36px, rounded-md = --radius-md,
   shadow-xs, ring-[3px] ring-ring/50 = --focus-ring, and so on).
   Our markup keeps its own class names (.btn, .seg, .switch ...) and its ARIA roles, so the editor's scripts and tests
   do not change. A native <select> and <input type="range"> are styled to look like shadcn's Select and Slider.
   Where we differ from shadcn on purpose, the rule says so. */

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; border-color: var(--border); }
h1, h2, h3, h4, p { margin: 0; }
body { margin: 0; -webkit-font-smoothing: antialiased; font-family: var(--font-sans); font-size: 14px; font-weight: 400; line-height: 1.5; color: var(--foreground); background: var(--background); }
a { color: inherit; }
::selection { background: var(--primary); color: var(--primary-foreground); }
:focus-visible { outline: none; }

/* ---- Button ---- */
.btn { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; white-space: nowrap;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs);
  font: 500 14px/1 var(--font-sans); text-decoration: none; cursor: pointer; outline: none; transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s; } /* opacity is not animated: a contrast check in the middle of a fade would read a faded colour */
.btn:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--accent); color: var(--accent-foreground); }
.btn:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); }
.btn:disabled { pointer-events: none; opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); color: var(--primary-foreground); border-color: transparent; box-shadow: none; }
.btn.primary:hover:not(:disabled) { background: color-mix(in oklab, var(--primary) 90%, transparent); color: var(--primary-foreground); }
.btn.secondary { background: var(--secondary); color: var(--secondary-foreground); border-color: transparent; box-shadow: none; }
.btn.secondary:hover:not(:disabled) { background: color-mix(in oklab, var(--secondary) 80%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--accent); }
.btn.danger { background: var(--destructive); color: #fff; border-color: transparent; box-shadow: none; }       /* shadcn "destructive" */
.btn.danger:hover:not(:disabled) { background: color-mix(in oklab, var(--destructive) 90%, transparent); color: #fff; }
.btn.danger:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklab, var(--destructive) 20%, transparent); }
.btn.link { background: transparent; border-color: transparent; box-shadow: none; color: var(--primary); }
.btn.link:hover:not(:disabled) { background: transparent; text-decoration: underline; text-underline-offset: 4px; }
.btn.wide { width: 100%; }
.btn.sm { height: 32px; padding: 0 12px; gap: 6px; }
.btn.lg { height: 40px; padding: 0 24px; }
.icon-btn { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); cursor: pointer; outline: none; transition: background-color .15s, border-color .15s, box-shadow .15s; }
.icon-btn:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
.icon-btn:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); }
.icon-btn:disabled { pointer-events: none; opacity: .5; cursor: not-allowed; }
.icon-btn .ico { width: 16px; height: 16px; }
.file-btn:focus-within { border-color: var(--ring); box-shadow: var(--focus-ring); }

/* ---- Input, Textarea, Select, Label ---- */
label, .label { font-size: 14px; font-weight: 500; line-height: 1; }
.field { display: grid; gap: 8px; font-weight: 500; }
input[type="text"], input[type="email"], input[type="search"], input[type="url"], input[type="password"], select, textarea {
  width: 100%; min-width: 0; height: 36px; padding: 4px 12px; border: 1px solid var(--input); border-radius: var(--radius-md); background: transparent; color: var(--foreground);
  box-shadow: var(--shadow-xs); font: 400 14px/1.4 var(--font-sans); outline: none; transition: color .15s, box-shadow .15s, border-color .15s; }
textarea { height: auto; min-height: 64px; padding: 8px 12px; }
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }
input[type="text"]:focus-visible, input[type="email"]:focus-visible, input[type="search"]:focus-visible, input[type="url"]:focus-visible, input[type="password"]:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
/* a native <select> dressed as shadcn's Select trigger */
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
input[type="color"] { width: 44px; height: 36px; padding: 3px; border: 1px solid var(--input); border-radius: var(--radius-md); background: transparent; box-shadow: var(--shadow-xs); cursor: pointer; }
input[type="color"]:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); outline: none; }

/* ---- Slider (a native range input; --pct is set by shadcn.js) ---- */
input[type="range"] { --pct: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; outline: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 9999px; background: linear-gradient(to right, var(--primary) var(--pct), var(--muted) var(--pct)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 9999px; background: var(--muted); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 9999px; background: var(--primary); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%; border: 1px solid var(--primary); background: #fff; box-shadow: var(--shadow-sm); transition: box-shadow .15s; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--primary); background: #fff; box-shadow: var(--shadow-sm); transition: box-shadow .15s; }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 50%, transparent); }
input[type="range"]:hover::-moz-range-thumb, input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 50%, transparent); }
input[type="range"]:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Switch (a button with role="switch") ---- */
.switch { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 4px 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; font: 500 14px/1.3 var(--font-sans); outline: none; }
.switch-track { display: inline-flex; align-items: center; flex: none; width: 32px; height: 1.15rem; border: 1px solid transparent; border-radius: 9999px; background: var(--input); box-shadow: var(--shadow-xs); transition: background-color .15s, box-shadow .15s, border-color .15s; }
.switch-thumb { display: block; width: 16px; height: 16px; border-radius: 9999px; background: var(--background); transition: transform .15s; }
.switch[aria-checked="true"] .switch-track { background: var(--primary); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(calc(100% - 2px)); }
.switch:focus-visible .switch-track { border-color: var(--ring); box-shadow: var(--focus-ring); }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Tabs (role="tablist", the "default" variant) ---- */
.tabs { display: flex; align-items: center; gap: 0; height: 36px; margin: 12px 16px 0; padding: 3px; border: 0; border-radius: var(--radius-lg); background: var(--muted); overflow-x: auto; flex: none; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; height: calc(100% - 1px); padding: 0 6px; border: 1px solid transparent; border-radius: var(--radius-md);
  background: transparent; color: var(--muted-foreground); font: 500 13px/1 var(--font-sans); white-space: nowrap; cursor: pointer; outline: none; transition: color .15s, background-color .15s, box-shadow .15s; }
.tabs [role="tab"]:hover { color: var(--foreground); }
.tabs [role="tab"]:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); }
.tabs [role="tab"][aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-sm); }

/* ---- Toggle group (role="radiogroup", the "outline" variant) ---- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-xs); }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; height: 36px; padding: 0 8px; border: 1px solid var(--input); border-left-width: 0; background: transparent; color: var(--foreground);
  font: 500 14px/1 var(--font-sans); cursor: pointer; outline: none; transition: background-color .15s, color .15s; }
.seg button:first-child { border-left-width: 1px; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.seg button:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.seg button:hover { background: var(--muted); }
.seg button:focus-visible { position: relative; z-index: 1; border-color: var(--ring); box-shadow: var(--focus-ring); }
/* The selected button is filled with the primary colour (shadcn's own selected style, bg-accent, is too faint for an editor). */
.seg button[aria-checked="true"] { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.seg .ico { width: 16px; height: 16px; }

/* ---- Card ---- */
.card { display: flex; flex-direction: column; gap: 24px; padding: 24px 0; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow-sm); }
.card-header, .card-content, .card-footer { padding: 0 24px; }
.card-header { display: grid; gap: 8px; }
.card-title { font-weight: 600; line-height: 1; }
.card-description { font-size: 14px; color: var(--muted-foreground); }
.card-footer { display: flex; align-items: center; }
/* choosable cards in the editor (frames, backgrounds, sizes) */
.frame-btn, .sw, .size-btn { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s; }
.frame-btn:hover, .sw:hover, .size-btn:hover { border-color: var(--ring); }
.frame-btn:focus-visible, .sw:focus-visible, .size-btn:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); outline: none; }
.frame-btn[aria-checked="true"], .sw[aria-checked="true"], .size-btn[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan-card { display: grid; gap: 8px; align-content: start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-sm); }

/* ---- Badge ---- */
.badge-pill { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: fit-content; padding: 2px 8px; border: 1px solid transparent; border-radius: 9999px; background: var(--primary); color: var(--primary-foreground); font-size: 12px; font-weight: 500; line-height: 1.33; white-space: nowrap; }
.badge-pill.secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-pill.outline { background: transparent; color: var(--foreground); border-color: var(--border); }

/* ---- Dialog ---- */
.dialog { width: calc(100% - 2rem); max-width: 26.25rem; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--background); color: var(--foreground); box-shadow: var(--shadow-lg); }
.dialog.dialog-wide { max-width: 32rem; }
.dialog.dialog-xl { max-width: 52rem; padding: 0; overflow: hidden; }
.dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog form, .dialog-body { display: grid; gap: 16px; }
.dialog-body > p, .dialog-body > h2 { margin: 0; }
.dialog h2 { font-size: 18px; font-weight: 600; line-height: 1; letter-spacing: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* ---- Dropdown menu (role="menu" with role="menuitem" children; the script is account-menu.js) ----
   Values from the registry's dropdown-menu: content = rounded-md border bg-popover p-1 shadow; item = gap-2 rounded-sm px-2 py-1.5 text-sm,
   focus = bg-accent; icons are 16 px in the muted colour; separator = -mx-1 my-1 h-px bg-border. */
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 300px; max-width: calc(100vw - 16px); border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-lg); overflow: hidden; }
.menu { display: grid; padding: 4px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--foreground);
  font: 400 14px/1.4 var(--font-sans); text-align: left; text-decoration: none; cursor: pointer; outline: none; user-select: none; }
.menu-item:hover, .menu-item:focus { background: var(--accent); color: var(--accent-foreground); }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }
.menu-item .ico { width: 16px; height: 16px; flex: none; color: var(--muted-foreground); }
.menu-item.danger-item, .menu-item.danger-item .ico { color: var(--destructive); }
.menu-text { display: grid; min-width: 0; flex: 1 1 auto; }
.menu-text small { font-size: 12px; line-height: 1.35; color: var(--muted-foreground); }
.menu-end { margin-left: auto; display: inline-flex; align-items: center; color: var(--muted-foreground); }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--border); }
.menu-sep[hidden] { display: none; }

/* ---- Progress ---- */
.progress { position: relative; width: 100%; height: 8px; overflow: hidden; border-radius: 9999px; background: color-mix(in oklab, var(--primary) 20%, transparent); }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width .2s; }
.progress.warn > span { background: var(--destructive); }

/* ---- Alert (a notice inside a page, not a strip) ---- */
.alert { display: grid; gap: 2px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); font-size: 14px; background: var(--card); color: var(--card-foreground); }
.alert > strong { font-weight: 500; letter-spacing: -0.01em; }
.alert > span { color: var(--muted-foreground); }
.alert.destructive { border-color: color-mix(in oklab, var(--destructive) 40%, var(--border)); }
.alert.destructive > strong { color: var(--destructive); }

/* ---- Alert strip (a notice strip under the top bar) ---- */
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; background: var(--muted); border-bottom: 1px solid var(--border); font-size: 14px; }
.banner[hidden] { display: none; }
.notice { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--muted); font-weight: 500; }

/* ---- Toast (Sonner's look) ---- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; max-width: min(92vw, 420px); padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; line-height: 1.4; }
.toast[hidden] { display: none; }
.toast.err { border-color: color-mix(in oklab, var(--destructive) 40%, var(--border)); color: var(--destructive); }

/* ---- Avatar (the fallback look: a muted disc with the first letter) ---- */
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9999px; background: var(--muted); color: var(--foreground); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; line-height: 1; user-select: none; }
.avatar[hidden] { display: none; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
/* Premium: a ring in the colour of the logo's second stop (our one accent) */
.avatar.premium { box-shadow: 0 0 0 2px var(--background), 0 0 0 4px #be185d; }

/* ---- Accordion (<details>) ---- */
.accordion { width: 100%; }
.accordion details { border-bottom: 1px solid var(--border); }
.accordion details:last-child { border-bottom: 0; }
.accordion summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; list-style: none; outline: none; transition: box-shadow .15s; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { text-decoration: underline; }
.accordion summary:focus-visible { box-shadow: var(--focus-ring); }
.accordion summary::after { content: ""; flex: none; width: 16px; height: 16px; margin-top: 2px; background: currentColor; opacity: .6; transition: transform .2s;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; }
.accordion details[open] > summary::after { transform: rotate(180deg); }
.accordion .answer { padding: 0 0 16px; font-size: 14px; }
.accordion .answer > * + * { margin-top: 8px; }

/* ---- Separator ---- */
.separator { flex: none; width: 100%; height: 1px; border: 0; background: var(--border); margin: 0; }

/* ---- small things ---- */
kbd { padding: 1px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--background); color: var(--muted-foreground); font: 500 12px var(--font-sans); }
code { padding: 1px 5px; border-radius: var(--radius-sm); background: var(--muted); font: 500 12px ui-monospace, monospace; }
.fine { font-size: 12.5px; line-height: 1.4; color: var(--muted-foreground); }
.error { color: var(--destructive); font-weight: 500; }

/* ---- dark mode: shadcn's dark variants of the same components ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn, :root:not([data-theme="light"]) .icon-btn { border-color: var(--input); background: color-mix(in oklab, var(--input) 30%, transparent); }
  :root:not([data-theme="light"]) .btn:hover:not(:disabled), :root:not([data-theme="light"]) .icon-btn:hover:not(:disabled) { background: color-mix(in oklab, var(--input) 50%, transparent); color: var(--foreground); }
  :root:not([data-theme="light"]) .btn.primary { background: var(--primary); border-color: transparent; }
  :root:not([data-theme="light"]) .btn.ghost { background: transparent; border-color: transparent; }
  :root:not([data-theme="light"]) .btn.ghost:hover:not(:disabled) { background: color-mix(in oklab, var(--accent) 50%, transparent); }
  :root:not([data-theme="light"]) .btn.danger { background: color-mix(in oklab, var(--destructive) 60%, transparent); }
  /* background-color, not the shorthand: the shorthand would reset the select's chevron (no-repeat, right) and tile it across the field. */
  :root:not([data-theme="light"]) input[type="text"], :root:not([data-theme="light"]) input[type="email"], :root:not([data-theme="light"]) select, :root:not([data-theme="light"]) textarea { background-color: color-mix(in oklab, var(--input) 30%, transparent); }
  :root:not([data-theme="light"]) .switch-track { background: color-mix(in oklab, var(--input) 80%, transparent); }
  :root:not([data-theme="light"]) .switch[aria-checked="false"] .switch-thumb { background: var(--foreground); }
  :root:not([data-theme="light"]) .switch[aria-checked="true"] .switch-track { background: var(--primary); }
  :root:not([data-theme="light"]) .switch[aria-checked="true"] .switch-thumb { background: var(--primary-foreground); }
  :root:not([data-theme="light"]) .tabs [role="tab"][aria-selected="true"] { background: color-mix(in oklab, var(--input) 30%, transparent); border-color: var(--input); }
  :root:not([data-theme="light"]) select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
  :root:not([data-theme="light"]) input[type="range"]::-webkit-slider-thumb { background: #fafafa; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
