:root {
  --bg: #fffaf7;
  --panel: #fff;
  --text: #302b45;
  --muted: #898398;
  --accent: #8b6ee8;
  --accent-dark: #7254d2;
  --soft: #f3efff;
  --border: #eee7eb;
  --image-bg: #f7f2f4;
  --shadow-sm: 0 8px 24px rgba(99, 72, 132, .06);
  --shadow-md: 0 16px 30px rgba(99, 72, 132, .13);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 17px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 8% 0%, #eee7ff 0, transparent 28rem),
    radial-gradient(circle at 100% 12%, #ffe7df 0, transparent 24rem),
    radial-gradient(circle at 50% 100%, #e8f7f0 0, transparent 26rem);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.hidden {
  display: none !important;
}

.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;
}

/* Layout and shared controls */

.container {
  position: relative;
  max-width: 1080px;
  padding: 56px 24px 80px;
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 48px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.logo-placeholder,
.brand-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #b38cf4);
  color: #fff;
}

.logo-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 1.2rem;
}

.language-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  color: var(--text);
  font-size: .78rem;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(99, 72, 132, .08);
  transition: transform .15s ease, background .15s ease;
}

.language-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.header-search-form {
  position: relative;
  display: flex;
  flex: 1;
  max-width: 560px;
}

.header-search {
  width: 100%;
  padding: 12px 48px 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: 0;
  background: rgba(255, 255, 255, .85);
  color: var(--text);
}

.header-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 110, 232, .14);
}

.header-search-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 1.25rem;
}

.search-suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: 0 14px 30px rgba(99, 72, 132, .14);
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.suggestion:hover {
  background: var(--soft);
}

.suggestion img {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--image-bg);
}

.btn {
  appearance: none;
  padding: 11px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: .9rem;
  font-weight: 700;
  transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(99, 72, 132, .1);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #a078eb);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-dark), #9068df);
}

/* Home page */

.hero {
  max-width: 720px;
  margin: 0 auto 34px;
  text-align: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(139, 110, 232, .24);
  font-size: 1.45rem;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -.055em;
}

h1 span {
  color: var(--accent);
}

.intro {
  max-width: 550px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.search-panel {
  max-width: 820px;
  padding: 14px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 24px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 18px 55px rgba(99, 72, 132, .1);
  backdrop-filter: blur(12px);
}

.upload-area {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 120px;
  padding: 20px 22px;
  border: 1.5px dashed #d9cfee;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fffdfd, #f8f4ff);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.upload-area:hover,
.upload-area:focus-visible {
  border-color: var(--accent);
  outline: 0;
  background: linear-gradient(135deg, #fff, #f4efff);
  transform: translateY(-1px);
}

.upload-area.drag-over {
  border-color: var(--accent);
  background: linear-gradient(135deg, #f8f3ff, #eee8ff);
  box-shadow: inset 0 0 0 2px rgba(139, 110, 232, .12);
}

.upload-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #f1ebff;
  color: #8061d8;
  font-size: 1.8rem;
  font-weight: 300;
}

.upload-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
}

.upload-copy strong {
  font-size: 1rem;
}

.upload-copy span {
  color: var(--muted);
  font-size: .85rem;
}

.status {
  max-width: 820px;
  min-height: 1.3em;
  margin: 14px auto 0;
  color: var(--muted);
  text-align: center;
}

.status.error {
  color: #d46d72;
}

.preview-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: #fff;
}

.preview-wrap img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--soft);
}

.preview-query {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.preview-info {
  min-width: 0;
}

.preview-label {
  display: block;
  color: var(--muted);
  font-size: .75rem;
}

.query-name {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: .9rem;
  font-weight: 700;
}

.remove-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #ffe3e4;
  color: #d05261;
  font-size: 1.45rem;
  line-height: 1;
  transition: background .15s ease, transform .15s ease;
}

.remove-btn:hover {
  background: #ffd0d3;
  transform: scale(1.08);
}

/* Results and cards */

.results {
  margin-top: 56px;
}

.results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.results-heading .eyebrow {
  margin-bottom: 4px;
}

.results h2 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -.03em;
}

.results-note,
.comparison-name,
.filename {
  color: var(--muted);
}

.results-note {
  font-size: .85rem;
}

.comparison {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  max-width: 980px;
  padding: 18px;
  margin: 0 auto 34px;
  border: 1px solid #eadff3;
  border-radius: 24px;
  background: linear-gradient(135deg, #fff, #faf6ff);
  box-shadow: 0 14px 34px rgba(99, 72, 132, .1);
}

.comparison-item {
  min-width: 0;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .8);
}

.comparison-label {
  display: block;
  margin: 0 4px 10px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.comparison-image-wrap,
.card-image-wrap {
  position: relative;
}

.comparison-item img {
  display: block;
  width: 100%;
  height: clamp(270px, 36vw, 440px);
  object-fit: contain;
  border-radius: 12px;
  background: var(--image-bg);
}

.comparison-arrow {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 300;
}

.comparison-match-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 4px 2px;
}

.comparison-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: .82rem;
}

