:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  /* Spacing scale (4-unit base) for deliberate rhythm. */
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 16px;
  --space-4: 24px;
}

* { box-sizing: border-box; }

/* Disable double-tap-to-zoom (keeps scrolling and pinch-zoom intact). */
* { touch-action: manipulation; }

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding: 0 0 40px;
  overflow-x: hidden;
}

.app-header {
  position: relative;
  padding: 10px 16px 0;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
  /* Keep the centered title clear of the corner buttons. */
  padding: 0 78px;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0 78px;
}

.subtitle-loading {
  visibility: hidden;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 12px;
}

/* Toolbar --------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Compact separation between control groups; each group keeps its own
     tighter internal gap. */
  gap: var(--space-2);
  padding: 4px 0;
  /* Pull up into the stage's shadow padding so controls sit closer to the
     nameplate without clipping the plate's drop shadow. */
  margin: -32px 0 12px;
}

.toolbar-group {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* −/+ control to enlarge the nameplate; shown on touch devices (any
   orientation) and narrow windows via media query below. */
.zoom-control {
  display: none;
}

.zoom-btn {
  font: inherit;
  font-weight: 700;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.zoom-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.zoom-label {
  min-width: 3.5ch;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Write-a-word tool (main screen) --------------------------------------- */
.toolbar-text {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
}

.text-tool {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
}

.text-tool-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.text-tool-input {
  height: 42px;
  flex: 1;
  width: auto;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
}

.text-tool-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.text-tool-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.18);
}

.text-tool-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Text width and justification segmented controls */
.text-size,
.text-align {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}

.size-btn,
.align-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-height: 36px;
}

.size-btn + .size-btn,
.align-btn + .align-btn {
  border-left: 1px solid var(--border);
}

.size-btn:hover,
.align-btn:hover {
  color: var(--text);
}

.size-btn[aria-pressed="true"],
.align-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.align-btn {
  width: 40px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.align-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.shape-tools {
  gap: 8px;
}

.shape-btn,
.history-btn {
  width: 52px;
  min-height: 44px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.history-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shape-btn:hover,
.history-btn:hover:not(:disabled) {
  border-color: var(--muted);
  background: #f6f8fa;
}

.shape-btn:active,
.history-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.shape-btn:focus-visible,
.history-btn:focus-visible {
  outline: 3px solid rgba(9, 105, 218, 0.2);
  outline-offset: 2px;
}

.history-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.toolbar-file-actions {
  gap: 8px;
}

.toolbar-action-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.toolbar-action-button:hover {
  border-color: var(--muted);
  background: #f6f8fa;
}

.toolbar-action-button:active {
  transform: translateY(1px);
}

.toolbar-action-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-action-button:focus-visible {
  outline: 3px solid rgba(9, 105, 218, 0.2);
  outline-offset: 2px;
}

.color-field {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
}

.color-field input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  box-shadow:
    0 1px 2px rgba(31, 35, 40, 0.12),
    0 3px 8px rgba(31, 35, 40, 0.08);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-field input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-field input[type="color"]:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--muted);
  box-shadow:
    0 2px 4px rgba(31, 35, 40, 0.14),
    0 6px 14px rgba(31, 35, 40, 0.12);
}

.color-field input[type="color"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(9, 105, 218, 0.2),
    0 4px 12px rgba(31, 35, 40, 0.12);
}

