/* hyd-postcard.css
   The personal postcard window (#hyd-postcard, behaviour in hyd-postcard.js): a live preview beside a
   form, a photo picker, a sticker tray and the delivery actions.
   Rules are layered in the order they were added. The first half is the original window; the
   fixed-height layout (O3) and the sage palette further down deliberately override it, so where a
   selector repeats, the later rule wins. --postcard-gutter is local; --paper-* and --metal-* are set
   by the sage palette block; --desktop-font and --phone-sheet-* come from other site sheets. */

/* A small silver/plum postcard window, using only the personal photo catalogue. */
#hyd-postcard {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(1040px, calc(100vw - 34px));
  max-width: none;
  max-height: calc(100dvh - 34px);
  overflow: auto;
  padding: 4px;
  border: 2px solid;
  border-color: #f1eaf6 #605168 #605168 #f1eaf6;
  border-radius: 7px;
  background: #21162d;
  color: #f6edfa;
  box-shadow:
    0 5px 0 #0b0712,
    0 24px 90px #0009;
  rotate: 0deg;
  transform: none;
  font:
    12px/1.5 Tahoma,
    sans-serif;
  color-scheme: dark;
}

#hyd-postcard::backdrop {
  background: #0b0714ba;
  backdrop-filter: blur(3px);
}

/* --- Titlebar and close button --- */
#hyd-postcard .postcard-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: -4px;
  z-index: 2;
  padding: 6px 8px;
  background:
    repeating-linear-gradient(0deg, #ffffff20 0 1px, transparent 1px 3px),
    linear-gradient(#e9e5ef, #b2aabb 48%, #cbc4d3);
  border: 1px solid;
  border-color: #fff #7c7285 #7c7285 #fff;
  border-radius: 3px 3px 0 0;
  color: #30213b;
  text-shadow: 0 1px #fff9;
}

#hyd-postcard h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font:
    bold 12px/1.4 Tahoma,
    sans-serif;
  letter-spacing: 0;
  margin: 0;
  color: #30213b;
}

#hyd-postcard h2 > span {
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}

#hyd-postcard .postcard-close {
  flex: none;
  width: 28px;
  height: 27px;
  padding: 0;
  font:
    20px/1 Tahoma,
    sans-serif;
  background: linear-gradient(#f6f1f9, #aa9bb8);
  color: #30213b;
  border: 1px solid;
  border-color: #fff #65576f #65576f #fff;
  border-radius: 3px;
  box-shadow: inset 0 1px #fff9;
}

/* --- Two-column layout: preview on the left, form on the right --- */
#hyd-postcard .postcard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: 22px;
  padding: 24px 21px;
}

#hyd-postcard .postcard-preview-panel {
  min-width: 0;
  align-self: start;
  padding: 14px 1px;
}

#hyd-postcard .postcard-paper {
  padding: 5px;
  background: linear-gradient(130deg, #9883ab55, #31213f);
  border: 1px solid #746080;
  box-shadow: 4px 6px 0 #0d081680;
  rotate: 0deg;
}

#hyd-postcard canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 14/9;
  box-shadow: 0 2px 8px #0007;
}

#hyd-postcard .postcard-preview-caption {
  margin: 17px 0 0;
  text-align: center;
  font:
    italic 18px/1.35 Georgia,
    serif;
  color: #e4bdd6;
}

/* --- Form: photo grid, fields and actions --- */
#hyd-postcard .postcard-form {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 5px;
  padding-left: 20px;
  border-left: 1px solid #665170;
}

#hyd-postcard fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 11px;
  min-width: 0;
}

#hyd-postcard legend {
  padding: 0;
  font:
    bold 11px/1.5 Tahoma,
    sans-serif;
  margin-bottom: 7px;
  color: #f2e3fa;
}

/* The grid declares max-height twice on purpose: the first value is the fallback for browsers that
   do not understand min() with dvh units. */
#hyd-postcard .postcard-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  min-height: 0;
  max-height: 280px;
  max-height: min(280px, 34dvh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-padding: 5px;
  padding: 5px;
}

