:root {
  --font-ui: Helvetica, Arial, 'Helvetica Neue', sans-serif;
  --bg-app: #0b0b0d;
  --bg-panel: #141416;
  --bg-panel-alt: #1d1d20;
  --bg-field: #202024;
  --border: #2b2b2f;
  --text: #f2f2f0;
  --text-muted: #9a9aa0;
  --accent: #ff6a5c;
  --accent-soft: rgba(255, 106, 92, 0.18);
  --secondary: #ff5fa8;
  --secondary-soft: rgba(255, 95, 168, 0.16);
  --gutter: 40px;
  /* hand-drawn cursor — the same sketched arrow glyph used in .header-link-arrow,
     at 2x that button's size and rotated 90° counter-clockwise (pointing up
     instead of right), swapped for whichever color reads against the
     background it's currently over (white on the dark tool chrome, black on
     the white poster/page areas) instead of the flat system arrow. Hotspot
     sits at the arrowhead's tip (its (19.5,12) position in the shared 24x24
     path, rotated -90° around the (12,12) center, then scaled 2x). Hovering
     an interactive element swaps to the pink secondary color instead of the
     browser's own hand cursor. */
  --cursor-light: url('../assets/cursor-white.svg') 25 9, default;
  --cursor-dark: url('../assets/cursor-black.svg') 25 9, default;
  --cursor-hover: url('../assets/cursor-pink.svg') 25 9, pointer;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text);
  cursor: var(--cursor-light);
}

canvas {
  display: block;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
}

#topbar {
  height: 110px;
  display: grid;
  /* minmax(0, 1fr), not plain 1fr — a plain 1fr track's automatic minimum is
     its content's min-content size, which can force the grid wider than the
     viewport on narrow phones instead of letting the side columns shrink */
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 6px var(--gutter);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

#anniversaryBadge {
  justify-self: start;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  color: #ffffff;
  letter-spacing: 0.2px;
}

#wordmark {
  justify-self: center;
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 76px;
  line-height: 1;
  color: #fff;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* header nav link — same script font as the wordmark, no border/background,
   just colored text so it reads as part of the logo lockup rather than a UI button */
.header-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 26px;
  line-height: 1.05;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.1px;
  border: none;
  background: none;
  /* inherit, not auto — a link/button's default "auto" cursor renders as the
     browser's own hand regardless of the ancestor's cursor, so it has to be
     forced back to the inherited hand-drawn arrow explicitly */
  cursor: inherit;
  transition: color 0.15s ease;
}

.header-link:hover { color: var(--secondary); cursor: var(--cursor-hover); }

.header-link-text {
  text-align: left;
}

/* hand-sketched arrow (not the font's own arrow glyph — Caveat doesn't ship
   one, so it would silently fall back to a mismatched system font) — a curved
   shaft plus a single V-stroke head, drawn in the button's own text color */
.header-link-arrow {
  display: inline-flex;
  align-items: center;
}

.header-link-arrow svg {
  width: 25px;
  height: 25px;
  display: block;
}

.header-link-arrow--flip { transform: scaleX(-1); }

#main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

#leftMenu {
  width: 380px;
  padding: 30px var(--gutter);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
}

#leftMenu::-webkit-scrollbar { width: 8px; }
#leftMenu::-webkit-scrollbar-track { background: transparent; }
#leftMenu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
#leftMenu::-webkit-scrollbar-thumb:hover { background: var(--accent); }

#canvasWrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.06) 1px, transparent 0) 0 0/24px 24px,
    var(--bg-app);
}

#previewContainer {
  width: 80%;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

#canvasHolder {
  position: relative;
  background: #fff;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
  cursor: var(--cursor-dark);
}

#canvasHolder:focus-within {
  box-shadow: 0 0 0 3px var(--accent), 0 12px 40px rgba(0,0,0,0.55);
}

#canvasTextInput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  overflow: hidden;
  cursor: text;
  z-index: 5;
}

#bottombar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px var(--gutter);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

/* "Grussbotschaft senden" shares the exact same script-font link look as the
   header's "Zu den Grussbotschaften" — plain colored text, no pill/background */
