:root {
  --onespot: #5B59D6;
  --onespot-dark: #4745C7;
  --paua: #1C1A5F;
  --rose: #B66393;
  --lavander: #B96FD6;
  --soft-lavander: #E3E3F8;
  --success: #1CA660;
  --error: #B91C1C;
  --error-accent: #E53E3E;

  --bg: #F4F4FC;
  --panel: #FFFFFF;
  --line: #E3E3F8;
  --text: #1C1A5F;
  --muted: rgba(28, 26, 95, 0.62);
  --accent: #5B59D6;
  --accent-dark: #4745C7;
  --raise: #F7F7FD;
  --heading: 'League Spartan', 'Montserrat', system-ui, sans-serif;
  --shot-h: clamp(18rem, calc(100vh - 16.5rem), 44rem);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body, button, input, textarea, select {
  -webkit-font-smoothing: antialiased;
}

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 'Montserrat', system-ui, sans-serif;
  min-height: 100vh;
}

.section { padding: 6rem 7%; }

button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: 0.0625rem solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999rem;
  padding: 0.55rem 1.2%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { border-color: #C7C7F1; color: var(--onespot-dark); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.ghost { background: transparent; }
.full { width: 100%; margin-top: 0.6rem; padding: 0.55rem 0; }

.layout {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) 1fr;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border-right: 0.0625rem solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 1.1rem 5% 1rem 7%;
  border-bottom: 0.0625rem solid var(--line);
}
.panel-head h1 { font-family: var(--heading); font-size: 1.35rem; font-weight: 700; line-height: 1.05; margin: 0.15rem 0 0; color: var(--paua); letter-spacing: -0.01em; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.beta {
  display: inline-flex; align-items: center;
  height: 1.375rem; padding: 0 0.5rem;
  border-radius: 999rem;
  background: var(--soft-lavander); color: var(--onespot-dark);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1;
  flex-shrink: 0; cursor: default;
}

.moka { height: 2.1rem; width: auto; flex-shrink: 0; overflow: visible; }
.moka .moka-metal { fill: var(--onespot); }
.moka .moka-metal-dark { fill: var(--onespot-dark); }
.moka .moka-shine { fill: none; stroke: var(--soft-lavander); stroke-width: 1.3; stroke-linecap: round; opacity: 0.9; }
.moka .moka-handle { fill: none; stroke: var(--paua); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.moka .moka-cup-body { fill: var(--soft-lavander); stroke: var(--paua); stroke-width: 1.3; stroke-linejoin: round; }
.moka .moka-cup-handle { fill: none; stroke: var(--paua); stroke-width: 1.3; stroke-linecap: round; }
.moka .moka-fill { fill: var(--rose); }
.moka .moka-stream { fill: none; stroke: var(--rose); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 26; stroke-dashoffset: 26; }
.moka .moka-steam path { fill: none; stroke: var(--lavander); stroke-width: 1.1; stroke-linecap: round; }
.moka .moka-flash-rays { fill: none; stroke: var(--onespot); stroke-width: 1.4; stroke-linecap: round; }
.moka-flash { opacity: 0; transform-box: view-box; transform-origin: 51px 40px; pointer-events: none; }

.moka-pot { transform-box: view-box; transform-origin: 24px 40px; }
.moka-fill { transform-box: view-box; transform-origin: 51px 46px; }
.moka-steam { opacity: 0; }
.moka .moka-cup-body { fill-opacity: 0; }

.moka.play .moka-pot { animation: moka-tilt 5s ease-in-out both; }
.moka.play .moka-stream { animation: moka-pour 5s linear both; }
.moka.play .moka-fill { animation: moka-fill 5s ease-in-out both; }
.moka.play .moka-steam { animation: moka-steam 5s ease-out both; }
.moka.play .moka-flash { animation: moka-flash 5s ease-out both; }

@keyframes moka-tilt {
  0%, 12% { transform: rotate(0deg); }
  28%, 68% { transform: rotate(32deg); }
  84%, 100% { transform: rotate(0deg); }
}
@keyframes moka-pour {
  0%, 27% { stroke-dashoffset: 26; opacity: 1; }
  36%, 66% { stroke-dashoffset: 0; opacity: 1; }
  76% { stroke-dashoffset: -26; opacity: 1; }
  77%, 100% { stroke-dashoffset: 26; opacity: 0; }
}
@keyframes moka-fill {
  0%, 32% { transform: scaleY(0); }
  72%, 100% { transform: scaleY(1); }
}
@keyframes moka-steam {
  0%, 62% { opacity: 0; transform: translateY(0.125rem); }
  78% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-0.3rem); }
}