#hyd-postcard .postcard-photos button {
  display: block;
  min-width: 0;
  overflow: hidden;
  padding: 3px;
  text-align: left;
  border: 1px solid #82708f;
  border-radius: 2px;
  background: #30223e;
  box-shadow: 2px 2px #0c0810;
  color: #e8d9f0;
}

#hyd-postcard .postcard-photos img {
  display: block;
  width: 100%;
  height: 66px;
  object-fit: cover;
  filter: none;
}

#hyd-postcard .postcard-photos span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font:
    10px/1.3 Tahoma,
    sans-serif;
  padding: 5px 2px 2px;
}

#hyd-postcard .postcard-photos button[aria-pressed='true'] {
  border-color: #efd2e9;
  box-shadow:
    0 0 0 1px #d998c2,
    inset 0 0 0 1px #fff1fa50;
  background: #5b3a61;
  color: #fff4fc;
}

#hyd-postcard .postcard-form > label {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: #f1e4f9;
  font:
    11px/1.4 Tahoma,
    sans-serif;
  margin-top: 5px;
}

#hyd-postcard .postcard-form > label span,
#hyd-postcard output {
  color: #bfaccb;
  font-size: 10px;
}

#hyd-postcard output {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

#hyd-postcard .postcard-form > input,
#hyd-postcard textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 8px 9px;
  border: 1px solid;
  border-color: #100a18 #806b91 #806b91 #100a18;
  border-radius: 3px;
  background: #150e20;
  color: #fff3ff;
  box-shadow: inset 0 2px 4px #0005;
  font:
    12px/1.5 Tahoma,
    sans-serif;
}

#hyd-postcard .postcard-form > input::placeholder,
#hyd-postcard textarea::placeholder {
  color: #9f8fad;
  opacity: 1;
}

#hyd-postcard textarea {
  min-height: 104px;
  max-height: 230px;
  resize: vertical;
}

/* --- Delivery actions --- */
#hyd-postcard .postcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}

#hyd-postcard .postcard-actions button {
  flex: 1 1 110px;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid;
  border-color: #eee1f8 #685079 #685079 #eee1f8;
  border-radius: 4px;
  background: linear-gradient(#bd9dcf, #8d6aa7 49%, #72508c 51%, #9b76b4);
  color: #fff6ff;
  text-shadow: 0 1px #443052;
  box-shadow:
    inset 0 1px #fff5,
    0 2px #0d0718;
  font:
    11px/1.35 Tahoma,
    sans-serif;
}

#hyd-postcard #postcard-share {
  background: linear-gradient(#594562, #37263f);
  border-color: #9e86ac #100a17 #100a17 #9e86ac;
}

#hyd-postcard #postcard-share {
  flex-basis: 100%;
}

/* Script toggles the hidden attribute on controls inside the postcard; !important stops any display
   rule in this file from showing them anyway. */
#hyd-postcard [hidden] {
  display: none !important;
}

/* --- Stickers on the card: layer, drag handles, tray and palette --- */
#hyd-postcard .postcard-sheet {
  position: relative;
  isolation: isolate;
}

#hyd-postcard .postcard-sticker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Invisible hit area laid over each placed sticker so it can be dragged and selected. !important on
   the background keeps any button, hover or theme background from painting a box behind the sticker. */
#hyd-postcard .postcard-sticker-handle {
  position: absolute;
  padding: 0;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  box-shadow: none;
  background: transparent !important;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  min-width: 0;
  min-height: 0;
  transition: none;
}

#hyd-postcard .postcard-sticker-handle[aria-pressed='true'] {
  border-color: #6a426d;
  outline: 2px dashed #f8edf8;
  outline-offset: 2px;
}

#hyd-postcard .postcard-sticker-handle:active {
  cursor: grabbing;
  border-style: solid;
  box-shadow: none;
}

#hyd-postcard .postcard-sticker-handle:focus-visible {
  outline: 3px solid #5e3478;
  outline-offset: 3px;
}

/* The selected sticker's corner handle (T11): a 24px press area at the turned corner, drawn as a
   small square, and above every sticker's hit area. The script sets left/top to the corner, rotate
   to the sticker's turn, and translate to its offset from the corner (gripPlacement, in the
   postcard script); the translate here centres it on the corner until the script has measured it. */
