:root {
  color-scheme: light;
  --ink: #17223b;
  --muted: #657087;
  --navy: #101b34;
  --navy-soft: #1a2949;
  --gold: #dba84d;
  --gold-light: #f3ce86;
  --cream: #fffaf0;
  --paper: #ffffff;
  --line: #dce1e9;
  --panel: #f8f9fb;
  --focus: #265ebd;
  --danger: #b13b42;
  --shadow: 0 18px 55px rgba(18, 28, 50, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: #edf0f5;
  color: var(--ink);
  font-size: 16px;
}

button, input, select, textarea { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 60%, transparent);
  outline-offset: 2px;
}

.topbar {
  min-height: 68px;
  padding: 12px 22px;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand {
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 2px solid var(--gold-light);
  color: var(--gold-light);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1rem;
  box-shadow: inset 0 0 0 3px var(--navy), inset 0 0 0 4px rgba(243,206,134,.55);
}

.topbar-actions, .toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.privacy-note {
  font-size: .78rem;
  color: #b8c1d1;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.privacy-dot { width: 7px; height: 7px; background: #72d6a0; border-radius: 50%; }

.quality-control { display: inline-flex; align-items: center; gap: 7px; color: #b8c1d1; font-size: .72rem; font-weight: 700; }
.quality-control select { width: auto; min-width: 142px; min-height: 40px; padding: 7px 28px 7px 9px; border-color: #42506c; color: white; background: var(--navy-soft); font-size: .75rem; }

.button, .icon-button, .text-button, .danger-link {
  border: 0;
  border-radius: 8px;
  font-weight: 650;
}

.button {
  min-height: 40px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-primary { background: var(--navy-soft); color: white; border: 1px solid #354564; }
.button-primary:hover { background: #263959; }
.button-accent { background: var(--gold); color: #172036; }
.button-accent:hover { background: #e6b963; }
.button-quiet { background: white; color: var(--ink); border: 1px solid var(--line); }
.topbar .button-quiet { color: #d6deec; background: transparent; border-color: #42506c; }
.button:disabled { opacity: .5; cursor: wait; }

.studio {
  min-height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 260px minmax(430px, 1fr) 300px;
}

.panel {
  background: var(--paper);
  padding: 22px 18px;
  min-width: 0;
  overflow: auto;
}

.data-panel { border-right: 1px solid var(--line); }
.properties-panel { border-left: 1px solid var(--line); }
.studio.data-hidden { grid-template-columns: minmax(430px, 1fr) 300px; }
.studio.layers-hidden { grid-template-columns: 260px minmax(430px, 1fr); }
.studio.data-hidden.layers-hidden { grid-template-columns: minmax(0, 1fr); }
.panel[hidden] { display: none !important; }
.pane-controls { display: flex; gap: 12px; margin-top: 8px; white-space: nowrap; }
.pane-controls button { font-size: .72rem; }
.project-link { margin-top: 24px; font-size: .75rem; }
details > summary { cursor: pointer; font-weight: 650; }
.photo-library > summary { margin-bottom: 10px; }
.shortcut-help { margin-top: 8px; text-align: left; }
.shortcut-help > summary { text-align: center; }
.shortcut-help dl { display: grid; grid-template-columns: minmax(140px, 1fr) 1fr; gap: 8px 16px; max-width: 580px; margin: 16px auto; }
.shortcut-help dt { font-weight: 650; }
.shortcut-help dd { margin: 0; }
.shortcut-help > p { text-align: center; }

.panel-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-heading .eyebrow { flex-basis: 100%; }
h1, h2, p { margin: 0; }
h1, h2 { color: var(--ink); }
h1 { font-size: 1.35rem; }
h2 { font-size: 1rem; }
.eyebrow { color: #a17324; font-size: .72rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.count-pill { margin-left: auto; padding: 4px 8px; font-size: .72rem; color: var(--muted); background: #eef1f5; border-radius: 20px; }

.upload-card {
  border: 1.5px dashed #aeb7c7;
  min-height: 132px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fbfcfe;
  transition: border-color .2s, background .2s;
}

.upload-card:hover { border-color: var(--gold); background: #fffaf1; }
.upload-card strong { color: var(--ink); font-size: .9rem; }
.upload-card span:last-of-type { font-size: .75rem; }
.upload-icon { width: 34px; height: 34px; border-radius: 50%; background: #edf0f5; display: grid; place-items: center; color: var(--ink); }
.text-button { width: 100%; background: none; color: #7e612d; padding: 10px; font-size: .8rem; }

.section-title-row { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 9px; gap: 10px; }
.section-title-row span { color: var(--muted); font-size: .75rem; }
.record-nav { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 6px; }

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  display: grid;
  place-items: center;
}
.icon-button:hover { background: #f3f5f8; }

select, input[type="text"], input[type="number"], textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfd5df;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
}
textarea { resize: vertical; line-height: 1.4; }

.data-table-wrap { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.data-table th, .data-table td { padding: 8px 9px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: top; word-break: break-word; }
.data-table tr:last-child th, .data-table tr:last-child td { border-bottom: 0; }
.data-table th { width: 38%; color: var(--muted); font-weight: 600; background: #fafbfc; }

.placeholder-box { margin-top: 18px; padding: 13px; border-radius: 8px; background: #f3f5f8; }
.placeholder-box h2 { margin-bottom: 9px; }
.placeholder-box p { margin-top: 8px; font-size: .72rem; line-height: 1.45; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid #d5b879; background: #fff8e9; color: #76561d; border-radius: 5px; padding: 4px 6px; font-size: .7rem; font-family: ui-monospace, monospace; }

.github-card { margin-top: 14px; padding: 13px; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px; border: 1px solid #cbd2dd; border-radius: 8px; background: var(--navy); color: white; }
.github-star { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: var(--navy); font-size: 1rem; }
.github-card strong { display: block; color: white; font-size: .78rem; }
.github-card p { margin: 4px 0 8px; color: #b8c1d1; font-size: .7rem; line-height: 1.45; }
.github-card a { color: var(--gold-light); font-size: .74rem; font-weight: 750; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.github-card a:hover { color: white; }

.claims {
  height: 37px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
  scrollbar-width: none;
  background: #f6f8fc;
  border-bottom: 1px solid var(--line);
}
.claims::-webkit-scrollbar { display: none; }
.claim {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.claim-mark {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-size: .6rem;
  font-weight: 800;
}

.video-card { margin-top: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.video-card strong { display: block; font-size: .78rem; }
.video-card p { margin: 4px 0 8px; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.video-card > a { display: inline-block; margin-top: 8px; color: var(--navy); font-size: .74rem; font-weight: 750; text-underline-offset: 3px; }
.video-embed { position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #0b1224; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-facade { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.video-facade img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-play {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(16, 27, 52, .82);
  color: var(--gold-light);
  font-size: .95rem;
  padding-left: 3px;
  transition: transform .15s ease, background .15s ease;
}
.video-facade:hover .video-play { transform: scale(1.08); background: var(--navy); }
.video-facade:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.video-note { margin: 8px 0 0; color: var(--muted); font-size: .66rem; }

.workspace { min-width: 0; display: flex; flex-direction: column; background: #e9edf3; }
.workspace-toolbar { min-height: 74px; padding: 14px 20px; border-bottom: 1px solid #d5dae3; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.workspace-toolbar h2 { margin-top: 3px; font-size: 1.05rem; }
.workspace-toolbar .button { font-size: .78rem; }
.zoom-control { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid #cfd5df; border-radius: 8px; background: #fff; }
.zoom-control button { border: 0; background: none; color: var(--ink); font: inherit; font-size: .75rem; line-height: 1; padding: 6px 7px; border-radius: 6px; cursor: pointer; }
.zoom-control button:hover:not(:disabled) { background: #eef2f8; }
.zoom-control button:disabled { color: #b4bcc9; cursor: default; }
.zoom-step { min-width: 24px; font-weight: 700; }
.zoom-label { min-width: 52px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.zoom-fit { border-left: 1px solid #e3e8ef !important; border-radius: 0 6px 6px 0 !important; color: var(--muted); }
.zoom-control .zoom-fit.active { color: #2d68c4; font-weight: 700; }

.canvas-shell {
  flex: 1;
  min-height: 420px;
  padding: 34px;
  display: grid;
  place-items: safe center;   /* "safe" keeps the top-left reachable when zoomed past the shell */
  overflow: hidden;           /* .zoomed turns this into a scroll container; see fitStage() */
  background-color: #dfe4eb;
  background-image: radial-gradient(#c7ced8 1px, transparent 1px);
  background-size: 18px 18px;
}

.certificate-stage {
  position: relative;
  width: 1200px;
  height: 848px;
  flex: none;
  transform-origin: top left;
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--cream);
  user-select: none;
  touch-action: none;
}

.canvas-shell.zoomed { overflow: auto; }
.canvas-shell.panning { cursor: grabbing; }
.stage-viewport { position: relative; flex: none; }
.stage-viewport .certificate-stage { position: absolute; inset: 0 auto auto 0; }

#backgroundCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#fieldLayer { position: absolute; inset: 0; }
.selection-marquee { position: absolute; border: 1.5px solid #2d68c4; background: rgba(45, 104, 196, .12); pointer-events: none; z-index: 2; }
.multi-selection .canvas-field .resize-handle, .multi-selection .canvas-field .rotate-handle { display: none; }

.canvas-field {
  position: absolute;
  min-height: 24px;
  display: flex;
  align-items: center;
  white-space: pre-wrap;
  line-height: 1.12;
  border: 1px solid transparent;
  padding: 2px;
  cursor: move;
}

.canvas-field.selected { border: 2px solid #2d68c4; background: rgba(230, 240, 255, .16); padding: 1px; }
.canvas-field.image-field { min-height: 20px; padding: 0; align-items: stretch; }
.canvas-field.image-field.selected { padding: 0; background: rgba(230, 240, 255, .16); }
.canvas-field.image-field img { width: 100%; height: 100%; display: block; object-fit: contain; pointer-events: none; }
.resize-handle { display: none; position: absolute; width: 15px; height: 15px; right: -8px; bottom: -8px; border: 2px solid white; background: #2d68c4; border-radius: 3px; cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.canvas-field.selected .resize-handle { display: block; }
.rotate-handle { display: none; position: absolute; width: 14px; height: 14px; left: 50%; top: -28px; margin-left: -7px; border: 2px solid white; background: #2d68c4; border-radius: 50%; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.rotate-handle::before { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 14px; margin-left: -1px; background: #2d68c4; }
.rotate-handle:active { cursor: grabbing; }
.rotate-handle.below { top: auto; bottom: -28px; }
.rotate-handle.below::before { top: auto; bottom: 100%; }
.canvas-field.selected .rotate-handle { display: block; }
.canvas-help { min-height: 40px; text-align: center; padding: 10px 20px; color: var(--muted); font-size: .76rem; border-top: 1px solid #d5dae3; }

.layer-actions { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.properties-actions { display: flex; align-items: center; gap: 12px; }
.layer-add-button { min-height: 34px; padding: 6px 8px; font-size: .7rem; cursor: pointer; }
.layers { display: flex; flex-direction: column; gap: 5px; padding-bottom: 14px; border-bottom: 1px solid var(--line); max-height: 200px; overflow: auto; }
.layer-button { width: 100%; border: 1px solid transparent; background: transparent; color: var(--ink); min-height: 42px; border-radius: 7px; display: grid; grid-template-columns: 30px minmax(0,1fr); align-items: center; text-align: left; padding: 6px; gap: 7px; }
.layer-button:hover { background: #f4f6f9; }
.layer-row { display: grid; grid-template-columns: minmax(0, 1fr) 28px 28px; align-items: center; gap: 3px; }
.layer-move { border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); min-height: 30px; cursor: pointer; }
.layer-move:hover:not(:disabled) { background: #eef3fb; }
.layer-move:disabled { opacity: .35; cursor: default; }
.layer-button.selected { background: #eef3fb; border-color: #b6c8e5; }
.layer-icon { width: 28px; height: 28px; border-radius: 5px; display: grid; place-items: center; background: white; border: 1px solid var(--line); font-family: Georgia, serif; font-weight: 700; }
.layer-copy { overflow: hidden; }
.layer-copy strong, .layer-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-copy strong { font-size: .77rem; }
.layer-copy span { font-size: .68rem; color: var(--muted); margin-top: 2px; }

.properties-heading { margin-top: 14px; }
.danger-link { background: none; color: var(--danger); padding: 4px; font-size: .73rem; }
.field-form { padding-bottom: 15px; }
.form-label, fieldset legend { display: block; margin: 9px 0 5px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 9px; }
.unit-input, .color-input { position: relative; display: flex; }
.font-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
.font-upload-button { min-height: 38px; padding: 8px 9px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #cfd5df; border-radius: 7px; color: #76561d; background: #fff8e9; font-size: .7rem; font-weight: 750; white-space: nowrap; cursor: pointer; }
.font-upload-button:hover { border-color: var(--gold); background: #fff2d8; }
.font-hint { display: block; min-height: 16px; margin-top: 4px; color: var(--muted); font-size: .64rem; line-height: 1.3; }
.font-hint.loaded { color: #42704c; }
.font-hint.error { color: var(--danger); }
.unit-input input { padding-right: 32px; }
.unit-input span { position: absolute; right: 9px; top: 11px; color: var(--muted); font-size: .7rem; }
.color-input { border: 1px solid #cfd5df; border-radius: 7px; overflow: hidden; }
.color-input input[type="color"] { border: 0; width: 38px; min-height: 38px; padding: 4px; background: white; }
.color-input input[type="text"] { border: 0; border-radius: 0; padding-left: 4px; font-size: .75rem; }
.alignment-group { border: 0; padding: 0; margin: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #cfd5df; border-radius: 7px; overflow: hidden; }
.segmented button { min-height: 35px; background: white; border: 0; border-right: 1px solid #cfd5df; font-weight: 700; }
.segmented button:last-child { border-right: 0; }
.segmented button:nth-child(1) { text-align: left; padding-left: 18px; }
.segmented button:nth-child(3) { text-align: right; padding-right: 18px; }
.segmented button.active { background: var(--navy); color: white; }
.positions-grid { grid-template-columns: repeat(3, 1fr); }
.positions-grid input { padding: 7px; }
.positions-grid .rotation-field { grid-column: span 2; }
.positions-grid .unit-input input { padding-right: 26px; }
.positions-grid .unit-input span { top: 8px; right: 8px; }
.image-layer-preview { height: 110px; margin-bottom: 8px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #eef1f5; }
.image-layer-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-edit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.image-edit-actions .button { width: 100%; min-height: 38px; padding: 7px; font-size: .72rem; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; gap: 8px; }
.range-row input { width: 100%; accent-color: var(--navy); }
.range-row output { color: var(--muted); font-size: .72rem; text-align: right; }
.image-layer-hint { margin-top: 10px; color: var(--muted); font-size: .7rem; line-height: 1.45; }

.export-summary { margin-top: 4px; border: 1px solid #d8c08d; background: #fff9ec; border-radius: 8px; padding: 10px; display: flex; gap: 9px; align-items: center; }
.export-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #4e7048; background: #e4f0df; font-weight: 800; }
.export-summary strong, .export-summary span { display: block; }
.export-summary strong { font-size: .78rem; }
.export-summary span { margin-top: 2px; color: var(--muted); font-size: .68rem; }

.restore-banner { position: fixed; z-index: 25; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 10px; border: 1px solid #d8c08d; background: #fff9ec; box-shadow: 0 14px 34px rgba(0,0,0,.22); }
.restore-banner[hidden] { display: none; }
.restore-copy strong { display: block; font-size: .86rem; }
.restore-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; }
.restore-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.restore-actions .button { padding: 7px 12px; font-size: .78rem; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translate(-50%, 30px); padding: 10px 15px; border-radius: 8px; background: var(--navy); color: white; box-shadow: 0 10px 30px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: .85rem; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.progress-overlay { position: fixed; z-index: 30; inset: 0; background: rgba(10,17,32,.7); display: grid; place-items: center; padding: 20px; }
.progress-overlay[hidden] { display: none; }
.progress-card { width: min(360px, 100%); padding: 24px; background: white; border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.progress-card span { color: var(--muted); font-size: .8rem; }
.spinner { width: 36px; height: 36px; border: 4px solid #e3e7ed; border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
.progress-track { width: 100%; height: 6px; border-radius: 5px; background: #e8ebef; overflow: hidden; }
#progressBar { width: 0; height: 100%; background: var(--gold); transition: width .2s; }
@keyframes spin { to { transform: rotate(360deg); } }

.crop-dialog {
  width: min(980px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  background: white;
  box-shadow: 0 28px 80px rgba(4, 10, 22, .42);
}
.crop-dialog::backdrop { background: rgba(7, 13, 27, .76); backdrop-filter: blur(3px); }
.crop-card { padding: 18px; }
.crop-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.crop-heading h2 { margin-top: 3px; font-size: 1.1rem; }
.crop-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: white; font-size: 1.4rem; line-height: 1; }
.crop-workspace { overflow: hidden; border-radius: 9px; background: #111827; }
#cropCanvas { display: block; width: 100%; height: auto; max-height: 52vh; touch-action: none; cursor: move; }
.crop-help { margin: 7px 0 2px; color: var(--muted); font-size: .7rem; }
.crop-controls { display: grid; grid-template-columns: minmax(160px, 1.4fr) repeat(4, minmax(82px, .65fr)); gap: 9px; align-items: end; }
.crop-actions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; margin-top: 15px; }
.crop-actions .button { min-width: 112px; }

/* recipient photo library + per-record photo layers */
.photo-library { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.photo-library-actions { display: grid; gap: 4px; }
.photo-library-actions .button { width: 100%; justify-content: center; }
.photo-library-status { margin: 8px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.photo-library-links { display: flex; gap: 10px; }
.photo-library-links .text-button { width: auto; padding: 6px 0; text-align: left; }
.photo-library-hint { margin: 2px 0 0; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.photo-match-note { margin: 9px 0 0; color: var(--muted); font-size: .7rem; word-break: break-word; }

.canvas-field.photo-field img { object-position: center; }
.canvas-field.shape-field { padding: 0; min-height: 0; }
.canvas-field.shape-field.selected { padding: 0; background: none; }
.canvas-field.shape-field svg { width: 100%; height: 100%; display: block; overflow: visible; pointer-events: none; }
.shape-toggle { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--muted); }
.shape-toggle input { width: 15px; height: 15px; }
.canvas-field.photo-missing { border: 1px dashed #b9c3d4; background: rgba(238, 241, 246, .75); }
.photo-missing-note { width: 100%; color: var(--muted); font-size: .7rem; text-align: center; pointer-events: none; }

.report-dialog { width: min(620px, calc(100vw - 28px)); }
.report-summary { margin: 0 0 10px; font-size: .8rem; }
.report-scroll { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.report-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.report-actions .button { min-width: 112px; }

@media (max-width: 1120px) {
  .studio { grid-template-columns: 230px minmax(420px, 1fr); }
  .studio.data-hidden { grid-template-columns: minmax(0, 1fr); }
  .studio.layers-hidden { grid-template-columns: 230px minmax(420px, 1fr); }
  .studio.data-hidden.layers-hidden { grid-template-columns: minmax(0, 1fr); }
  .properties-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(220px, .7fr) 1.3fr; gap: 20px; }
  .properties-panel > .panel-heading, .properties-panel > .layers { grid-column: 1; }
  .properties-panel > .properties-heading, .properties-panel > .field-form, .properties-panel > .export-summary { grid-column: 2; }
  .properties-panel > .properties-heading { grid-row: 1; align-self: start; }
  .properties-panel > .field-form { grid-row: 2; }
  .properties-panel > .export-summary { align-self: end; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .privacy-note { display: none; }
  .quality-control > span { display: none; }
  .quality-control select { min-width: 116px; }
  .topbar-actions .button-primary { display: none; }
  .studio { display: flex; flex-direction: column; }
  .workspace { order: 1; }
  .data-panel { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .properties-panel { order: 3; display: block; }
  .canvas-shell { min-height: 330px; padding: 18px; }
  .workspace-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-group { justify-content: flex-start; }
  .data-panel, .properties-panel { overflow: visible; }
  .topbar .button-accent { padding: 8px 10px; font-size: .78rem; }
  .crop-controls { grid-template-columns: repeat(2, 1fr); }
  .crop-controls label:first-child { grid-column: 1 / -1; }
  .crop-actions { grid-template-columns: 1fr 1fr; }
  .crop-actions span { display: none; }
  .crop-actions .button { min-width: 0; }
}

@media (max-width: 440px) {
  .topbar { padding: 10px 12px; }
  .brand span:last-child { display: none; }
  .canvas-help { font-size: .7rem; }
  .form-grid { grid-template-columns: 1fr; }
  .positions-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