@keyframes moka-flash {
  0%, 77% { opacity: 0; transform: scale(0.4); }
  79% { opacity: 1; transform: scale(1.1); }
  82% { opacity: 0.85; transform: scale(1.2); }
  90%, 100% { opacity: 0; transform: scale(1.45); }
}
@media (prefers-reduced-motion: reduce) {
  .moka.play .moka-pot, .moka.play .moka-stream, .moka.play .moka-fill, .moka.play .moka-steam, .moka.play .moka-flash { animation: none; }
}
.panel-body {
  flex: 1; overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 1.5rem 7%;
  display: flex; flex-direction: column; gap: 1.75rem;
}
.panel-foot {
  display: grid; grid-template-columns: 1fr 1.6fr; gap: 0.5rem;
  padding: 1rem 7% 1.1rem;
  border-top: 0.0625rem solid var(--line);
  background: var(--panel);
}
.panel-foot button { padding: 0.7rem 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.pair button { padding: 0.55rem 0; }
.status:empty { display: none; }
.status { margin: 0.6rem 0 0; color: var(--success); font-weight: 500; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history { display: flex; gap: 0.25rem; flex-shrink: 0; }
button.icon { width: 2.25rem; height: 2.25rem; padding: 0; background: transparent; border-color: transparent; }
button.icon:hover:not(:disabled) { background: var(--raise); border-color: var(--line); }
button.icon svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button.icon:disabled { opacity: 0.3; }

.group-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 0.75rem; }
.group .group-head h2 { margin: 0; }
.group h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.2;
  color: var(--lavander);
  margin: 0 0 0.75rem;
}

.hint { color: var(--muted); font-size: 0.875rem; margin: -0.3rem 0 0.6rem; }
.hint.below { margin: 0.5rem 0 0; }