#hyd-postcard .postcard-sticker-grip {
  position: absolute;
  z-index: 1;
  width: 24px;
  height: 24px;
  translate: -50% -50%;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent !important;
  pointer-events: auto;
  touch-action: none;
  cursor: nwse-resize;
  min-width: 0;
  min-height: 0;
  transition: none;
}

/* The square; the script's translate keeps it on the corner wherever the press area goes. */
#hyd-postcard .postcard-sticker-grip-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  box-sizing: border-box;
  border: 2px solid #6a426d;
  border-radius: 3px;
  background: #f8edf8;
  box-shadow: 0 1px 2px #0d081680;
}

#hyd-postcard .postcard-sticker-grip:not(:disabled):active {
  box-shadow: none;
}

/* Touchscreens: a 44px press area, which the script places diagonally outside the corner (pulled
   back onto the card near its edges), leaving the sticker free to drag. */
@media (any-pointer: coarse) {
  #hyd-postcard .postcard-sticker-grip {
    width: 44px;
    height: 44px;
  }

  #hyd-postcard .postcard-sticker-grip-mark {
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
  }
}

/* The rotate knob (R2-7): a round version of the maker's glossy sticker-control buttons (the same
   violet metal gradient, bevelled border and inner highlight as .postcard-sticker-controls
   button), with a circular arrow; the script sets left/top to its centre (turnPlacement).
   28px, 44px on touchscreens. */
#hyd-postcard .postcard-sticker-turn {
  position: absolute;
  z-index: 1;
  width: 28px;
  height: 28px;
  translate: -50% -50%;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid;
  border-color: #f3ecf5 #51455c #51455c #f3ecf5;
  border-radius: 50%;
  background: linear-gradient(#eee6f0, #baacc5 48%, #a999b6 50%, #cbbdd4) !important;
  color: #30203e;
  box-shadow:
    inset 0 1px #fffc,
    0 1px #100a17;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  min-width: 0;
  min-height: 0;
  transition: none;
}

#hyd-postcard .postcard-sticker-turn[hidden] {
  display: none;
}

#hyd-postcard .postcard-sticker-turn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

#hyd-postcard .postcard-sticker-turn:focus-visible {
  outline: 3px solid #5e3478;
  outline-offset: 3px;
}

#hyd-postcard .postcard-sticker-turn:active {
  cursor: grabbing;
}

@media (any-pointer: coarse) {
  #hyd-postcard .postcard-sticker-turn {
    width: 44px;
    height: 44px;
  }

  #hyd-postcard .postcard-sticker-turn svg {
    width: 24px;
    height: 24px;
  }
}

/* While a finger holds a sticker, a second finger on the photograph pinches the sticker instead of
   zooming the page. */
#hyd-postcard .postcard-sheet[data-sticker-gesture] canvas {
  touch-action: none;
}

#hyd-postcard .postcard-sticker-tray {
  margin: 26px 0 0;
  padding: 12px 13px;
  border: 1px solid;
  border-color: #96819e #130c1a #130c1a #96819e;
  border-radius: 5px;
  background: linear-gradient(#362940, #251a2f);
  box-shadow: inset 0 1px #fff1;
}

#hyd-postcard .postcard-sticker-tray legend {
  padding: 0 6px;
  margin: 0;
  font-size: 11px;
  color: #f2e6f7;
}

#hyd-postcard #postcard-sticker-count {
  margin-left: 10px;
  font-weight: normal;
  color: #b8a5c5;
  font-size: 10px;
}

#hyd-postcard .postcard-sticker-palette {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
}

#hyd-postcard .postcard-sticker-palette button {
  padding: 5px 2px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  min-width: 0;
  box-shadow: none;
  transition:
    background 0.12s,
    transform 0.12s;
}

#hyd-postcard .postcard-sticker-palette button:not(:disabled):hover {
  border-color: #9c84ac;
  background: #79628b40;
  transform: translateY(-2px);
}

#hyd-postcard .postcard-sticker-palette img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 62px;
  aspect-ratio: 1;
  filter: drop-shadow(0 3px 2px #09041160);
}

#hyd-postcard .postcard-sticker-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #73607e;
}

