@font-face {
  font-family: "Catamaran";
  src: url("Catamaran-VF.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --foam: #e9f8f4;
  --sand: #fff7e3;
  --sea: #7fd3cb;
  --sea-deep: #0d6b72;
  --sea-night: #0a4f57;
  --shell: #2f9e6e;
  --shell-dark: #1f7a52;
  --coral: #ff7a59;
  --coral-dark: #e35a39;
  --sun: #ffd25e;
  --ink: #17423a;
  --muted: #557571;
  --line: #cde6e0;
  --highlight: #fff0b3;
  --danger: #c4402e;
  --radius: 18px;
  --press: 0 3px 0 rgba(23, 66, 58, 0.22);
  font-family: "Catamaran", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; min-height: 100vh;
  background: linear-gradient(180deg, #bff0e8 0%, var(--sea) 100%) fixed;
}
[hidden] { display: none !important; }
body:not(.advanced) .adv { display: none !important; }

h1, h2, p { margin: 0; }
h1 { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.01em; line-height: 1.05; }
h2 { font-size: 1.15rem; font-weight: 800; }

button, input, select, textarea { font: inherit; color: inherit; }

/* chunky, pressable buttons */
button, .add-btn {
  border: 2px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--press);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
button:hover:not(:disabled), .add-btn:hover { border-color: var(--shell); }
button:active:not(:disabled), .add-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(23, 66, 58, 0.22); }
button:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
button.primary { background: var(--coral); border-color: var(--coral-dark); color: #fff; box-shadow: 0 3px 0 var(--coral-dark); }
button.primary:hover:not(:disabled) { background: var(--coral-dark); }
button.quiet { background: transparent; border-color: transparent; box-shadow: none; }
button.quiet:hover:not(:disabled) { background: var(--foam); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 0.25rem 0.75rem; font-size: 0.9rem; }
button.big { font-size: 1.1rem; padding: 0.6rem 1.3rem; }
button.round { width: 2.5rem; height: 2.5rem; padding: 0; font-size: 1.25rem; line-height: 1; }
button.link { border: 0; background: none; box-shadow: none; padding: 0.2rem 0.3rem; color: var(--sea-deep); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
button.link:active { transform: none; }

:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 0.4rem 0.6rem;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus { border-color: var(--shell); outline: none; }
textarea { resize: vertical; }
input[type="range"] { accent-color: var(--shell); }

/* step numbers */
.step {
  display: inline-grid; place-items: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--shell); color: #fff; font-weight: 900; font-size: 0.95rem;
  flex: none;
}
.step.light { background: rgba(255, 255, 255, 0.28); width: 1.5rem; height: 1.5rem; margin-right: 0.15rem; }

/* rising bubbles in the background */
.bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bubbles i {
  position: absolute; bottom: -40px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55); background: rgba(255, 255, 255, 0.15);
  animation: rise linear infinite;
}
.bubbles i:nth-child(1) { left: 6%;  width: 18px; height: 18px; animation-duration: 17s; }
.bubbles i:nth-child(2) { left: 18%; width: 10px; height: 10px; animation-duration: 12s; animation-delay: -4s; }
.bubbles i:nth-child(3) { left: 33%; width: 26px; height: 26px; animation-duration: 22s; animation-delay: -9s; }
.bubbles i:nth-child(4) { left: 49%; width: 12px; height: 12px; animation-duration: 15s; animation-delay: -2s; }
.bubbles i:nth-child(5) { left: 63%; width: 20px; height: 20px; animation-duration: 19s; animation-delay: -12s; }
.bubbles i:nth-child(6) { left: 77%; width: 9px;  height: 9px;  animation-duration: 11s; animation-delay: -6s; }
.bubbles i:nth-child(7) { left: 88%; width: 24px; height: 24px; animation-duration: 24s; animation-delay: -15s; }
.bubbles i:nth-child(8) { left: 95%; width: 14px; height: 14px; animation-duration: 14s; animation-delay: -8s; }
@keyframes rise {
  from { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translate(14px, -55vh); }
  to { transform: translate(-6px, -112vh); opacity: 0.3; }
}

/* ---------- top bar ---------- */
.bar {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.8rem 1.2rem;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.tagline { color: var(--sea-night); font-weight: 600; font-size: 0.95rem; }
.bar-actions { display: flex; gap: 0.5rem; align-items: center; }
.mascot { display: block; }
.bob { animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-4px) rotate(2deg); } }