.howto { margin: 0.75rem 0 0; border: 0.0625rem solid var(--line); border-radius: 0.75rem; background: var(--raise); }
.howto summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  height: 2.5rem; padding: 0 5%;
  font-size: 0.875rem; font-weight: 600; color: var(--muted);
  cursor: pointer; list-style: none; border-radius: 0.75rem;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after {
  content: ''; width: 0.5rem; height: 0.5rem; flex-shrink: 0;
  border-right: 0.125rem solid currentColor; border-bottom: 0.125rem solid currentColor;
  transform: translateY(-0.125rem) rotate(45deg); transition: transform 0.2s ease-out;
}
.howto[open] summary::after { transform: translateY(0.125rem) rotate(-135deg); }
.howto summary:hover { color: var(--onespot-dark); }
.howto summary:focus-visible { outline: 0.125rem solid var(--onespot); outline-offset: 0.125rem; }
.howto ul { margin: 0; padding: 0 5% 0.75rem 11%; display: flex; flex-direction: column; gap: 0.5rem; }
.howto li { font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.howto li::marker { color: var(--lavander); }
.howto li strong { color: var(--paua); font-weight: 600; }
.howto code { font-size: 0.8125rem; }
code { background: var(--raise); border: 0.0625rem solid var(--line); border-radius: 0.25rem; padding: 0 1%; }

textarea, input[type=text] {
  width: 100%;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--raise);
  border: 0.0625rem solid var(--line);
  border-radius: 0.6rem;
  padding: 0.6rem 4%;
}
textarea { resize: vertical; line-height: 1.6; }
textarea:focus, input[type=text]:focus { outline: none; border-color: var(--accent); background: #fff; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 0.75rem; }
.row label { font-size: 1rem; white-space: nowrap; }
.row output { color: var(--muted); margin-left: 2%; }
.hex { position: relative; display: inline-flex; align-items: center; width: 8.25rem; flex-shrink: 0; }
.hex .swatch {
  position: absolute; left: 5%; top: 50%;
  width: 1.5rem; height: 1.5rem; margin-top: -0.75rem;
  padding: 0; border: 0.0625rem solid rgba(0, 0, 0, 0.15); border-radius: 0.35rem;
  cursor: pointer;
}
.hex .swatch:hover { border-color: rgba(0, 0, 0, 0.35); }
.hex input {
  width: 100%; height: 2.25rem;
  padding: 0 4% 0 30%;
  font: inherit; font-size: 1rem; letter-spacing: 0.04em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--text); background: var(--raise);
  border: 0.0625rem solid var(--line); border-radius: 0.5rem;
}
.hex input:focus { outline: none; border-color: var(--accent); background: #fff; }
.hex input.invalid { border-color: var(--error-accent); background: #FFF5F5; }
input[type=range] { width: 7.5rem; accent-color: var(--accent); }

.check { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 1rem; margin: 0 0 0.55rem; cursor: pointer; }
.check input { accent-color: var(--accent); margin-top: 0.2rem; }
.check em { display: block; font-style: normal; color: var(--muted); font-size: 0.875rem; }

.stage { min-width: 0; display: flex; flex-direction: column; }
.section.stage { padding: 2.5rem 4% 2rem; }
.stage-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.4rem 1.2%; margin-bottom: 1.5rem; }
.stage-head h2 { font-family: var(--heading); font-size: 1.4rem; font-weight: 700; line-height: 1.1; margin: 0; color: var(--paua); letter-spacing: -0.01em; }
.stage-head .count { color: var(--muted); font-size: 0.875rem; }
.stage-head .tip { color: var(--muted); font-size: 0.875rem; margin-left: auto; }

.strip { display: flex; align-items: flex-start; gap: 1.25rem; overflow-x: auto; overflow-y: hidden; padding: 0.5rem 4.35% 1.25rem 0.5%; margin: 0 -4.35% 0 -0.5%; }
.slides { display: flex; gap: 1.25rem; width: max-content; }

.card { margin: 0; display: flex; flex-direction: column; position: relative; flex-shrink: 0; }
.shots { display: flex; gap: 1.25rem; cursor: grab; border-radius: 0.6rem; }
.shots img { height: var(--shot-h); width: auto; display: block; border-radius: 0.6rem; box-shadow: 0 0.6rem 1.5rem rgba(28, 26, 95, 0.12); }
.card .headline { display: block; width: 0; min-width: 100%; margin-top: 0.75rem; padding: 0.5rem 4%; font-size: 1rem; line-height: 1.45; resize: none; overflow: hidden; }
.meta { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.4rem; font-size: 0.875rem; color: var(--muted); width: 0; min-width: 100%; }
.meta .file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-tools { position: absolute; top: 0.6rem; right: 4%; display: flex; gap: 0.3rem; }
.card-tools button[data-act="replace"] { opacity: 0; transition: opacity 0.15s; }
.card:hover .card-tools button[data-act="replace"] { opacity: 1; }
.card-tools button[data-act="remove"]:hover { background: var(--error-accent); border-color: var(--error-accent); color: #fff; }
.card-tools button { padding: 0.35rem 0.85rem; font-size: 1rem; background: rgba(255, 255, 255, 0.94); box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.12); }
.card-tools button[data-act="remove"] { width: 2.2rem; padding: 0.35rem 0; }

.card.file-over .shots { outline: 0.2rem solid var(--accent); outline-offset: 0.2rem; }
.sort-ghost { opacity: 0.35; }
.sort-ghost .shots img { box-shadow: none; }
.sort-drag { opacity: 1 !important; }
.sort-drag { z-index: 100; }
.sort-drag .shots { cursor: grabbing; transform: rotate(1.5deg); box-shadow: 0 1.5rem 3rem rgba(28, 26, 95, 0.25); }
.sort-drag .card-tools, .sort-drag .headline, .sort-drag .meta { display: none; }

.templates { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.tpl { flex-direction: column; gap: 0.4rem; padding: 0.45rem 3% 0.5rem; border-radius: 0.75rem; font-size: 0.72rem; }
.tpl-shots { display: flex; gap: 0.15rem; }
.tpl-shots canvas { height: 7.5rem; width: auto; border-radius: 0.3rem; display: block; }

.mirrors { display: flex; flex-direction: column; }
.device-row { margin-top: 2.5rem; padding-top: 2rem; border-top: 0.0625rem solid var(--line); }
.mirror-card { margin: 0; flex-shrink: 0; }
.mirror-card .shots { cursor: default; }
.mirror-card .meta { width: 0; min-width: 100%; }
.mirror-card { position: relative; display: flex; flex-direction: column; }
.own-shots .mirror-card .shots { cursor: pointer; }
.mirror-card .card-tools button[data-act="device-replace"] { opacity: 0; transition: opacity 0.15s; }
.mirror-card:hover .card-tools button[data-act="device-replace"] { opacity: 1; }
.mirror-card.file-over .shots, .device-row.file-over .mirror-strip { outline: 0.2rem solid var(--accent); outline-offset: 0.2rem; border-radius: 0.6rem; }
.row-add { margin-left: auto; padding: 0.45rem 1.2%; font-size: 1rem; }

.add-tile {
  flex-shrink: 0;
  height: var(--shot-h);
  aspect-ratio: 1320 / 2868;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0 1%;
  border: 0.125rem dashed #C7C7F1;
  border-radius: 0.6rem;
  color: var(--muted);
  text-align: center;
}
.add-tile .add-plus { font-size: 2.25rem; line-height: 1; font-weight: 400; color: var(--lavander); }
.add-tile strong { font-size: 1rem; color: var(--text); margin-bottom: 0.4rem; }
.add-tile button { width: 80%; flex-direction: column; gap: 0; padding: 0.55rem 0; font-size: 1rem; }
.add-tile button em { font-style: normal; font-weight: 400; font-size: 0.875rem; color: var(--muted); }
.add-tile button:hover { border-color: var(--accent); color: var(--accent-dark); }

.toast {
  position: fixed; left: 50%; bottom: 1.75rem; z-index: 70;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 1rem;
  padding: 0.5rem 0.5% 0.5rem 1.6%;
  background: var(--paua); white-space: nowrap; color: #fff;
  border-radius: 999rem;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.25);
  font-size: 1rem;
}
.toast span { white-space: nowrap; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; }
.toast button[hidden] { display: none; }
.toast button { background: transparent; border-color: rgba(255, 255, 255, 0.3); color: #fff; width: 4.75rem; padding: 0.4rem 0; flex-shrink: 0; }
.toast button:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.5); }

