/* Broadsheet — design-system tokens and component classes, lifted verbatim
   from the source Claude Design project (_ds/broadsheet.../styles.css). Plain
   CSS, no build step — this is the system's source of truth, not a copy to
   drift from. Layout/app-specific rules for SPI Sticker Studio start below
   the "app layout" divider. */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #0088b0;
  --color-accent-2: #d6006c;
  --color-divider: color-mix(in srgb, #201e1d 16%, transparent);

  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #e9f8ff;
  --color-accent-200: #cbeeff;
  --color-accent-300: #99e0ff;
  --color-accent-400: #62c5ee;
  --color-accent-500: #38a6cf;
  --color-accent-600: #1186ac;
  --color-accent-700: #006786;
  --color-accent-800: #004961;
  --color-accent-900: #0a303e;

  --color-accent-2-100: #fff1f4;
  --color-accent-2-200: #ffdee6;
  --color-accent-2-300: #ffc0d0;
  --color-accent-2-400: #ff90b1;
  --color-accent-2-500: #ff458e;
  --color-accent-2-600: #d82071;
  --color-accent-2-700: #aa0b56;
  --color-accent-2-800: #790e3d;
  --color-accent-2-900: #4b1528;

  --font-heading: "Source Serif 4", system-ui, sans-serif;
  --font-heading-weight: 600;
  --font-body: "Source Serif 4", system-ui, sans-serif;

  --space-1: 5.0px;
  --space-2: 10.0px;
  --space-3: 15.0px;
  --space-4: 20.0px;
  --space-6: 30.0px;
  --space-8: 40.0px;

  --radius-sm: 1px;
  --radius-md: 2px;
  --radius-lg: 4px;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: var(--font-heading-weight); }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.55; font-weight: 400; }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 27px; }
h2 { font-size: 19px; }
h3 { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); background: none; border: 0; }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-block { width: 100%; margin-top: var(--space-2); }

/* — forms — */
.field { margin-bottom: var(--space-3); }
.field > label {
  display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  margin-bottom: 6px; color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input::placeholder { color: color-mix(in srgb, var(--color-text) 65%, transparent); opacity: 1; }
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 220px; resize: vertical; font-size: 13.5px; line-height: 1.55; }

.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius-md); width: 100%; }
.seg-opt { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: var(--color-bg); }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }

/* — tags — */
.tag { display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.02em; padding: 3px 10px; border-radius: calc(var(--radius-md) * 0.75); }
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-accent-2 { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

.elev-sm { box-shadow: var(--shadow-sm); }

/* ══════════════════ app layout — SPI Sticker Studio Create page ══════════════════ */

html, body { margin: 0; padding: 0; height: 100%; overflow-x: hidden; }
#app { height: 100vh; min-width: 1100px; display: flex; flex-direction: column; overflow: hidden; }

.app-header {
  display: flex; align-items: baseline; gap: var(--space-8);
  padding: 14px var(--space-6) 10px; border-bottom: 2px solid var(--color-text);
}
.brand { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.brand-title { font-family: var(--font-heading); font-weight: 700; font-size: 22px; letter-spacing: -.01em; line-height: 1; }
.brand-sub { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--color-neutral-600); }
.header-stats { display: flex; gap: var(--space-6); align-items: center; margin-left: auto; }
.stat { text-align: right; }
.stat-k { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-neutral-600); }
.stat-v { font-family: var(--font-heading); font-size: 17px; }
.provider-pill {
  display: flex; align-items: center; gap: 7px; padding: 5px 10px;
  background: var(--color-accent-100); color: var(--color-accent-800); font-size: 12px;
}
.provider-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent-2-600); display: inline-block; }

.studio-grid { flex: 1; display: grid; grid-template-columns: 330px minmax(0,1fr) 360px; overflow: hidden; }

.panel-aside { overflow-y: auto; padding: var(--space-4); }
.panel-aside-left { border-right: 1px solid var(--color-divider); }
.panel-aside-right { border-left: 1px solid var(--color-divider); display: flex; flex-direction: column; gap: var(--space-6); }
.aside-label { margin: 0 0 var(--space-2); }
.thumb-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }
.thumb-row img { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--color-divider); }

.canvas-main { overflow-y: auto; display: flex; flex-direction: column; padding: var(--space-4) var(--space-6); }
.canvas-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
.canvas-meta { font-size: 12.5px; color: var(--color-neutral-700); }
.canvas-tags { display: flex; gap: 6px; align-items: center; }

.canvas-body { background: #fff; flex: 1; min-height: 430px; display: flex; flex-direction: column; padding: var(--space-4); }

.state-idle { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; }
.state-idle h4 { font-family: var(--font-heading); font-size: 21px; margin: 0; }
.state-idle p { max-width: 38ch; margin: 0; font-size: 14px; line-height: 1.55; color: var(--color-neutral-700); }

.state-working { flex: 1; display: flex; flex-direction: column; gap: var(--space-4); }
.working-head { display: flex; align-items: baseline; justify-content: space-between; }
.working-bar { height: 3px; background: var(--color-neutral-200); }
.working-bar-fill { height: 100%; width: 55%; background: var(--color-accent); }
.working-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); flex: 1; }
.working-tiles div { background: var(--color-neutral-200); animation: spipulse 1.4s ease-in-out infinite; }
.working-tiles div:nth-child(2) { animation-delay: .3s; }
.working-tiles div:nth-child(3) { animation-delay: .6s; }
.working-tiles div:nth-child(4) { animation-delay: .9s; }
@keyframes spipulse { 0%,100% { opacity: .35 } 50% { opacity: .9 } }

.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); flex: 1; align-content: start; }
.tile { border: 1px solid var(--color-divider); background: #fff; display: flex; flex-direction: column; }
.tile img { width: 100%; display: block; background: repeating-conic-gradient(var(--color-neutral-200) 0% 25%, #fff 0% 50%) 0 0/16px 16px; }
.tile .tile-meta { display: flex; align-items: baseline; justify-content: space-between; padding: 7px 9px; font-size: 12px; }
.tile .tile-meta span:last-child { color: var(--color-neutral-600); }
.tile.tile-error { padding: var(--space-3); font-size: 12.5px; color: var(--color-accent-2-700); }

.canvas-actions { display: flex; gap: var(--space-2); align-items: center; padding-top: var(--space-3); flex-wrap: wrap; }
.flex-spacer { flex: 1; }

.trail { display: flex; flex-direction: column; gap: 7px; }
.trail-row { display: flex; gap: 9px; font-size: 12.5px; line-height: 1.4; }
.trail-row .trail-stamp { color: var(--color-neutral-600); min-width: 44px; }
.trail-row .trail-text { flex: 1; }
.trail-row .trail-cost { color: var(--color-neutral-600); }
.trail-empty { font-size: 12.5px; color: var(--color-neutral-700); }