#hyd-postcard #postcard-selected-sticker {
  flex: 1 1 120px;
  font-size: 11px;
  color: #ebdcee;
}

#hyd-postcard .postcard-sticker-controls button {
  min-width: 28px;
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid;
  border-color: #f3ecf5 #51455c #51455c #f3ecf5;
  border-radius: 3px;
  background: linear-gradient(#eee6f0, #baacc5 48%, #a999b6 50%, #cbbdd4);
  color: #30203e;
  text-shadow: 0 1px #fff8;
  font:
    12px Tahoma,
    sans-serif;
  box-shadow: 0 1px #100a17;
}

/* --- Shared button states, focus and helper text --- */
#hyd-postcard button:not(:disabled):active {
  border-style: inset;
  box-shadow: inset 0 2px 3px #0005;
}

#hyd-postcard button:disabled {
  opacity: 0.42;
  cursor: default;
}

#hyd-postcard :is(button, input, textarea, a):focus-visible {
  outline: 2px solid #f2c6e7;
  outline-offset: 3px;
}

#hyd-postcard #postcard-open {
  align-self: flex-start;
  color: #edc4e1;
  font:
    11px/1.5 Tahoma,
    sans-serif;
  text-underline-offset: 3px;
  margin-top: 4px;
  padding: 3px 0;
}

#hyd-postcard .postcard-close:focus-visible {
  outline-color: #553564;
  outline-offset: 1px;
}

#hyd-postcard .postcard-hint {
  font:
    10px/1.5 Tahoma,
    sans-serif;
  color: #c2afce;
  margin: 5px 0 0;
}

#hyd-postcard #postcard-status {
  min-height: 30px;
  color: #edc9e0;
  font:
    11px/1.5 Tahoma,
    sans-serif;
  margin: 3px 0 0;
}

/* Visually hidden but still announced by screen readers. */
#hyd-postcard .postcard-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Narrow screens (first pass; the fixed-height layout below refines it) --- */
@media (max-width: 760px) {
  #hyd-postcard {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  #hyd-postcard .postcard-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 15px;
  }

  #hyd-postcard .postcard-preview-panel {
    padding: 2px 4px 0;
  }

  #hyd-postcard .postcard-preview-caption {
    margin-top: 10px;
    font-size: 16px;
  }

  #hyd-postcard .postcard-form {
    padding: 15px 0 0;
    border-left: 0;
    border-top: 1px solid #665170;
  }

  /* Same double max-height fallback as the desktop photo grid above. */
  #hyd-postcard .postcard-photos {
    max-height: 240px;
    max-height: min(240px, 32dvh);
  }

  #hyd-postcard .postcard-photos img {
    height: 66px;
  }

  #hyd-postcard textarea {
    min-height: 88px;
  }

  #hyd-postcard .postcard-form > input,
  #hyd-postcard textarea {
    font-size: 16px;
  }

  #hyd-postcard .postcard-titlebar {
    gap: 8px;
  }

  #hyd-postcard h2 {
    font-size: 11px;
  }
}

@media (max-width: 440px) {
  #hyd-postcard .postcard-sticker-palette {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #hyd-postcard .postcard-sticker-palette img {
    max-width: 50px;
    margin: auto;
  }

  #hyd-postcard .postcard-sticker-tray {
    padding: 8px;
  }

  #hyd-postcard .postcard-sticker-controls button {
    min-height: 34px;
    min-width: 34px;
  }
}

/* Reduced motion: the hover lift comes from a rule with higher specificity, so !important is what
   cancels that transform. */
@media (prefers-reduced-motion: reduce) {
  #hyd-postcard .postcard-sticker-palette button {
    transition: none;
    transform: none !important;
  }
}

/* A readable shelf for the detailed local souvenir renders. */
#hyd-postcard .postcard-sticker-palette {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px 5px;
}

#hyd-postcard .postcard-sticker-palette button {
  padding: 5px 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

#hyd-postcard .postcard-sticker-palette img {
  max-width: 88px;
  margin: auto;
}

#hyd-postcard .postcard-sticker-palette button > span {
  font:
    9px/1.25 Tahoma,
    sans-serif;
  color: var(--paper-text,#f3e6f8);
  text-align: center;
}