.picker {
  position: fixed; z-index: 60;
  width: 15rem;
  padding: 0.75rem 0.85%;
  background: #fff;
  border: 0.0625rem solid var(--line);
  border-radius: 0.9rem;
  box-shadow: 0 1rem 2.5rem rgba(28, 26, 95, 0.18);
  display: flex; flex-direction: column; gap: 0.75rem;
}
.picker[hidden] { display: none !important; }
.pk-sv {
  position: relative; height: 9.5rem; border-radius: 0.6rem; cursor: crosshair; touch-action: none;
  background-image: linear-gradient(to top, #000, rgba(0, 0, 0, 0)), linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}
.pk-sv-thumb, .pk-hue-thumb {
  position: absolute; width: 1.1rem; height: 1.1rem; margin: -0.55rem 0 0 -0.55rem;
  border: 0.15rem solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 0.0625rem rgba(0, 0, 0, 0.25), 0 0.125rem 0.375rem rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.pk-hue {
  position: relative; height: 0.8rem; border-radius: 999rem; cursor: pointer; touch-action: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.pk-hue-thumb { top: 50%; }
.pk-hex {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.875rem; font-weight: 600; color: var(--muted); letter-spacing: 0.08em;
}
.pk-hex b { color: var(--muted); font-weight: 500; margin-left: auto; }
.pk-hex input {
  width: 7rem; height: 2.1rem; padding: 0 5%;
  font: inherit; font-size: 1rem; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text);
  background: var(--raise); border: 0.0625rem solid var(--line); border-radius: 0.5rem;
}
.pk-hex input:focus { outline: none; border-color: var(--accent); background: #fff; }
.pk-hex input.invalid { border-color: var(--error-accent); background: #FFF5F5; }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(91, 89, 214, 0.14);
  border: 0.25rem dashed var(--accent);
  pointer-events: none;
}
.drop-overlay span { background: var(--accent); color: #fff; font-weight: 600; padding: 0.9rem 3%; border-radius: 999rem; }
body.dragging .drop-overlay { display: flex; }

@media (max-width: 52rem) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; height: auto; border-right: 0; border-bottom: 0.0625rem solid var(--line); }
  .panel-body { overflow: visible; }
  .panel-foot { position: sticky; bottom: 0; z-index: 5; }
  .section { padding: 3rem 5%; }
  :root { --shot-h: 24rem; }
  .stage-head .tip { margin-left: 0; width: 100%; }
}