/* ---------- workspace ---------- */
.workspace {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 1rem;
  padding: 0 1rem 1rem;
}
.panel {
  background: var(--paper);
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(10, 79, 87, 0.18);
  padding: 1rem 1.1rem;
  min-height: 0;
}
.drawings { overflow-y: auto; }
.panel-title { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.8rem; }
.count { color: var(--muted); font-weight: 600; font-size: 0.95rem; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  padding: 1.1rem 0.8rem;
  border: 3px dashed var(--sea);
  border-radius: var(--radius);
  background: var(--foam);
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.dropzone.over { border-color: var(--coral); background: var(--highlight); }
.add-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.add-btn { display: inline-flex; align-items: center; gap: 0.4rem; position: relative; font-size: 1.02rem; }
.add-btn.camera { background: var(--shell); border-color: var(--shell-dark); color: #fff; box-shadow: 0 3px 0 var(--shell-dark); }
.add-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.add-btn:focus-within { outline: 3px solid var(--sun); outline-offset: 2px; }
.add-btn.small-btn { font-size: 0.9rem; padding: 0.25rem 0.75rem; }
.drop-hint { color: var(--muted); font-size: 0.88rem; }

.list-tools { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; }

/* ---------- drawing cards ---------- */
.cards { list-style: none; margin: 0.9rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.cards:empty { display: none; }
.card {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.55rem;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.card.dragging { opacity: 0.4; }
.card.drop-before { box-shadow: 0 -4px 0 var(--coral); }
.card.drop-after { box-shadow: 0 4px 0 var(--coral); }
.card.flash { background: var(--highlight); }
.card.error { border-color: var(--danger); }
.grip {
  align-self: stretch; width: 10px; flex: none;
  cursor: grab;
  background-image: radial-gradient(var(--muted) 1.2px, transparent 1.4px);
  background-size: 6px 6px;
  opacity: 0.6;
}
.thumb {
  width: 72px; height: 72px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px; border: 0; padding: 0;
  background: var(--foam);
  box-shadow: none;
  overflow: hidden;
}
.thumb:hover { outline: 3px solid var(--sea); }
.thumb svg { max-width: 62px; max-height: 62px; }
.card-fields { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 1; }
.card-fields .name { font-weight: 800; font-size: 1.05rem; padding: 0.25rem 0.5rem; }
.card-row { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.status { font-size: 0.85rem; color: var(--muted); flex: 1; min-width: 0; }
.card.busy .status::before {
  content: ""; display: inline-block; width: 0.7rem; height: 0.7rem; margin-right: 0.35rem; vertical-align: -1px;
  border-radius: 50%; border: 2px solid var(--sea); border-top-color: transparent; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.card.error .status { color: var(--danger); }
.edit-btn { white-space: nowrap; }
.edit-btn.on { background: var(--foam); border-color: var(--sea); }
.card-actions { display: flex; flex-direction: column; gap: 0.15rem; }
button.icon { padding: 0 0.45rem; line-height: 1.5; border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
button.icon:hover { border-color: var(--line); background: var(--foam); }
button.icon.remove:hover { color: var(--danger); }

/* ---------- preview ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; gap: 0.7rem; }
.stage .panel-title { margin: 0; }
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tabs { display: flex; background: var(--foam); border-radius: 999px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; box-shadow: none; padding: 0.3rem 0.9rem; }
.tabs button[aria-selected="true"] { background: var(--sea-deep); color: #fff; }

.mat {
  position: relative;
  flex: 1;
  min-height: 420px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.10) 0 40px, transparent 41px),
    radial-gradient(circle at 85% 75%, rgba(255,255,255,0.08) 0 70px, transparent 71px),
    radial-gradient(circle at 70% 15%, rgba(255,255,255,0.07) 0 22px, transparent 23px),
    linear-gradient(160deg, var(--sea-deep), var(--sea-night));
  display: grid; place-items: center;
  padding: 1.5rem;
  overflow: hidden;
}
.empty { color: #e3f6f2; text-align: center; max-width: 24rem; font-size: 1.1rem; font-weight: 600; display: grid; justify-items: center; gap: 0.8rem; }
.swim { animation: swim 4s ease-in-out infinite; }
@keyframes swim { 0%, 100% { transform: translate(-10px, 0) rotate(-3deg); } 50% { transform: translate(10px, -8px) rotate(3deg); } }

.sheet { width: 100%; height: 100%; display: grid; place-items: center; min-height: 0; }
.sheet > svg {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  color: #000;
}
.sheet.white-ink > svg { background: #2a3530; color: #fff; }
.sheet .tz-hit { cursor: text; }
.sheet .tz-hit:hover { fill: rgba(255, 210, 94, 0.45); }
.sheet .tz-art { cursor: pointer; }
.shirt { width: 100%; height: 100%; display: grid; place-items: center; min-height: 0; }
.shirt > svg { max-width: 100%; max-height: 100%; width: auto; height: auto; }

.stale {
  position: absolute; top: 0.8rem; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--highlight); color: var(--ink);
  padding: 0.3rem 0.4rem 0.3rem 0.9rem; border-radius: 999px; font-weight: 700; font-size: 0.9rem;
}
.inline-name {
  position: absolute; text-align: center; font-weight: 800;
  border: 3px solid var(--coral) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 5;
}
.stage-foot:empty { display: none; }
.layout-info { color: var(--muted); font-size: 0.92rem; }
.layout-info:empty { display: none; }
.warnings { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.warnings li { padding: 0.15rem 0; }
.warnings li::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--sun); margin-right: 0.45rem; }

/* Advanced switch + style bar */
.adv-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; border-top: 2px dashed var(--line); padding-top: 0.7rem; }
.adv-row .hint { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 800; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.knob { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; }
.knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.15s; }
.switch input:checked + .knob { background: var(--shell); }
.switch input:checked + .knob::after { transform: translateX(18px); }
.switch input:focus-visible + .knob { outline: 3px solid var(--sun); outline-offset: 2px; }

.style-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.9rem 1.4rem; }
.style-group { display: flex; flex-direction: column; gap: 0.3rem; }
.more-btn { margin-left: auto; }

/* ---------- settings bits ---------- */
.field { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.6rem; }
.label { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.check { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.6rem; cursor: pointer; }
.check input { accent-color: var(--shell); width: 1.05rem; height: 1.05rem; }
.seg { display: flex; background: var(--foam); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; box-shadow: none; background: transparent; padding: 0.3rem 0.85rem; white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--shell); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.swatch {
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.18);
  box-shadow: none;
}
.swatch[aria-checked="true"] { outline: 3px solid var(--coral); outline-offset: 2px; }
.swatches input[type="color"] { width: 34px; height: 34px; padding: 0; border: 0; background: none; cursor: pointer; }
.hint { font-size: 0.88rem; color: var(--muted); }
.hint.error { color: var(--danger); }
#retrace-all { margin-top: 0.8rem; }
#export-eps { margin-top: 0.8rem; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 24px; padding: 0; width: min(460px, 94vw); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
dialog::backdrop { background: rgba(10, 79, 87, 0.55); }
dialog.wide { width: min(940px, 96vw); }
.dialog-body { padding: 1.3rem; display: flex; flex-direction: column; gap: 0.75rem; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }
#login-form .mascot { align-self: center; }

.options-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.8rem; }
fieldset { border: 2px solid var(--line); border-radius: var(--radius); padding: 0.4rem 0.9rem 0.9rem; margin: 0; min-width: 0; }
legend { font-weight: 800; padding: 0 0.3rem; }

/* name style */
.style-btn { display: inline-flex; align-items: center; gap: 0.45rem; }
.aa { font-weight: 900; font-size: 1.05em; color: var(--coral-dark); letter-spacing: -0.02em; }
dialog.side {
  position: fixed; inset: 92px auto auto 1rem; margin: 0;
  width: 370px; max-height: calc(100vh - 110px); overflow-y: auto;
  z-index: 30;
}
.font-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.font-tile {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.2rem;
  border-radius: 16px; padding: 0.5rem 0.6rem 0.4rem; text-align: left;
  box-shadow: none; min-width: 0;
}
.font-tile svg { width: 100%; height: 42px; color: var(--ink); }
.font-tile .fname { font-size: 0.8rem; font-weight: 800; }
.font-tile .ftag { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.font-tile[aria-checked="true"] { border-color: var(--coral); background: #fff4ef; box-shadow: 0 0 0 2px var(--coral); }
#weight-seg button { padding: 0.3rem 0.5rem; font-size: 0.88rem; }
.range-ends { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.range-ends input { flex: 1; min-width: 0; }
#size-out { color: var(--ink); }

/* edit dialog */
#edit-name { max-width: 20rem; font-weight: 800; font-size: 1.1rem; }
.edit-tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.edit-tools .seg { width: 13rem; }
#rot-left, #rot-right { font-size: 1.15rem; padding: 0.1rem 0.6rem; }
.crop-stage {
  display: grid; place-items: center;
  background: var(--foam); border-radius: var(--radius);
  padding: 0.5rem; min-height: 0;
}
#crop-canvas { display: block; max-width: 100%; max-height: 52vh; touch-action: none; cursor: crosshair; background: #fff; border-radius: 6px; }
.clean-toggle { margin-top: 0; font-weight: 700; font-size: 0.92rem; }
.thick { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.thick input { flex: 1; min-width: 0; }
#names-text { font-size: 1rem; line-height: 1.5; }

/* ---------- toast + party ---------- */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 700;
  padding: 0.6rem 1.1rem; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  z-index: 50; max-width: 92vw; text-align: center;
}
.toast.error { background: var(--danger); }
.party { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.party > * { position: absolute; bottom: -60px; animation: party-up 2.4s ease-out forwards; }
.party .pb { border-radius: 50%; border: 3px solid #fff; background: rgba(255,255,255,0.3); }
@keyframes party-up {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), -105vh) rotate(var(--rot)); opacity: 0.2; }
}

/* ---------- smaller screens ---------- */
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .tagline { display: none; }
}

/* Phones: one section at a time, switched from the bar at the bottom */
@media (max-width: 760px) {
  body { min-height: 100vh; padding-bottom: 78px; }
  .bar { padding: 0.6rem 0.8rem; gap: 0.5rem; }
  .brand .mascot { width: 50px; height: 32px; }
  h1 { font-size: 1.25rem; }
  .bar-actions { width: 100%; }
  .bar-actions .primary { flex: 1; }
  .workspace { display: block; flex: none; padding: 0 0.6rem 0.6rem; }
  .panel { padding: 0.9rem; }
  .drawings { overflow: visible; }
  body[data-panel="drawings"] .stage, body[data-panel="stage"] .drawings { display: none; }
  .mat { flex: none; min-height: 0; height: calc(100vh - 300px); min-height: 320px; padding: 0.8rem; }
  .more-btn { margin-left: 0; }
  button.icon { min-width: 36px; min-height: 32px; font-size: 1.1rem; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--paper);
    box-shadow: 0 -4px 16px rgba(10, 79, 87, 0.15);
    padding: 0.5rem 0.6rem calc(0.5rem + env(safe-area-inset-bottom));
    gap: 0.5rem;
  }
  .mobile-nav button { flex: 1; padding: 0.55rem 0; display: inline-flex; justify-content: center; align-items: center; gap: 0.4rem; }
  .mobile-nav button[aria-pressed="true"] { background: var(--sea-deep); border-color: var(--sea-night); color: #fff; }
  .mobile-nav button[aria-pressed="true"] .step { background: #fff; color: var(--sea-deep); }
  .toast { bottom: 88px; }
  dialog.side { inset: auto 0 0 0; width: 100%; max-width: none; max-height: 58vh; border-radius: 24px 24px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