.appearance-controls {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.header-color-field {
  font-size: 0.65rem;
}

.header-color-field input[type="color"] {
  width: 34px;
  height: 34px;
}

.header-reset {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: #cf222e;
  cursor: pointer;
}

.header-reset:hover {
  border-color: #cf222e;
  background: rgba(207, 34, 46, 0.06);
}

.header-reset:focus-visible {
  outline: 3px solid rgba(207, 34, 46, 0.2);
  outline-offset: 2px;
}

.header-reset svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 520px) {
  .app-header {
    padding: 10px 12px 0;
  }

  .app-header h1 {
    padding: 2px 48px 0;
    font-size: clamp(1.05rem, 5vw, 1.2rem);
    text-align: center;
    white-space: nowrap;
  }

  .subtitle {
    margin-top: 6px;
    padding: 0;
  }

  .appearance-controls {
    position: static;
    justify-content: center;
    margin-top: 10px;
  }
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-ghost { color: var(--muted); }

/* Compact square arrow buttons for the column-shift control. */
.btn-arrange {
  width: 44px;
  height: 44px;
  padding: 0;
  min-width: 44px;
  line-height: 1;
}

/* Palette --------------------------------------------------------------- */
/* Fixed 8-across grid so all swatches stay on one row and never orphan-wrap;
   width is capped so they don't balloon on desktop and centered by the group. */
.toolbar-colors {
  width: 100%;
  flex-wrap: nowrap;
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  align-items: start;
  gap: var(--space-2);
  width: 100%;
  max-width: 680px;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0 auto;
}

.visually-hidden-color {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.swatch-wrap {
  position: relative;
  min-width: 0;
}

.swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform 0.16s cubic-bezier(0.2, 0.7, 0.2, 1),
    box-shadow 0.16s ease, opacity 0.16s ease, filter 0.16s ease;
}

.add-color {
  border-style: dashed;
  background: var(--panel);
  color: var(--muted);
  font-size: 1.6rem;
  font-weight: 400;
  padding-bottom: 3px;
}

.remove-color {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  padding: 0 0 2px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.swatch[aria-pressed="true"] + .remove-color {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.remove-color:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* Recede the unselected swatches so the active one clearly stands out. */
.swatch:not([aria-pressed="true"]) {
  opacity: 0.45;
  filter: saturate(0.9);
  transform: scale(0.94);
}

.swatch:not([aria-pressed="true"]):hover {
  opacity: 0.8;
  transform: scale(0.97) translateY(-1px);
}

/* Active color = the picked-up paint: lift it well above the receded row with
   a strong shadow so the selection is unmistakable, not just a thin border. */
.swatch[aria-pressed="true"] {
  transform: translateY(-6px) scale(1.16);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
  border-color: rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.add-color:not([aria-pressed="true"]) {
  opacity: 1;
  filter: none;
  transform: none;
}

.add-color:not([aria-pressed="true"]):hover {
  opacity: 1;
  transform: translateY(-1px);
}

.swatch .count {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  line-height: 1;
}

/* Immediate hover tooltip (no delay). */
.swatch:hover::after,
.swatch:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2328;
  color: #fff;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* Hint ------------------------------------------------------------------ */
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 4px 0 12px;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.85em;
}

@media (hover: none) {
  .hint-desktop { display: none; }
}

/* Stage / plate --------------------------------------------------------- */
/* Full-bleed so the plate can grow to the full page width. */
.stage-wrap {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  /* Pull up into the header so the nameplate sits closer to the subtitle,
     while the stage keeps its top padding as shadow room. */
  margin-top: -14px;
  padding: 0;
}

.stage {
  display: flex;
  align-items: flex-start;
  justify-content: safe center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  outline: none;
  border-radius: 8px;
  /* Hide the horizontal scrollbar while keeping scroll/pan on narrow screens. */
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Vertical room for the plate's drop shadow (offset 12 + blur 30 ≈ 42px
     below); horizontal kept small so the plate can use nearly the full width. */
  padding: 22px 12px 48px;
}

/* On phones, use nearly the full screen width for the nameplate. */
@media (max-width: 640px) {
  .stage {
    padding-left: 5px;
    padding-right: 5px;
  }
}

/* Show the −/+ zoom control on touch devices in any orientation (portrait or
   landscape phones exceed 640px wide when rotated) as well as narrow windows. */
@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  .zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .toolbar {
    gap: 8px;
    margin-top: -36px;
    margin-bottom: 0;
  }

  .toolbar-colors {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-2) 8px;
  }

  .palette {
    grid-column: 1 / -1;
    grid-row: 1;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    max-width: none;
  }

  #shift-left {
    grid-column: 3;
    grid-row: 2;
    width: 100%;
  }

  #shift-right {
    grid-column: 4;
    grid-row: 2;
    width: 100%;
  }

  .toolbar-text {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    max-width: none;
  }

  .text-tool {
    grid-column: 1 / -1;
  }

  .text-tool-input {
    width: 100%;
  }

  .text-size {
    width: 100%;
    min-width: 0;
  }

  .size-btn {
    flex: 1 1 0;
    padding-right: 10px;
    padding-left: 10px;
  }

  .text-align {
    width: auto;
  }

  .toolbar + .inspiration-section {
    margin-top: 8px;
  }
}

@media (max-width: 360px) {
  .toolbar-text {
    grid-template-columns: 1fr;
  }

  .text-size,
  .text-align {
    width: 100%;
  }

  .align-btn {
    flex: 1 1 0;
  }
}