@media (max-width: 440px) {
  #hyd-postcard .postcard-sticker-palette {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #hyd-postcard .postcard-sticker-palette img {
    max-width: 68px;
  }
}

#hyd-postcard .postcard-sticker-palette [data-kind='stamp'] img {
  filter: brightness(3);
}

/* Photo choice belongs beside the preview, not below the sticker shelf. */
#hyd-postcard .postcard-photo-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 12px;
  padding: 0;
  min-height: 32px;
}

#hyd-postcard .postcard-photo-tools button {
  min-height: 32px;
  min-width: 32px;
  padding: 4px 10px;
  border: 1px solid #777;
  border-top-color: #eee;
  border-left-color: #ddd;
  border-radius: 4px;
  background: linear-gradient(#f6f6f6, #c8c8c8);
  color: #242424;
  font: 12px var(--desktop-font,Tahoma,sans-serif);
  box-shadow: 0 1px 1px #0004;
  text-shadow: 0 1px #fff;
}

#hyd-postcard #postcard-change-photo {
  margin-right: auto;
}

#hyd-postcard #postcard-photo-position {
  font: 11px var(--desktop-font,Tahoma,sans-serif);
  color: var(--paper-muted,#cbc5cd);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#hyd-postcard #postcard-photo-picker {
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid var(--paper-edge,#858089);
  background: var(--paper-panel,#333038);
  border-radius: 4px;
}

#hyd-postcard #postcard-photo-picker .postcard-photos {
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  max-height: 220px;
}

#hyd-postcard #postcard-photo-picker legend {
  padding: 0 5px;
}

/* A live hint sits outside the exported canvas. */
#hyd-postcard .postcard-note-hint {
  position: absolute;
  left: 65.3%;
  top: 30%;
  max-width: 30%;
  font:
    italic clamp(7px, 1.2vw, 15px)/1.45 Georgia,
    serif;
  color: #526c54;
  pointer-events: none;
}

/* --- Fixed-height window: overrides the rules above wherever the selectors repeat --- */

/* O3: the title and delivery controls stay on screen; only the work area scrolls. */
#hyd-postcard {
  --postcard-gutter: 16px;
  width: min(1040px, calc(100vw - 24px));
  height: min(760px, calc(100dvh - 24px));
  max-height: none;
  overflow: hidden;
  font: 14px/1.4 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard[open] {
  display: flex;
  flex-direction: column;
}

#hyd-postcard .postcard-titlebar {
  position: static;
  flex: none;
  min-height: 48px;
  padding: 4px 8px;
  gap: 12px;
}

#hyd-postcard h2 {
  font: bold 14px/1.3 var(--desktop-font,Tahoma,sans-serif);
  min-width: 0;
}

#hyd-postcard h2 svg {
  width: 20px;
  height: 20px;
  flex: none;
}

#hyd-postcard .postcard-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
}

#hyd-postcard .postcard-close svg {
  width: 18px;
  height: 18px;
}

#hyd-postcard .postcard-layout {
  flex: 1;
  min-height: 0;
  overflow: auto;
  contain: layout paint;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  align-content: start;
  gap: 20px;
  padding: var(--postcard-gutter);
}

#hyd-postcard .postcard-preview-panel {
  padding: 0;
}

#hyd-postcard .postcard-paper {
  background: #718570;
  border-color: #a1b39c;
  box-shadow: 2px 3px #152117;
}

#hyd-postcard .postcard-preview-caption {
  margin: 10px 0 16px;
  text-align: left;
  font: 12px/1.4 var(--desktop-font,Tahoma,sans-serif);
  color: var(--paper-muted,#cbc3d0);
}

#hyd-postcard .postcard-form {
  gap: 6px;
  padding: 0 0 0 20px;
}

#hyd-postcard .postcard-form > label {
  margin: 8px 0 0;
  font: 13px/1.4 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard .postcard-form > label:first-child {
  margin-top: 0;
}

#hyd-postcard .postcard-form > label span,
#hyd-postcard output {
  font-size: 12px;
}

