/* ==========================================================================
   UI refresh — header toolbar buttons + bug report / download popups.
   Loaded after styles.css and report-bug-button.css so these rules win the
   cascade without needing !important. Reuses the same design tokens
   (--ink, --muted, --line, --blue, --accent) already defined in styles.css.
   ========================================================================== */

/* ---------- Header toolbar ----------
   Understated, rounded-lg buttons (8px), one shared neutral border and
   a quiet gray hover fill — no shadows, no pill shapes. Download is the
   only filled/primary one. */

.topbar-actions {
  gap: 8px;
}

.topbar-actions > .select-label,
.topbar-actions > .ghost-button,
#downloadMenu .download-menu-trigger,
.dl-report-bug-button {
  min-height: 38px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.topbar-actions .button-icon,
.editor-sheet-control .sheet-gear,
.dl-report-bug-button__icon {
  width: 15px;
  height: 15px;
}

/* Sheet / Auto select */
.editor-sheet-control.select-label {
  padding-left: 12px;
  border: 1px solid #e5e5e0;
  background: #ffffff;
  color: #30302e;
  box-shadow: none;
}

.editor-sheet-control.select-label:hover {
  border-color: #d4d4d0;
  background: #f7f7f5;
}

.editor-sheet-control .sheet-gear {
  color: #78766f;
}

.topbar-actions > .select-label select {
  height: 36px;
  min-width: 0;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: #30302e;
  font-weight: 500;
  padding: 0 22px 0 6px;
}

/* Reset */
#resetTemplate.ghost-button {
  border: 1px solid #e5e5e0;
  background: #ffffff;
  color: #30302e;
  box-shadow: none;
}

#resetTemplate.ghost-button:hover {
  border-color: #d4d4d0;
  background: #f7f7f5;
}

/* Download — the one filled, primary action */
#downloadMenu .download-menu-trigger {
  padding: 0 18px;
  border: 1px solid transparent;
  background: var(--blue, #2563eb);
  color: #ffffff;
  box-shadow: none;
  font-weight: 500;
}

#downloadMenu .download-menu-trigger:hover {
  background: #1d4ed8;
}

.download-menu-panel {
  border-radius: 12px;
  padding: 8px;
}

/* Report bug */
.dl-report-bug-button {
  border: 1px solid #e5e5e0;
  background: #ffffff;
  color: #30302e;
  box-shadow: none;
}

.dl-report-bug-button:hover,
.dl-report-bug-button:focus-visible {
  border-color: #d4d4d0;
  background: #f7f7f5;
  color: #30302e;
  outline: none;
}

/* ==========================================================================
   Report a Bug dialog
   ========================================================================== */

.dl-bug-dialog {
  width: min(460px, calc(100vw - 32px));
  border-radius: 16px;
  box-shadow: 0 24px 55px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

/* ---- Hero header ---- */
.dl-bug-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 52px 20px 22px;
  background: linear-gradient(155deg, #171f36 0%, #10162a 100%);
  overflow: hidden;
}

.dl-bug-hero__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.dl-bug-hero__icon svg {
  width: 22px;
  height: 22px;
}

.dl-bug-hero__copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.dl-bug-hero__copy h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
}

.dl-bug-hero__copy p {
  margin: 4px 0 0;
  color: #aab2cc;
  font-size: 0.78rem;
  line-height: 1.4;
}

.dl-bug-hero__deco {
  position: absolute;
  right: 72px;
  bottom: 12px;
  opacity: 0.9;
  pointer-events: none;
}

.dl-bug-hero .dl-bug-dialog__close {
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: none;
}

.dl-bug-hero .dl-bug-dialog__close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.dl-bug-hero .dl-bug-dialog__close svg {
  width: 13px;
  height: 13px;
}

/* ---- Step indicator ---- */
.dl-bug-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-bottom: 1px solid #eef1f7;
  background: #fbfcfe;
}

.dl-bug-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #aab0bf;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.dl-bug-step.is-active {
  color: var(--ink, #172033);
}

.dl-bug-step__num {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1.5px solid #d7dee8;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 700;
}