/* WebKit: hide the horizontal scrollbar on the stage. */
.stage::-webkit-scrollbar {
  display: none;
}

.nameplate {
  --nameplate-cell: 20px;
  --nameplate-gap: 4px;
  --nameplate-pad: 22px;
  --nameplate-logo-size: 164px;
  --nameplate-grid-width: 1244px;
  --nameplate-grid-height: 164px;
  --nameplate-width: 1474px;
  --nameplate-height: 208px;
  --nameplate-radius: 16px;
  --nameplate-cell-radius: 4px;
  --nameplate-line: 1px;
  --nameplate-highlight-inner: 2px;
  --nameplate-highlight-outer: 4px;
  --nameplate-plate-color: #000000;
  --nameplate-label-color: #ffffff;
  --nameplate-logo-color: #ffffff;
  --nameplate-empty-color: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--nameplate-pad);
  width: var(--nameplate-width);
  height: var(--nameplate-height);
  background:
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.12),
      rgba(255, 255, 255, 0) 42%,
      rgba(0, 0, 0, 0.18)
    ),
    var(--nameplate-plate-color);
  padding: var(--nameplate-pad);
  border-radius: var(--nameplate-radius);
  box-shadow:
    0 calc(var(--nameplate-cell) * 0.6)
      calc(var(--nameplate-cell) * 1.5) rgba(0, 0, 0, 0.38),
    0 calc(var(--nameplate-cell) * 0.1)
      calc(var(--nameplate-cell) * 0.3) rgba(0, 0, 0, 0.25),
    inset 0 var(--nameplate-line) 0 rgba(255, 255, 255, 0.08);
}

.nameplate-no-shadow {
  box-shadow:
    inset 0 var(--nameplate-line) 0 rgba(255, 255, 255, 0.08);
}

.nameplate-logo {
  width: var(--nameplate-logo-size);
  height: var(--nameplate-logo-size);
  flex: 0 0 auto;
  background-color: var(--nameplate-logo-color);
  -webkit-mask: url("github-mark-white.svg") center / contain no-repeat;
  mask: url("github-mark-white.svg") center / contain no-repeat;
}

.nameplate-grid-area {
  position: relative;
  flex: 0 0 auto;
  width: var(--nameplate-grid-width);
  height: var(--nameplate-grid-height);
}