#hyd-postcard .postcard-form > input,
#hyd-postcard textarea {
  min-height: 40px;
  font: 16px/1.4 var(--desktop-font,Tahoma,sans-serif);
  text-transform: none;
}

#hyd-postcard textarea {
  min-height: 124px;
}

#hyd-postcard .postcard-hint {
  font: 12px/1.5 var(--desktop-font,Tahoma,sans-serif);
  margin-top: 8px;
}

#hyd-postcard .postcard-footer {
  flex: none;
  border-top: 1px solid var(--paper-edge,#68606f);
  padding: 12px var(--postcard-gutter) 8px;
  background: var(--paper-panel,#34313a);
}

#hyd-postcard .postcard-actions {
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
}

#hyd-postcard .postcard-actions button {
  flex: 0 1 auto;
  min-width: 136px;
  min-height: 38px;
  padding: 7px 14px;
  font: 14px/1.2 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard #postcard-share {
  flex-basis: auto;
}

/* The share button is the primary action and turns green under any theme. The html[data-theme]
   prefix lifts specificity above the theme sheet's generic button rules. */
html[data-theme] #hyd-postcard .postcard-footer #postcard-share {
  background: linear-gradient(#32684d, #29563f 49%, #193b2b 50%, #294f3b);
  color: #fff;
  border-color: #8fb495 #14291d #14291d #8fb495;
  text-shadow: 0 1px #14291d;
  box-shadow:
    inset 0 1px #ffffff50,
    0 1px 2px #0005;
}

#hyd-postcard .postcard-delivery {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 7px;
  min-height: 32px;
}

#hyd-postcard #postcard-status {
  flex: 1;
  min-width: 0;
  min-height: 0;
  margin: 0;
  font: 12px/1.4 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard #postcard-open {
  flex: none;
  margin: 0;
  padding: 0;
  font: 12px/1.4 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard .postcard-sticker-tray {
  margin: 0;
  padding: 0 10px;
  border-radius: 3px;
  box-shadow: none;
}

#hyd-postcard .postcard-sticker-tray summary {
  padding: 10px 0;
  cursor: pointer;
  font: 13px/1.4 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard .postcard-sticker-palette {
  padding-top: 8px;
  border-top: 1px solid var(--paper-edge,#82758f);
}

#hyd-postcard .postcard-sticker-palette button {
  transition: none;
  border-radius: 3px;
}

#hyd-postcard .postcard-sticker-palette button:not(:disabled):hover {
  transform: none;
}

#hyd-postcard .postcard-sticker-palette button > span {
  font: 11px/1.3 var(--desktop-font,Tahoma,sans-serif);
}

#hyd-postcard .postcard-sticker-tray > .postcard-hint {
  margin-bottom: 10px;
}

#hyd-postcard summary:focus-visible {
  outline: 2px solid #f2c6e7;
  outline-offset: 2px;
}

#hyd-postcard .postcard-photo-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  font: 14px/1.2 var(--desktop-font,Tahoma,sans-serif);
}

@media (max-width: 760px) {
  #hyd-postcard {
    --postcard-gutter: 12px;
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }

  #hyd-postcard .postcard-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  #hyd-postcard .postcard-form {
    padding: 16px 0 0;
  }

  #hyd-postcard .postcard-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  }

  #hyd-postcard .postcard-actions button {
    min-width: 0;
    min-height: 44px;
    padding: 8px 4px;
  }

  #hyd-postcard #postcard-share {
    grid-column: auto;
  }

  #hyd-postcard .postcard-close {
    width: 44px;
    height: 44px;
  }

  #hyd-postcard h2 {
    font-size: 13px;
  }

  #hyd-postcard .postcard-delivery {
    align-items: center;
    min-height: 34px;
  }

  #hyd-postcard #postcard-status,
  #hyd-postcard #postcard-open {
    font-size: 11px;
  }

  #hyd-postcard .postcard-photo-tools {
    gap: 6px;
  }

  #hyd-postcard .postcard-photo-tools button {
    min-height: 40px;
    padding: 5px 7px;
    font-size: 13px;
  }
}