.dl-bug-step.is-active .dl-bug-step__num {
  border-color: var(--blue, #2563eb);
  background: var(--blue, #2563eb);
  color: #ffffff;
}

.dl-bug-step__line {
  flex: 1 1 auto;
  height: 1px;
  background: #e2e8f0;
}

/* ---- Body / fields ---- */
.dl-bug-dialog__header,
.dl-bug-dialog__body,
.dl-bug-dialog__actions {
  padding-inline: 22px;
}

.dl-bug-dialog__body {
  padding-block: 16px 4px;
}

.dl-bug-grid {
  gap: 6px 10px;
}

.dl-bug-field {
  gap: 6px;
  margin-bottom: 12px;
}

.dl-bug-field > span:not(.dl-bug-input-icon) {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink, #172033);
}

.dl-bug-field > span:not(.dl-bug-input-icon) small {
  font-weight: 500;
  color: #94a3b8;
}

.dl-bug-field input,
.dl-bug-field select,
.dl-bug-field textarea {
  min-height: 38px;
  border-color: #dbe3ee;
  border-radius: 9px;
  background: #ffffff;
  font-size: 0.83rem;
  padding: 8px 11px;
  box-shadow: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.dl-bug-field textarea {
  min-height: 76px;
}

.dl-bug-field input:hover,
.dl-bug-field select:hover,
.dl-bug-field textarea:hover {
  border-color: #b9c3d1;
}

.dl-bug-field input:focus,
.dl-bug-field select:focus,
.dl-bug-field textarea:focus {
  border-color: var(--blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dl-bug-input-icon {
  position: relative;
  display: block;
}

.dl-bug-input-icon > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.dl-bug-input-icon input,
.dl-bug-input-icon select {
  width: 100%;
  padding-left: 33px;
}

/* ---- Upload dropzone ---- */
.dl-bug-upload {
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  padding: 16px 12px;
  border-radius: 10px;
  border-width: 1.5px;
  text-align: center;
}

.dl-bug-upload__icon {
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  color: #94a3b8;
}

.dl-bug-upload strong {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink, #172033);
}

.dl-bug-upload small {
  font-size: 0.72rem;
  color: #94a3b8;
}

.dl-bug-upload.is-dragover {
  border-color: var(--blue, #2563eb);
  background: #eef4ff;
}

/* ---- Checkbox row ---- */
.dl-bug-check {
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef4ff;
}

.dl-bug-check__copy {
  display: grid;
  gap: 1px;
  color: var(--ink, #172033);
  font-size: 0.78rem;
  line-height: 1.3;
}

.dl-bug-check__copy small {
  color: #6b7a94;
  font-size: 0.7rem;
  font-weight: 400;
}

.dl-bug-check__badge {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  color: var(--blue, #2563eb);
}

.dl-bug-dialog__status {
  min-height: 0;
  margin-top: 0;
}

.dl-bug-dialog__status:not(:empty) {
  min-height: 18px;
  margin-top: 8px;
}

/* ---- Actions ---- */
.dl-bug-dialog__actions {
  border-top: 1px solid #eef1f7;
  padding-block: 14px 18px;
}

.dl-bug-action {
  min-height: 38px;
  border-radius: 9px;
  padding: 0 16px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: none;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.dl-bug-action:not(.dl-bug-action--primary) {
  border-color: transparent;
  background: transparent;
  color: var(--muted, #667085);
}

.dl-bug-action:not(.dl-bug-action--primary):hover {
  background: var(--surface-soft, #f8fafc);
  color: var(--ink, #172033);
}

.dl-bug-action--primary {
  gap: 8px;
  background: var(--blue, #2563eb);
  border-color: var(--blue, #2563eb);
}

.dl-bug-action--primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

/* ==========================================================================
   Bug report success / confirmation state
   ========================================================================== */

.dl-bug-success {
  padding: 34px 26px 24px;
  text-align: center;
}

/* The close (X) button is an absolutely-positioned sibling that comes
   before this block in the DOM — without a z-index it can end up
   painted underneath this block and swallow clicks, since two
   position:relative/absolute siblings stack in DOM order by default. */
.dl-bug-dialog__close {
  z-index: 2;
}

.dl-bug-success__icon {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  background: linear-gradient(155deg, #22c58b 0%, #0f9d6e 100%);
  color: #ffffff;
  box-shadow: 0 0 0 10px rgba(16, 185, 129, 0.08);
}

.dl-bug-success__icon svg {
  width: 24px;
  height: 24px;
}

.dl-bug-success__spark {
  position: absolute;
  border-radius: 2px;
  transform: rotate(45deg);
}

.dl-bug-success__spark--1 {
  top: -14px;
  left: -22px;
  width: 8px;
  height: 8px;
  background: #34d399;
}

.dl-bug-success__spark--2 {
  top: 4px;
  right: -26px;
  width: 6px;
  height: 6px;
  background: #60a5fa;
}

.dl-bug-success__spark--3 {
  bottom: -10px;
  left: -8px;
  width: 5px;
  height: 5px;
  background: #f472b6;
}

.dl-bug-success h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink, #172033);
}

.dl-bug-success p {
  margin: 0 auto;
  max-width: 340px;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--muted, #667085);
}

.dl-bug-success__highlight {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: none;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
}

.dl-bug-success__highlight svg {
  flex: 0 0 auto;
  color: #10b981;
}

.dl-bug-success__next {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #eef1f7;
  text-align: left;
}

.dl-bug-success__next h4 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink, #172033);
}

.dl-bug-timeline {
  position: relative;
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dl-bug-timeline__item {
  position: relative;
  display: flex;
  gap: 12px;
}

.dl-bug-timeline__item:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 26px;
  left: 12px;
  width: 1px;
  height: calc(100% + 2px);
  border-left: 1.5px dashed #dbe3ee;
}

.dl-bug-timeline__icon {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #ffffff;
}

.dl-bug-timeline__icon--blue {
  background: var(--blue, #2563eb);
}

.dl-bug-timeline__icon--purple {
  background: #7c5cff;
}

.dl-bug-timeline__icon--green {
  background: #10b981;
}

.dl-bug-timeline__copy {
  display: grid;
  gap: 1px;
  padding-top: 2px;
}

.dl-bug-timeline__copy strong {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink, #172033);
}

.dl-bug-timeline__copy small {
  font-size: 0.74rem;
  color: var(--muted, #667085);
}

.dl-bug-action--dark {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  background: #10162a;
  border-color: #10162a;
  color: #ffffff;
}

.dl-bug-action--dark:hover {
  background: #060a17;
  border-color: #060a17;
}

.dl-bug-success__footer {
  margin-top: 12px !important;
  color: #94a3b8 !important;
  font-size: 0.74rem !important;
  text-align: center !important;
}

/* ==========================================================================
   Download confirmation popup
   ========================================================================== */

.download-dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 24px 26px 26px;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.14);
}

.download-close {
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  box-shadow: none;
  color: #78766f;
}

.download-close:hover {
  background: #f7f7f5;
  color: #30302e;
}

.download-close svg {
  width: 14px;
  height: 14px;
}

.download-illustration {
  width: 128px;
  margin-bottom: 6px;
}

.download-status h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.download-status p,
.download-status-started p,
.download-started-copy {
  font-size: 0.83rem !important;
  line-height: 1.5 !important;
}

.download-note {
  gap: 10px;
  margin-top: 16px !important;
  padding: 12px 14px;
  border: 1px solid #e5e5e0;
  border-radius: 10px;
  background: #f7f7f5;
  box-shadow: none;
}

.download-note span {
  width: 26px;
  height: 26px;
  background: var(--blue, #2563eb);
  font-size: 0.8rem;
}

.download-note p {
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  color: #44433f !important;
}

.download-actions {
  gap: 10px;
  margin-top: 18px;
}

.coffee-button,
.download-later {
  min-height: 40px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.coffee-button {
  border-color: #fbcf6b;
  background: #ffd76a;
  color: #4a3300;
  box-shadow: none;
}

.coffee-button:hover {
  background: #ffcd47;
}

.coffee-icon {
  width: 22px;
  height: 22px;
}

.download-later {
  border-color: #e5e5e0;
  background: #ffffff;
  color: #30302e;
  box-shadow: none;
}

.download-later:hover {
  border-color: #d4d4d0;
  background: #f7f7f5;
}

/* ==========================================================================
   Active dimension highlight on the CANVAS — when a dimension field gets
   focus (sidebar or the on-canvas editor itself), its measurement overlay
   (.param-highlight-overlay.is-active-dimension, set by applyParamHighlight
   in app.js) gets a glow so it's obvious which arrow/value on the drawing
   corresponds to the field being edited. The other persistent dimensions
   dim slightly so the active one stands out.
   ========================================================================== */

.param-highlight-overlay {
  transition: opacity 0.18s ease;
}

.param-highlight-overlay.is-dimmed-dimension {
  opacity: 0.4;
}

.param-highlight-overlay.is-active-dimension .param-measure-line {
  /* stroke-width is set inline by app.js on each line/arrowhead, which
     always wins over a stylesheet rule — so the emphasis here comes from
     color + glow only, not a thicker line. */
  stroke: #0f766e;
  filter: drop-shadow(0 0 3px rgba(15, 118, 110, 0.55));
}

.param-highlight-overlay.is-active-dimension .measure-edit-box {
  border-color: #0f766e;
  background: #d3f5e9;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.28), 0 3px 10px rgba(15, 118, 110, 0.24);
  animation: dl-canvas-dimension-pulse 900ms ease-out;
}

@keyframes dl-canvas-dimension-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.55), 0 3px 10px rgba(15, 118, 110, 0.24);
  }
  100% {
    box-shadow: 0 0 0 6px rgba(15, 118, 110, 0), 0 3px 10px rgba(15, 118, 110, 0.24);
  }
}

@media (prefers-reduced-motion: reduce) {
  .param-highlight-overlay.is-active-dimension .measure-edit-box {
    animation: none;
  }
}