.nameplate-column-numbers {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  display: grid;
  grid-template-columns: repeat(52, var(--nameplate-cell));
  grid-template-rows: var(--nameplate-pad);
  column-gap: var(--nameplate-gap);
  height: var(--nameplate-pad);
  color: var(--nameplate-label-color);
  font-size: calc(var(--nameplate-cell) * 0.55);
  font-weight: 700;
  line-height: var(--nameplate-pad);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.nameplate-column-numbers[hidden] {
  display: none;
}

.nameplate-column-number {
  grid-column: var(--column);
  grid-row: 1;
  justify-self: center;
}

.nameplate-grid {
  display: grid;
  width: var(--nameplate-grid-width);
  height: var(--nameplate-grid-height);
  grid-template-rows: repeat(7, var(--nameplate-cell));
  grid-auto-flow: column;
  grid-auto-columns: var(--nameplate-cell);
  gap: var(--nameplate-gap);
  user-select: none;
  -webkit-user-select: none;
}

.nameplate-cell {
  display: block;
  width: var(--nameplate-cell);
  height: var(--nameplate-cell);
  border-radius: var(--nameplate-cell-radius);
  background: var(--nameplate-empty-color);
  box-shadow:
    inset var(--nameplate-line) var(--nameplate-line)
      calc(var(--nameplate-line) * 2) rgba(0, 0, 0, 0.6),
    inset calc(var(--nameplate-line) * -1)
      calc(var(--nameplate-line) * -1) var(--nameplate-line)
      rgba(255, 255, 255, 0.12);
  padding: 0;
  border: none;
}

.nameplate-cell:is(button) {
  cursor: pointer;
}

.nameplate-cell:is(button):hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.nameplate-cell:focus { outline: none; }

.nameplate-cell.filled {
  box-shadow:
    inset 0 calc(var(--nameplate-cell) * 0.06)
      calc(var(--nameplate-cell) * 0.06)
      rgba(255, 255, 255, 0.22),
    inset 0 calc(var(--nameplate-cell) * -0.06)
      calc(var(--nameplate-cell) * 0.06)
      rgba(0, 0, 0, 0.28),
    0 calc(var(--nameplate-cell) * 0.03)
      calc(var(--nameplate-cell) * 0.06) rgba(0, 0, 0, 0.3);
}

.nameplate-cell.highlight {
  box-shadow:
    0 0 0 var(--nameplate-highlight-inner) #fff,
    0 0 0 var(--nameplate-highlight-outer) var(--accent);
}

.nameplate-flat-cells .nameplate-cell {
  box-shadow: none;
}

.nameplate-hide-empty .nameplate-cell:not(.filled) {
  visibility: hidden;
}

.nameplate[aria-hidden="true"] {
  pointer-events: none;
}

/* Inspiration ---------------------------------------------------------- */
.inspiration-section {
  margin: 32px auto 0;
  padding: 24px 0 8px;
  border-top: 1px solid var(--border);
}

.section-heading {
  text-align: center;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.inspiration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.inspiration-card {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 50px;
}

.inspiration-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.inspiration-preview {
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  contain: layout paint;
}

.inspiration-status {
  grid-column: 1 / -1;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.saved-design-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 0;
}

.saved-designs-section.has-saved-designs .saved-design-actions {
  margin-bottom: 18px;
}

.save-design-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 126px;
  min-height: 46px;
  padding: 9px 22px;
  border: 1px solid #075bbd;
  border-radius: 12px;
  background: linear-gradient(180deg, #218bff 0%, var(--accent) 100%);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 4px 10px rgba(9, 105, 218, 0.24);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

.save-design-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 6px 14px rgba(9, 105, 218, 0.3);
}

.save-design-button:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 2px 5px rgba(9, 105, 218, 0.22);
}

.save-design-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.save-design-button:focus-visible,
.saved-design-download:focus-visible,
.saved-design-delete:focus-visible {
  outline: 3px solid rgba(9, 105, 218, 0.3);
  outline-offset: 2px;
}

.save-design-button-secondary {
  border-color: var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(31, 35, 40, 0.12);
}

.save-design-button-secondary:hover {
  border-color: var(--muted);
  background: #f6f8fa;
  box-shadow: 0 4px 10px rgba(31, 35, 40, 0.16);
}

.saved-design-item {
  display: grid;
  grid-template-columns: 15% 35% 35% 15%;
  gap: 0;
  min-width: 0;
}

.saved-design-item .inspiration-card {
  grid-column: 1 / -1;
}

.saved-design-item .inspiration-preview {
  border-radius: 8px 8px 0 0;
}

.saved-design-download,
.saved-design-delete {
  width: 100%;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.saved-design-delete {
  grid-column: 3;
  border-left: 0;
  border-radius: 0 0 8px 0;
  padding-bottom: 2px;
  color: #cf222e;
}

.saved-design-download {
  grid-column: 2;
  border-radius: 0 0 0 8px;
}

.saved-design-download svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.saved-design-download:hover {
  background: var(--accent);
  color: #fff;
}

.saved-design-delete:hover {
  background: #cf222e;
  color: #fff;
}

/* Hamburger menu button (top-left of header) --------------------------- */
.menu-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.menu-btn:hover {
  border-color: var(--muted);
}

/* Side menu (drawer) --------------------------------------------------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(88vw, 340px);
  background: var(--panel);
  box-shadow: 2px 0 28px rgba(0, 0, 0, 0.2);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.drawer-close {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}

.drawer-close:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 24px;
}

.drawer-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.drawer-section:last-child {
  border-bottom: none;
}

.drawer-section h3 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.drawer-instructions p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.drawer-instructions p:last-child {
  margin-bottom: 0;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 4px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.toggle-item input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  cursor: pointer;
  transition: background 0.16s ease;
}

.toggle-item input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(31, 35, 40, 0.35);
  transition: transform 0.16s ease;
}

.toggle-item input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle-item input:checked::after {
  transform: translateX(18px);
}

.toggle-item input:focus-visible {
  outline: 3px solid rgba(9, 105, 218, 0.3);
  outline-offset: 2px;
}

/* Full-width action items in the drawer */
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.menu-item:first-of-type {
  margin-top: 0;
}

.menu-item svg {
  flex: 0 0 auto;
}

.menu-item:hover {
  border-color: var(--muted);
}
