/* Labelmatico base: design tokens, reset, typography, controls and shared components.
   Loaded on every page. Page-specific styles live in site.css and editor.css. */

@font-face {
  font-family: "Labelmatico UI";
  src: url("fonts/LM-inter.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Labelmatico Display";
  src: url("fonts/LM-bricolagegrotesque.ttf") format("truetype");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  /* Brand */
  --accent: #5641bc;
  --accent-hover: #46329f;
  --accent-active: #3a2a85;
  --accent-soft: #f0edfb;
  --accent-soft-2: #e4defa;
  --accent-ink: #3d2b94;
  --accent-ring: #5641bc59;

  /* Neutrals */
  --bg: #f6f6f9;
  --surface: #fff;
  --surface-2: #f9f9fb;
  --surface-3: #f1f1f5;
  --border: #e4e4eb;
  --border-strong: #d2d2dc;
  --ink: #1e1f27;
  --ink-2: #3f4150;
  --muted: #676a7a;
  --faint: #8c8fa0;

  /* Status */
  --danger: #b4283c;
  --danger-soft: #fdf0f2;
  --danger-border: #f2c9d0;
  --success: #1c7a52;
  --success-soft: #ecf8f2;
  --success-border: #bfe5d1;
  --warning: #8a5a00;
  --warning-soft: #fff7e6;
  --warning-border: #f0d9a8;

  /* Shape & depth */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --shadow-xs: 0 1px 2px #1e1f270d;
  --shadow-sm: 0 1px 2px #1e1f270a, 0 2px 6px #1e1f270a;
  --shadow-md: 0 2px 4px #1e1f270a, 0 8px 24px #1e1f2714;
  --shadow-lg: 0 4px 10px #1e1f270f, 0 24px 60px #1e1f2726;

  /* Type */
  --font-ui: "Labelmatico UI", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Labelmatico Display", var(--font-ui);
  --control-h: 36px;
  --header-h: 64px;
  --page-w: 1120px;
  --gutter: clamp(16px, 4vw, 32px);

  color-scheme: light;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
img, svg, canvas { max-width: 100%; }
img { display: block; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft-2); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 3000;
  padding: 8px 14px; border-radius: var(--radius); background: var(--ink); color: #fff; text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 12px; }

/* ---------- Links ---------- */
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Buttons ----------
   button            neutral (white, bordered)
   .primary          filled brand
   .danger           destructive text / outline
   .button-link      an <a> that looks like a button
   .project-link     an <a> that looks like a neutral button (legacy name, kept for JS) */
button, .button-link, .project-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-2);
  font: 550 13px/1.2 var(--font-ui); text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none;
  box-shadow: var(--shadow-xs);
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
button:hover:not(:disabled), .button-link:hover, .project-link:hover {
  background: var(--surface-3); border-color: var(--border-strong); color: var(--ink);
}
button:active:not(:disabled) { background: var(--border); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.primary, button.primary, .button-link.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px #3a2a8540, inset 0 1px 0 #ffffff1f;
}
.primary:hover:not(:disabled), button.primary:hover:not(:disabled), .button-link.primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover); color: #fff;
}
.primary:active:not(:disabled) { background: var(--accent-active); }

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

.button-lg { min-height: 44px; padding: 0 20px; font-size: 14px; border-radius: 10px; }
.button-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.button-ghost:hover { background: var(--surface-3); border-color: transparent; }

/* Inline text link with an arrow, used for secondary actions */
.text-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--accent); text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.ui-icon, .tool-icon { width: 16px; height: 16px; flex: none; }
.icon-control { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* ---------- Form controls ---------- */
input, select, textarea { font: inherit; color: inherit; min-width: 0; }
input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file]), select, textarea {
  display: block; width: 100%; min-height: var(--control-h); margin-top: 6px; padding: 7px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  font-size: 14px; color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition: border-color .12s, box-shadow .12s;
}
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--surface) url("brand/chevron-down.svg") no-repeat right 10px center / 14px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
:is(input, select, textarea):hover:not(:disabled, :focus) { border-color: #babac8; }
:is(input:not([type=checkbox], [type=radio], [type=range], [type=color]), select, textarea):focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
input[type=range] { accent-color: var(--accent); }
input[type=color] {
  width: 44px; height: 32px; padding: 3px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }

label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 550; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-weight: 500; cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 0; }
.hint { font-size: 13px; line-height: 1.55; color: var(--muted); margin: 8px 0 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }

