/* Jewel Studio. Light, warm neutrals, one garnet accent. No coloured edge
   strokes anywhere: selection is a tinted fill or a neutral ring. */

:root {
  --paper: oklch(0.975 0.006 75);
  --surface: oklch(0.993 0.003 75);
  --panel: oklch(0.955 0.008 70);
  --panel-2: oklch(0.935 0.009 70);
  --stage: oklch(0.92 0.007 70);
  --ink: oklch(0.25 0.012 40);
  --ink-2: oklch(0.46 0.012 45);
  --ink-3: oklch(0.62 0.01 50);
  --line: oklch(0.885 0.008 60);
  --accent: oklch(0.44 0.13 18);
  --accent-hover: oklch(0.39 0.125 18);
  --accent-ink: oklch(0.985 0.006 75);
  --accent-soft: oklch(0.935 0.03 18);
  --danger: oklch(0.5 0.16 28);
  --danger-soft: oklch(0.95 0.025 28);
  --focus: oklch(0.55 0.12 250);
  --r: 12px;
  --r-s: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15.5px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
#app { min-height: 100%; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: 0.45; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; line-height: 1.4; }
.spacer { flex: 1; }

/* ---------- icons, buttons ---------- */
.icon { display: inline-grid; width: 22px; height: 22px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--ink); flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--panel); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  background: var(--panel); color: var(--ink); font-weight: 560; white-space: nowrap;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn .icon { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.quiet { background: transparent; color: var(--ink-2); }
.btn.quiet:hover:not(:disabled) { background: var(--panel); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.big { height: 52px; padding: 0 22px; font-size: 16.5px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.groups { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
.chips.groups::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--panel); color: var(--ink-2); font-size: 14px; font-weight: 520; white-space: nowrap;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.chip .icon { width: 17px; height: 17px; }
.chip:hover { background: var(--panel-2); }
.chip[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 640; }
.chips.compact .chip { height: 30px; padding: 0 10px; font-size: 13px; }

/* ---------- sliders ---------- */
.slider { display: grid; gap: 2px; min-width: 0; }
.slider-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.slider-label output { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.slider input[type="range"] { width: 100%; margin: 0; height: 30px; accent-color: var(--accent); background: transparent; touch-action: pan-y; }

/* ---------- home ---------- */
.home { max-width: 980px; margin: 0 auto; padding: calc(var(--safe-t) + 8px) 16px calc(var(--safe-b) + 40px); }
.home-bar { height: 56px; display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 600 19px/1 var(--serif); letter-spacing: 0.01em; }
.brand .icon { color: var(--accent); width: 24px; height: 24px; }
.start { padding: 28px 0 32px; display: grid; gap: 12px; max-width: 620px; }
.start h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.015em; font-weight: 680; }
.start > .muted { font-size: 16.5px; max-width: 56ch; }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.section-title { font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 12px; }
.recent { padding: 8px 0 28px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px 12px; }
.tile { display: grid; gap: 6px; min-width: 0; }
.tile-img { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--stage); display: grid; place-items: center; }
.tile-img img { width: 100%; height: 100%; object-fit: contain; }
.tile:hover .tile-img img { transform: scale(1.015); }
.tile-img img { transition: transform 240ms var(--ease); }
.tile-empty { color: var(--ink-3); display: grid; place-items: center; }
.tile-count { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; border-radius: 999px; background: oklch(0.99 0.004 75 / 0.88); font-size: 12.5px; font-weight: 600; }
.tile-name { font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tips { padding: 8px 0 0; max-width: 680px; }
.tips ol { margin: 0; padding: 0 0 0 20px; display: grid; gap: 8px; color: var(--ink-2); }
.tips li::marker { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tips strong { color: var(--ink); font-weight: 620; }
.note { display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: var(--r); padding: 10px 6px 10px 14px; margin: 0 0 24px; font-size: 14px; }
.note p { flex: 1; }
.desk-only { display: none; }
@media (hover: hover) and (pointer: fine) { .desk-only { display: inline; } .touch-only { display: none; } }

.batch .bar { margin: 0 -16px 0; }
.batch-head { padding: 18px 0 16px; display: grid; gap: 6px; max-width: 640px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--ink-2); animation: spin 0.9s linear infinite; }
.spinner.small { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; overflow: hidden; background: var(--paper); }
.bar {
  display: flex; align-items: center; gap: 4px;
  min-height: calc(54px + var(--safe-t)); padding: var(--safe-t) 10px 0 6px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar-title { flex: 1; min-width: 0; font-size: 16.5px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.bar .btn { margin-left: 4px; }
.stage { position: relative; display: grid; place-items: center; background: var(--stage); overflow: hidden; min-height: 0; touch-action: none; }
.stage-canvas { display: block; touch-action: none; border-radius: 4px; box-shadow: 0 1px 2px oklch(0.3 0.02 50 / 0.12), 0 8px 30px oklch(0.3 0.02 50 / 0.10); cursor: grab; }
.stage-canvas:active { cursor: grabbing; }
.submode .stage-canvas { box-shadow: none; border-radius: 0; cursor: crosshair; }
.stage-status { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 24px; text-align: center; background: var(--stage); }
.stage-status p { max-width: 34ch; }
.stage-status .row { display: flex; gap: 8px; margin-top: 6px; }

.tools { background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); min-width: 0; }
.panel { min-height: 150px; padding: 12px 14px 10px; display: grid; gap: 12px; align-content: start; }
.panel-note { font-size: 13.5px; }
.panel-callout { font-size: 14px; padding: 10px 12px; border-radius: var(--r-s); background: var(--accent-soft); color: var(--ink); }
.panel-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-row.tight { gap: 10px; }
.panel-row.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.panel-row.sliders.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.tool { display: inline-grid; justify-items: center; gap: 4px; min-width: 76px; padding: 10px 8px 8px; border-radius: var(--r); background: var(--panel); font-size: 12.5px; font-weight: 540; color: var(--ink); }
.tool:hover:not(:disabled) { background: var(--panel-2); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tabs { display: grid; grid-template-columns: repeat(6, 1fr); padding: 2px 4px 4px; }
.tab { display: grid; justify-items: center; gap: 2px; padding: 6px 0 8px; font-size: 11.5px; font-weight: 540; color: var(--ink-2); }
.tab .icon { width: 40px; height: 28px; padding: 3px 9px; border-radius: 999px; transition: background-color 160ms var(--ease); }
.tab[aria-pressed="true"] { color: var(--accent); font-weight: 650; }
.tab[aria-pressed="true"] .icon { background: var(--accent-soft); }
.submode .tabs { display: none; }

.strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; margin: 0 -14px; padding: 2px 14px 4px; scrollbar-width: thin; }
.swatch { flex: 0 0 74px; display: grid; gap: 5px; justify-items: center; font-size: 12px; color: var(--ink-2); scroll-snap-align: start; text-align: center; }
.swatch > span:last-child { width: 100%; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.swatch img, .swatch .sw { width: 70px; height: 70px; border-radius: 10px; object-fit: cover; display: block; background: var(--panel); box-shadow: inset 0 0 0 1px oklch(0.3 0.02 50 / 0.08); }
.swatch[aria-selected="true"] img, .swatch[aria-selected="true"] .sw { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch[aria-selected="true"] { color: var(--ink); font-weight: 640; }
.swatch .sw[data-clear] { background: repeating-conic-gradient(#e7e3dd 0 25%, #f6f4f1 0 50%) 0 0 / 14px 14px; }
.swatch.add { justify-content: center; }
.swatch.add .icon { width: 70px; height: 70px; padding: 22px; border-radius: 10px; background: var(--panel); color: var(--ink-2); }
.strip-note { flex: 0 0 200px; align-self: center; }
.color-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.color-pick input { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: none; overflow: hidden; }
.color-pick input::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick input::-webkit-color-swatch { border: 0; border-radius: 50%; }

.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.size { display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: var(--r); background: var(--panel); }
.size-shape { grid-row: 1 / 3; width: 22px; max-height: 30px; justify-self: center; border-radius: 3px; background: var(--ink-3); }
.size-name { font-size: 14px; font-weight: 600; }
.size[aria-checked="true"] { background: var(--accent-soft); }
.size[aria-checked="true"] .size-shape { background: var(--accent); }
.size[aria-checked="true"] .size-name { color: var(--accent); }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: oklch(0.2 0.01 40 / 0); display: grid; align-items: end; transition: background-color 200ms var(--ease); }
.sheet-wrap.open { background: oklch(0.2 0.01 40 / 0.32); }
.sheet { background: var(--surface); border-radius: 18px 18px 0 0; padding: 6px 16px calc(18px + var(--safe-b)); max-height: 92dvh; overflow: auto; transform: translateY(100%); transition: transform 240ms var(--ease); }
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 10px; }
.sheet-head h2 { font-size: 18px; font-weight: 650; }
.save-body { display: grid; gap: 16px; }
.save-preview { display: grid; place-items: center; background: var(--stage); border-radius: var(--r); padding: 12px; }
.save-preview canvas { max-width: 100%; max-height: 38dvh; width: auto; height: auto; border-radius: 3px; box-shadow: 0 4px 18px oklch(0.3 0.02 50 / 0.12); }
.save-opts { display: grid; gap: 10px; align-content: start; }
.save-opts input[type="text"], .field input { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; width: 100%; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-top: 4px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.more-body { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }

/* ---------- toast, veils ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 40; max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--accent-ink); font-size: 14.5px; transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: oklch(0.36 0.09 25); }
.editor ~ .toast, body:has(.editor) .toast { bottom: calc(230px + var(--safe-b)); }
.busy-veil { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 12px; background: oklch(0.975 0.006 75 / 0.86); }
.drop-hint { position: fixed; inset: 12px; z-index: 50; display: none; place-items: center; border-radius: 20px; background: oklch(0.975 0.006 75 / 0.92); box-shadow: inset 0 0 0 2px var(--ink-3); font-size: 20px; font-weight: 600; pointer-events: none; }
body.dropping .drop-hint { display: grid; }

/* ---------- wider screens ---------- */
@media (min-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1fr) 384px; grid-template-rows: auto minmax(0, 1fr); }
  .bar { grid-column: 1 / -1; }
  .tools { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; border-top: 0; border-left: 1px solid var(--line); overflow: auto; }
  .tabs { order: -1; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 12px 12px 4px; }
  .tab { grid-auto-flow: column; justify-content: center; gap: 6px; padding: 8px 6px; border-radius: 10px; font-size: 13.5px; }
  .tab .icon { width: 20px; height: 20px; padding: 0; background: none !important; }
  .tab[aria-pressed="true"] { background: var(--accent-soft); }
  .panel { padding: 14px 16px; }
  .panel-row.sliders { grid-template-columns: 1fr; }
  .strip { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .chips.groups { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .sizes { grid-template-columns: 1fr; }
  body:has(.editor) .toast { bottom: 28px; left: calc(50% - 192px); }
  .sheet-wrap { align-items: center; justify-items: center; }
  .sheet { width: min(760px, 94vw); border-radius: 18px; transform: translateY(16px); opacity: 0; transition: transform 220ms var(--ease), opacity 220ms var(--ease); }
  .sheet-wrap.open .sheet { opacity: 1; }
  .save-body { grid-template-columns: 1.15fr 1fr; align-items: start; }
  .save-preview canvas { max-height: 60vh; }
  .start { padding: 44px 0 40px; }
  .start h1 { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
}