#sendGreeting.header-link {
  justify-self: auto;
  width: auto;
  margin: 0;
  padding: 0;
}

#sendGreeting.header-link:disabled { opacity: 0.6; cursor: inherit; }

h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 0 14px 0;
  padding-bottom: 10px;
  font-family: 'Caveat', cursive;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

#leftMenu h3:first-of-type { margin-top: 2px; }

label {
  display: block;
  margin: 14px 0;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text-muted);
  /* the browser's UA stylesheet sets cursor:default directly on <label> —
     without this override that breaks inheritance for every control nested
     inside a label (every slider/select/color-picker in the left menu) */
  cursor: inherit;
}

textarea, select, input[type="number"], input[type="text"] {
  width: 100%;
  margin-top: 7px;
  padding: 10px 12px;
  background: var(--bg-field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
  /* a <select>'s default "auto" cursor renders as the browser's own arrow
     regardless of the ancestor's cursor, same as links/buttons */
  cursor: inherit;
}

select:hover { cursor: var(--cursor-hover); }

select:focus, textarea:focus, input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="color"] {
  width: 100%;
  margin-top: 7px;
  height: 42px;
  padding: 3px;
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: inherit;
}

input[type="color"]:hover { cursor: var(--cursor-hover); }

input[type="range"] {
  width: 100%;
  margin-top: 8px;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
  cursor: inherit;
}

input[type="range"]:hover { cursor: var(--cursor-hover); }

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--secondary);
  border: 2px solid #fff;
  cursor: inherit;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

input[type="range"]::-webkit-slider-thumb:hover { cursor: var(--cursor-hover); }

input[type="range"]::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--secondary);
  border: 2px solid #fff;
  cursor: inherit;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

input[type="range"]::-moz-range-thumb:hover { cursor: var(--cursor-hover); }

.sliderVal {
  display: inline-block;
  min-width: 44px;
  margin-top: 7px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

button {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--text);
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  cursor: var(--cursor-hover);
}

/* tablets and narrow desktops: keep the sidebar usable but stack it above the
   canvas instead of beside it, so its 380px fixed width doesn't crush the
   preview area */
@media (max-width: 900px) {
  :root { --gutter: 24px; }

  #main {
    flex-direction: column;
    overflow-y: auto;
  }

  #leftMenu {
    width: 100%;
    max-height: 42vh;
    padding: 20px var(--gutter);
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
  }

  #canvasWrap {
    min-height: 220px;
  }

  #previewContainer {
    width: 94%;
    height: 92%;
  }
}

/* phones: shrink the header lockup and spacing so nothing wraps/overflows on
   narrow viewports */
@media (max-width: 600px) {
  :root { --gutter: 16px; }

  /* the 3-column single-row header (badge | wordmark | link) has no room
     left over for the wordmark on a phone once the side columns are wide
     enough to hold their own text — badge and link would collide with it.
     Give the wordmark its own full-width row instead, with badge/link
     sharing a row above it. */
  #topbar {
    height: auto;
    min-height: 96px;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      "badge link"
      "word word";
    row-gap: 4px;
    column-gap: 8px;
    padding: 10px var(--gutter);
  }

  #anniversaryBadge {
    grid-area: badge;
    font-size: 10px;
  }

  #wordmark {
    grid-area: word;
    justify-self: center;
    font-size: 36px;
  }

  .header-link {
    grid-area: link;
    font-size: 15px;
    gap: 5px;
  }

  .header-link-arrow svg {
    width: 18px;
    height: 18px;
  }

  #bottombar {
    height: auto;
    padding: 12px var(--gutter);
  }

  #leftMenu {
    max-height: 38vh;
    padding: 16px var(--gutter);
  }

  h3 {
    margin: 20px 0 12px 0;
    font-size: 26px;
  }

  label {
    margin: 12px 0;
    font-size: 14px;
  }
}

/* short/landscape phones: the sidebar's vh-based cap eats too much of the
   little vertical space there is, so tighten it further */
@media (max-width: 900px) and (orientation: landscape) {
  #leftMenu {
    max-height: 46vh;
  }
}