/* Segmented tabs (data mode) */
.tabs {
  display: flex; gap: 2px; padding: 3px; margin-bottom: 18px;
  border-radius: 10px; background: var(--surface-3);
}
.tabs button {
  flex: 1; min-height: 32px; padding: 0 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); box-shadow: none; font-size: 13px;
}
.tabs button:hover:not(:disabled) { background: #ffffff99; color: var(--ink); }
.tabs button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }

.eyebrow {
  display: inline-block; margin-bottom: 12px; font-size: 12px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent);
}

/* ---------- Site header ---------- */
.app-header {
  position: relative; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  min-height: var(--header-h); padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(10px);
}
.site-header { position: sticky; top: 0; }
.brand { display: flex; align-items: center; flex: none; border-radius: var(--radius-sm); }
.brand img { width: auto; height: 28px; }
.app-header nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.site-header nav > a {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px;
  border-radius: var(--radius); color: var(--ink-2); font-size: 13px; font-weight: 550; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.site-header nav > a:hover { background: var(--surface-3); color: var(--ink); }
.site-header nav > a[aria-current=page] { background: var(--accent-soft); color: var(--accent-ink); }
.site-header nav > a.primary { margin-left: 6px; background: var(--accent); color: #fff; box-shadow: 0 1px 2px #3a2a8540; }
.site-header nav > a.primary:hover { background: var(--accent-hover); color: #fff; }
.site-header nav .ui-icon { width: 16px; height: 16px; }

@media (max-width: 640px) {
  :root { --header-h: 56px; }
  .brand img { height: 24px; }
  .app-header { gap: 8px; }
  .site-header nav { gap: 2px; }
  .site-header nav > a:not(.primary) { padding: 0 10px; }
  .site-header nav > a:not(.primary) .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .site-header nav > a.primary { margin-left: 4px; padding: 0 12px; }
}
@media (max-width: 440px) {
  .app-header { padding: 0 12px; }
  .brand img { height: 22px; }
  .site-header nav > a:not(.primary) { padding: 0 9px; }
  .nav-label-long { display: none; }
}

/* ---------- Site footer ---------- */
.page-footer {
  margin-top: auto; padding: 32px var(--gutter) 40px;
  border-top: 1px solid var(--border); background: var(--surface);
}
.footer-inner {
  max-width: var(--page-w); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px 32px;
}
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.footer-brand img { width: 22px; height: 22px; border-radius: 5px; }
.page-footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.page-footer nav a { color: var(--muted); font-size: 13px; text-decoration: none; padding: 4px 0; }
.page-footer nav a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Dialogs ---------- */
dialog {
  max-width: calc(100vw - 24px); max-height: 90dvh; padding: 24px; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: #16141f73; backdrop-filter: blur(2px); }
dialog[open] { animation: dialog-in .16s ease-out; }
dialog h2 { font-size: 18px; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }

/* ---------- Toast notices (notifications.js) ---------- */
.action-notice {
  position: fixed; top: calc(var(--header-h) + 14px); right: max(16px, calc(50% - 220px)); z-index: 2500;
  width: min(440px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px;
  border: 1px solid var(--danger-border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-lg); color: var(--ink);
  animation: notice-in .18s ease-out;
}
.notice-symbol { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px; background: var(--danger-soft); color: var(--danger); }
.notice-symbol svg { width: 18px; height: 18px; }
.notice-content { flex: 1; min-width: 0; }
.notice-content > strong { display: block; margin: 2px 0 4px; font-size: 14px; }
.notice-content > p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.notice-close { width: 28px; min-height: 28px; height: 28px; padding: 0; flex: none; border: 0; background: transparent; box-shadow: none; color: var(--faint); }
.notice-close:hover:not(:disabled) { background: var(--surface-3); }
.notice-link { margin-top: 10px; min-height: 30px; font-size: 12px; }
.action-notice[data-kind=info] { border-color: var(--success-border); }
.action-notice[data-kind=info] .notice-symbol { background: var(--success-soft); color: var(--success); }
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Project library (shared by /projects and the editor's Projects dialog) ---------- */
.cloud-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.cloud-heading h2 { margin: 0; font-size: 20px; }
#cloud-status { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
#cloud-status:empty { display: none; }
#cloud-status[data-error=true] { padding: 10px 14px; border: 1px solid var(--danger-border); border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); }

#cloud-name {
  max-width: 420px; margin: 0 auto; padding: 28px;
  border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-sm);
}
#cloud-name button[type=submit] { width: 100%; margin-top: 4px; min-height: 40px; }
#cloud-name form { display: grid; }
#cloud-name #project-name-cancel { margin-top: 8px; }

.library-overview {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 12px 14px 12px 12px; margin-bottom: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs);
}
.library-toolbar { display: contents; }
.library-identity { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 320px; }
.library-identity > div { min-width: 0; }
.library-identity strong { font-size: 14px; font-weight: 650; }
.library-icon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #7d68e0, var(--accent)); color: #fff;
}
.library-icon .ui-icon { width: 20px; height: 20px; }
.library-note { margin: 1px 0 0; max-width: 70ch; font-size: 13px; color: var(--muted); }
.library-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.library-actions svg { width: 16px; height: 16px; }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.library-heading h3 { margin: 0; font-size: 16px; }
.project-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.project-filters label { margin: 0; flex: 0 1 200px; font-size: 12px; }
.project-filters label:first-child { flex: 1 1 240px; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; margin-bottom: 20px; }
.project-grid[aria-busy=true] { opacity: .6; }
.project-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.project-card .project-open {
  display: block; width: 100%; min-height: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none;
  background: var(--surface-3);
}
.project-card .project-open:hover:not(:disabled) { background: var(--surface-3); }
.project-card .project-open:focus-visible { outline-offset: -3px; }
.project-card img {
  width: 100%; height: 170px; padding: 22px; object-fit: contain;
  background: radial-gradient(circle, #d6d6e0 1px, transparent 1.3px) 0 0 / 14px 14px, var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.project-card img { filter: drop-shadow(0 6px 10px #1e1f2720); }
.project-card h3 { margin: 14px 16px 2px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card p { margin: 0 16px 14px; font-size: 12px; color: var(--muted); }
/* Cards are narrow, so the four actions sit in a 2 × 2 grid: Open and Rename, then Duplicate and Delete. */
.project-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: auto; border-top: 1px solid var(--border); }
.project-actions button {
  min-width: 0; min-height: 38px; padding: 0 8px; border: 0; border-radius: 0; box-shadow: none; background: transparent;
  font-size: 12px; color: var(--muted); gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-actions button:nth-child(even) { border-left: 1px solid var(--border); }
.project-actions button:nth-child(n+3) { border-top: 1px solid var(--border); }
.project-actions button:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.project-actions button:first-child { color: var(--accent); font-weight: 650; }
.project-actions button:last-child:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.project-actions .ui-icon { width: 14px; height: 14px; }

.project-empty {
  display: block; text-align: center; padding: 48px 24px; margin: 0 0 20px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-xl); background: var(--surface);
  color: var(--muted);
}
.empty-design-icon {
  display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 24px;
}
.empty-design-icon .ui-icon { width: 26px; height: 26px; }
.project-empty:not([hidden]) ~ .project-pagination { display: none; }
.project-empty h3 { margin: 0 0 6px; font-size: 18px; }
.project-empty p { margin: 0 auto 20px; max-width: 42ch; font-size: 14px; }
.project-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 13px; color: var(--muted); }
.project-pagination button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.project-pagination:has(#projects-prev:disabled):has(#projects-next:disabled) button { display: none; }

@media (max-width: 560px) {
  .library-overview { align-items: flex-start; }
  .library-actions { width: 100%; }
  .library-actions > * { flex: 1; }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .project-card img { height: 120px; padding: 12px; }
  .project-card h3 { margin: 10px 12px 2px; font-size: 13px; }
  .project-card p { margin: 0 12px 10px; font-size: 11px; }
  .project-actions button { padding: 0 4px; gap: 4px; }
  .project-card:hover { transform: none; }
}
/* The smallest phones: one project per row, so the buttons have room. */
@media (max-width: 360px) {
  .project-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  :is(input:not([type=checkbox], [type=radio], [type=range], [type=color]), select, textarea) { font-size: 16px; }
}

@media print {
  .site-header, .page-footer, .skip-link { display: none; }
  body { background: #fff; }
}

/* ---------- Early days notice ---------- */
.beta-banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #fff6dc; border-bottom: 1px solid #f1dc9c; color: #5c4508; font-size: 13.5px; line-height: 1.45; }
.beta-banner[hidden] { display: none; }
.beta-banner p { flex: 1; margin: 0; text-align: center; }
.beta-banner a { color: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.beta-banner-icon { flex: none; width: 18px; height: 18px; color: #a87a00; }
.beta-banner-close { flex: none; display: inline-grid; place-items: center; width: 30px; min-height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: inherit; }
.beta-banner-close:hover:not(:disabled) { background: #f6e6b4; }
.beta-banner-close svg { width: 16px; height: 16px; }
@media (max-width: 600px) { .beta-banner { font-size: 12.5px; padding: 6px 10px; align-items: flex-start; } .beta-banner p { text-align: left; } .beta-banner-icon { margin-top: 2px; } }