.grid,
.text-results-grid {
  display: grid;
  gap: 18px;
}

.grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.text-results-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-top: 28px;
}

.card,
.text-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}

.card:hover,
.text-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.card {
  display: flex;
  flex-direction: column;
}

.card img,
.text-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--image-bg);
}

.card-body,
.text-card-body {
  padding: 14px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px 14px;
}

.score {
  color: var(--accent);
  font-weight: 800;
}

.filename {
  word-break: break-all;
  font-size: .8rem;
}

.edit-meme-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 50%;
  background: rgba(48, 43, 69, .78);
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  transition: background .15s ease, transform .15s ease;
}

.edit-meme-btn:hover {
  background: var(--accent);
  transform: scale(1.06);
}

.text-results {
  margin-top: 30px;
}

.text-results h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.text-empty {
  margin-top: 28px;
  color: var(--muted);
}

.text-card {
  color: var(--text);
  text-decoration: none;
}

.text-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.text-card p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

/* Results animations */

.results.reveal {
  animation: results-reveal .55s ease-out both;
}

.results.reveal .comparison {
  animation: comparison-reveal .55s .08s ease-out both;
}

.results.reveal .card {
  animation: card-reveal .42s ease-out both;
}

.results.reveal .card:nth-child(2) { animation-delay: .05s; }
.results.reveal .card:nth-child(3) { animation-delay: .1s; }
.results.reveal .card:nth-child(4) { animation-delay: .15s; }
.results.reveal .card:nth-child(5) { animation-delay: .2s; }

.comparison.match-swap .comparison-match {
  animation: match-swap .42s ease-out both;
}

@keyframes results-reveal {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes comparison-reveal {
  from { opacity: 0; transform: scale(.97) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes card-reveal {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes match-swap {
  from { opacity: .35; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Editor */

.editor-modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(20px, 3vw, 48px);
  background: rgba(30, 27, 46, .58);
  backdrop-filter: blur(7px);
}

.editor-exit-confirm {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 27, 46, .42);
}

.editor-exit-confirm-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(24, 18, 45, .28);
}

.editor-exit-confirm-panel h2 {
  margin: 0 0 24px;
  font-size: 20px;
}

.editor-exit-confirm-panel p {
  margin: 8px 0 20px;
  color: var(--muted);
}

.editor-exit-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.editor-exit-confirm-actions button {
  min-width: 80px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.editor-exit-confirm-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.editor-panel {
  position: relative;
  display: grid;
  grid-template-rows: 70px minmax(0, 1fr);
  width: min(1560px, 100%);
  height: 920px;
  min-height: 920px;
  max-height: calc(100vh - 40px);
  padding: 16px 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(24, 18, 45, .36);
  font-family: "Manrope", Arial, sans-serif;
}

.editor-panel::before {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: calc(100% - 404px);
  width: 1px;
  background: var(--border);
  content: "";
  pointer-events: none;
}

.editor-heading {
  display: flex;
  align-items: center;
  align-self: start;
  gap: 18px;
  height: 62px;
  min-height: 62px;
  overflow: hidden;
}

.editor-brand {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 400px;
  gap: 22px;
}

.editor-brand-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eee8ff, #f8f5ff);
  color: var(--accent);
}

.editor-brand-icon svg {
  width: 27px;
  height: 27px;
}

.editor-heading h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 29px;
  letter-spacing: -.02em;
}

.editor-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.editor-zoom {
  position: absolute;
  top: 27px;
  right: 428px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(42, 35, 72, .04);
}

.editor-zoom button,
.editor-zoom span {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 39px;
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  line-height: 20px;
}

.editor-zoom span {
  min-width: 60px;
}

.editor-zoom button:last-child,
.editor-zoom span:last-child {
  border-right: 0;
}

.editor-zoom button:hover {
  background: var(--soft);
  color: var(--accent);
}

.editor-zoom svg {
  width: 16px;
  height: 16px;
}

.editor-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--soft);
  color: var(--text);
}

.editor-workspace {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr) 384px;
  gap: 24px;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.editor-workspace > * {
  min-width: 0;
}

.editor-tools {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 5px;
  padding: 8px 18px 0 0;
}

/* Only text is implemented; other panels remain available for future tools. */
.editor-tools .editor-tool:not([data-editor-tool="text"]) {
  display: none;
}

.editor-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 54px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
}

.editor-tool:hover,
.editor-tool.active {
  border-color: #e4d9ff;
  background: var(--soft);
  color: var(--accent);
}

.editor-tool svg {
  flex: 0 0 22px;
  width: 21px;
  height: 21px;
}

.editor-tool span {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.editor-canvas-wrap {
  position: relative;
  display: grid;
  align-self: stretch;
  place-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: visible;
  border-radius: 14px;
  background: transparent;
}

.editor-canvas-wrap .canvas-container {
  width: auto !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow: hidden;
  aspect-ratio: var(--editor-ratio, 4 / 3);
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 8px 18px rgba(36, 28, 61, .08);
}

.editor-canvas-wrap .canvas-container canvas {
  width: 100%;
  height: 100%;
}

#editor-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 14px;
  background: var(--image-bg);
  cursor: crosshair;
  touch-action: none;
}