/* Short landscape screens: tighter footer and titlebar so the work area keeps its room. */
@media (max-height: 450px) {
  #hyd-postcard .postcard-footer {
    padding-top: 8px;
    padding-bottom: 4px;
  }

  #hyd-postcard .postcard-delivery {
    min-height: 20px;
  }

  #hyd-postcard .postcard-titlebar {
    min-height: 44px;
  }

  #hyd-postcard .postcard-layout {
    padding-block: 12px;
  }
}

/* Keep the delivery actions thumb-sized on touchscreens at every width. */
@media (any-pointer: coarse) {
  #hyd-postcard .postcard-actions button {
    min-height: 44px;
  }
}

/* The theme sheet (hyd-theme.css, loaded after this file) also styles the postcard window, so the
   rules below carry the html[data-theme] prefix to win on specificity. */

/* A self-contained sage/forest palette; the desktop's other windows keep their theme. */
html[data-theme] #hyd-postcard {
  --paper-surface: #203328;
  --paper-panel: #2b4333;
  --paper-high: #3a5b42;
  --paper-inset: #13231a;
  --paper-text: #eef5e8;
  --paper-muted: #bbd0b5;
  --paper-edge: #718b72;
  --paper-accent: #b5dba5;
  --metal-top: #eef5e9;
  --metal-mid: #bbcdbb;
  --metal-end: #d4e1cc;
  --metal-ink: #243d2c;
  scrollbar-color: #8faa88 #203328;
}

#hyd-postcard::backdrop {
  background: #09160fba;
}

html[data-theme] #hyd-postcard .postcard-form > label span {
  color: var(--paper-muted);
}

html[data-theme] #hyd-postcard :is(input, textarea)::placeholder {
  color: var(--paper-muted);
  opacity: 1;
}

html[data-theme] #hyd-postcard .postcard-photo-tools button {
  background: linear-gradient(var(--metal-top),var(--metal-mid));
  color: var(--metal-ink);
  border-color: var(--metal-top) var(--paper-edge) var(--paper-edge) var(--metal-top);
}

html[data-theme] #hyd-postcard .postcard-sticker-palette button:not(:disabled):hover {
  border-color: #8daf80;
  background: #8bad7e40;
}

html[data-theme] #hyd-postcard .postcard-sticker-handle[aria-pressed='true'] {
  border-color: #426e48;
  outline-color: #edf5e7;
}

html[data-theme] #hyd-postcard .postcard-sticker-grip-mark {
  border-color: #426e48;
  background: #edf5e7;
}

html[data-theme] #hyd-postcard :is(button, input, textarea, a, summary):focus-visible {
  outline-color: #c8e7b9;
}

html[data-theme] #hyd-postcard .postcard-close:focus-visible {
  outline-color: #305b3c;
}

/* Touch: a 44px press area for the close button wherever the layout keeps it at 36px (landscape phones). */
@media (pointer: coarse) {
  #hyd-postcard .postcard-close {
    position: relative;
  }

  #hyd-postcard .postcard-close::after {
    content: '';
    position: absolute;
    inset: -5px;
  }
}

/* At least a 24px press area for "open image", invisible. */
#hyd-postcard #postcard-open {
  position: relative;
}

#hyd-postcard #postcard-open::after {
  content: '';
  position: absolute;
  inset: -5px 0;
}

/* Phone sheet (--phone-sheet-* in hyd-world.css); only the work area scrolls, as before. */
@media (max-width: 620px) {
  html[data-theme] #hyd-postcard {
    position: fixed;
    inset: auto 8px var(--phone-sheet-bottom) 8px;
    margin: 0;
    width: auto;
    height: var(--phone-sheet-height);
    max-height: none;
  }
}

/* The same theme palette as the photo tools' buttons. */
html[data-theme] #hyd-postcard .postcard-sticker-turn {
  background: linear-gradient(var(--metal-top), var(--metal-mid)) !important;
  border-color: var(--metal-top) var(--paper-edge) var(--paper-edge) var(--metal-top);
  color: var(--metal-ink);
}

/* Touch screens: after "save postcard" the finished PNG also shows under the card, as large as the
   card, so a long press can save it where the download did not start (hyd-postcard.js). */
#hyd-postcard #postcard-saved {
  display: block;
  width: 100%;
  height: auto;
  margin: 4px 0 10px;
}