.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 14px 20px 16px 24px;
  overflow-y: auto;
}

.editor-tool-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.editor-font-field {
  width: 100%;
}

.editor-field,
.editor-color-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  line-height: 20px;
}

.editor-field input[type="text"],
.editor-field input[type="number"],
.editor-field select {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
}

#editor-panel-text > .editor-field:first-child { order: 1; }
#editor-panel-text > .editor-font-row { order: 2; }
#editor-panel-text > .editor-size-block { order: 4; }
#editor-panel-text > .editor-color-field { order: 5; }
#editor-panel-text > .editor-align-field { display: none; }
#editor-panel-text > .editor-outline-block {
  order: 6;
  grid-template-columns: 1fr 1fr;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
#editor-panel-text > .editor-bg-toggle,
#editor-panel-text > .editor-background { display: none; }
#editor-panel-text > #editor-add { order: 8; margin-top: 5px; }
#editor-panel-text > #editor-delete { order: 9; }

.editor-size-block {
  display: block;
}

.editor-font-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.editor-font-row .editor-font-field {
  min-width: 0;
}

.editor-size-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.editor-size-controls input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 4px;
  accent-color: var(--accent);
}

.editor-px-input {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.editor-px-input input {
  width: 48px;
  height: 39px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  text-align: center;
}

.editor-color-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.editor-color-field input[type="color"],
.editor-background input[type="color"] {
  align-self: auto;
  width: 42px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.editor-options .editor-color-field {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.editor-options .editor-color-field input[type="color"] {
  align-self: flex-start;
}

.editor-style-toggles {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  width: 168px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.editor-toggle-row {
  color: var(--text);
}

.editor-style-control {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font-family: Arial, sans-serif;
  font-size: 20px;
}

.editor-style-control:last-child {
  border-right: 0;
}

.editor-style-control.active {
  background: var(--soft);
  color: var(--accent);
}

.editor-style-control svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  pointer-events: none;
}

.editor-sidebar .btn {
  width: 100%;
  min-height: 48px;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 750;
  line-height: 20px;
}

#editor-delete {
  border-color: var(--border);
  background: #fff;
}

.editor-layers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.editor-layer {
  overflow: hidden;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-layer.active,
.editor-layer:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.editor-layer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.editor-layer-actions .btn {
  min-height: 42px;
  padding: 9px 8px;
  font-size: .78rem;
}

.editor-layer-actions .btn:nth-child(n + 3) {
  grid-column: span 2;
}

.editor-layer-actions svg {
  width: 15px;
  height: 15px;
  vertical-align: middle;
}

.editor-download {
  margin-top: auto !important;
}

.editor-status {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .85rem;
}

.editor-coming-soon {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}

.editor-footer {
  display: none;
}

.editor-object-toolbar {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  width: max-content;
  min-width: 0;
  height: 44px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(35, 29, 50, .14);
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
}

.editor-object-toolbar button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.editor-object-toolbar button:hover {
  background: var(--soft);
  color: var(--accent);
}

.editor-object-toolbar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  pointer-events: none;
}

/* Responsive behavior */

@media (max-width: 980px) {
  .editor-workspace {
    grid-template-columns: 104px minmax(0, 1fr) 300px;
    gap: 14px;
  }

  .editor-tools {
    padding-right: 10px;
  }

  .editor-tool {
    padding: 0 9px;
  }

  .editor-brand {
    min-width: 270px;
  }

  .editor-zoom {
    right: 324px;
  }
}

@media (max-width: 620px) {
  .container {
    padding: 36px 16px 56px;
  }

  .site-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 34px;
  }

  .language-btn {
    top: 14px;
    right: 16px;
  }

  .upload-area,
  .preview-wrap {
    flex-wrap: wrap;
  }

  .upload-copy {
    min-width: calc(100% - 68px);
  }

  .upload-area .btn,
  .preview-wrap .btn {
    width: 100%;
  }

  .results-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .comparison {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .comparison-arrow {
    justify-self: center;
    transform: rotate(90deg);
  }

  .editor-modal {
    padding: 12px;
  }

  .editor-panel {
    height: calc(100vh - 24px);
    min-height: 0;
    max-height: calc(100vh - 24px);
    padding: 16px;
    overflow: auto;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .editor-panel::before {
    display: none;
  }

  .editor-heading {
    flex-wrap: wrap;
    gap: 12px;
  }

  .editor-brand {
    min-width: 0;
    flex: 1 1 100%;
  }

  .editor-zoom {
    position: static;
  }

  .editor-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .editor-canvas-wrap {
    height: auto;
  }

  .editor-canvas-wrap .canvas-container {
    width: 100% !important;
    height: auto !important;
  }

  .editor-tools {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--border);
  }

  .editor-tool {
    min-width: 104px;
  }

  .editor-sidebar {
    gap: 10px;
  }

  #editor-canvas {
    max-height: 55vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .results.reveal,
  .results.reveal .comparison,
  .results.reveal .card,
  .comparison.match-swap .comparison-match {
    animation: none;
  }
}
