:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-synthesis: none;
  --bg: #0d0f12;
  --panel: rgba(27, 30, 36, 0.92);
  --panel-deep: #12151a;
  --panel-soft: #20242b;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f4ef;
  --muted: #a4a8b0;
  --quiet: #747982;
  --accent: #d9f66f;
  --accent-ink: #11140a;
  --danger: #ff8f8f;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(217, 246, 111, 0.09), transparent 34%),
    radial-gradient(circle at 94% 8%, rgba(109, 166, 246, 0.08), transparent 30%),
    var(--bg);
  letter-spacing: -0.012em;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="color"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.app-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 14px 16px 10px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(22px, 2.2vw, 32px);
  line-height: 1.15;
  font-weight: 720;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 680;
}

.subtitle {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.privacy-badge,
.language-select select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  color: #cbd0d7;
  font-size: 12px;
}

.privacy-badge svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.language-select select {
  appearance: none;
  min-width: 116px;
  padding: 0 34px 0 14px;
  color: var(--text);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 16px,
    calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.workspace {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  padding: 0 16px 88px;
}

.workspace:not(.has-editor) .drop-zone {
  display: flex;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.workspace:not(.has-editor) {
  overflow-y: auto;
}

.workspace.has-editor .drop-zone {
  display: none;
}

.drop-zone {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 126px;
  padding: 24px 28px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(217, 246, 111, 0.035), transparent 42%),
    rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.drop-zone::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: rgba(217, 246, 111, 0.055);
  transition: opacity 160ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.drop-zone.is-dragging::after {
  opacity: 1;
}

.drop-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone h2 {
  margin-bottom: 5px;
  font-size: 18px;
}

.drop-zone p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.drop-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.sample-gallery {
  width: min(720px, 100%);
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sample-heading h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.sample-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--panel-soft);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease;
}

.sample-card:hover:not(:disabled) {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.sample-card:disabled {
  cursor: wait;
  opacity: 0.6;
}

.sample-card img {
  display: block;
  width: 100%;
  height: 112px;
  object-fit: cover;
  object-position: center 32%;
  background: #13e663;
}

.sample-card span {
  display: block;
  padding: 9px 8px 10px;
  font-size: 12px;
  font-weight: 650;
}

.button,
.icon-button,
.text-button,
.background-button {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 17px;
  border-radius: 12px;
  font-weight: 660;
  font-size: 13px;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.button--secondary {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
}

.button--secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.085);
}

.button--primary {
  color: var(--accent-ink);
  background: var(--accent);
}

.button--primary:hover:not(:disabled) {
  background: #e3fa8f;
}

.button--wide {
  width: 100%;
}

.button--compact {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 11px;
}

.button--compact svg {
  width: 16px;
  height: 16px;
}

.editor {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: minmax(220px, 0.68fr) minmax(0, 1fr) minmax(260px, 0.72fr);
  gap: 12px;
}

.panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.panel-kicker {
  margin-bottom: 4px;
  color: var(--quiet);
  font-size: 9px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.icon-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}

.source-stage,
.preview-tile {
  background-color: #808080;
  background-image:
    linear-gradient(45deg, #999 25%, transparent 25%),
    linear-gradient(-45deg, #999 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #999 75%),
    linear-gradient(-45deg, transparent 75%, #999 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.source-stage {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  min-height: 0;
  overflow: auto;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.source-stage.is-eyedropper {
  cursor: crosshair;
}

.source-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.eyedropper-cursor {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px black, 0 2px 8px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
}

.file-facts,
.source-panel .button--wide,
.sample-size-field {
  flex: 0 0 auto;
}

.source-panel {
  overflow: auto;
  overscroll-behavior: contain;
}

.file-facts {
  margin: 12px 0;
}

.file-facts > div,
.diagnostic-card > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
}

.file-facts > div:last-child,
.diagnostic-card > div:last-child {
  border-bottom: 0;
}

.file-facts dt,
.diagnostic-card span {
  color: var(--quiet);
  font-size: 11px;
}

.file-facts dd,
.diagnostic-card strong {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #dadddf;
  font-size: 12px;
  font-weight: 610;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-color-readout {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.color-chip {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: #13e663;
}

.text-button {
  padding: 5px 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.text-button:hover {
  color: var(--text);
}

.preview-panel {
  min-height: 0;
}

.preview-heading,
.background-toolbar {
  flex: 0 0 auto;
}

.preview-heading {
  align-items: flex-end;
}

.preview-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.detail-status {
  max-width: 220px;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--quiet);
  background: rgba(255, 255, 255, 0.035);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-status[data-state="loading"] {
  border-color: rgba(217, 246, 111, 0.28);
  color: var(--accent);
}

.detail-status[data-state="ready"] {
  color: #dcebad;
}

.zoom-control {
  display: grid;
  grid-template-columns: auto minmax(90px, 150px) 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.zoom-control svg {
  width: 17px;
  height: 17px;
}

.zoom-control output {
  font-size: 11px;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 9px 0;
  appearance: none;
  border-radius: 999px;
  background: #40454d;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  appearance: none;
  border: 3px solid var(--panel-deep);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(217, 246, 111, 0.45);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 3px solid var(--panel-deep);
  border-radius: 50%;
  background: var(--accent);
}

.background-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.background-toolbar::-webkit-scrollbar {
  display: none;
}

.background-button {
  display: inline-flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.background-button:hover,
.background-button.is-active {
  border-color: var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.compare-button {
  margin-left: auto;
}

.compare-button svg {
  width: 15px;
  height: 15px;
}

.preview-viewport {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border-radius: var(--radius-md);
  background: #090b0e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.055);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.preview-viewport.is-panning {
  cursor: grabbing;
}

.preview-grid {
  display: grid;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  margin: auto;
  place-items: center;
  padding: 18px;
}

.preview-grid[data-mode="single"] .preview-tile {
  display: none;
}

.preview-grid[data-mode="single"][data-active="checker"] [data-tile="checker"],
.preview-grid[data-mode="single"][data-active="white"] [data-tile="white"],
.preview-grid[data-mode="single"][data-active="gray"] [data-tile="gray"],
.preview-grid[data-mode="single"][data-active="black"] [data-tile="black"] {
  display: grid;
}

.preview-grid[data-mode="compare"] {
  width: 100%;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  align-items: stretch;
  gap: 10px;
}

.preview-tile {
  position: relative;
  width: max-content;
  max-width: none;
  min-height: 200px;
  margin: 0;
  overflow: hidden;
  place-items: center;
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.13);
}

.preview-grid[data-mode="compare"] .preview-tile {
  display: grid;
  width: 100%;
  min-width: 240px;
}

.preview-tile--white {
  background: #fff;
}

.preview-tile--gray {
  background: #808080;
}

.preview-tile--black {
  background: #000;
}

.preview-tile canvas {
  display: block;
  max-width: none;
  image-rendering: auto;
}

.preview-tile.is-detail-ready .result-canvas {
  display: none;
}

.preview-grid[data-mode="compare"] canvas {
  max-width: 100%;
  height: auto;
}

.preview-tile figcaption {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.64);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.controls-panel {
  overflow: auto;
  overscroll-behavior: contain;
}

.field,
.slider-field,
.switch-field {
  display: block;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.field > span,
.slider-label label {
  display: block;
  margin-bottom: 8px;
  color: #d6d8dc;
  font-size: 12px;
  font-weight: 620;
}

.field select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel-deep);
}

.key-list-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-list-field > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sample-size-field {
  min-width: 0;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
}

.sample-size-field legend {
  margin-bottom: 7px;
  color: var(--quiet);
  font-size: 10px;
}

.sample-size-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.sample-size-options label {
  position: relative;
  cursor: pointer;
}

.sample-size-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sample-size-options span {
  display: grid;
  min-height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 10px;
}

.sample-size-options input:checked + span {
  border-color: rgba(217, 246, 111, 0.42);
  color: var(--accent);
  background: rgba(217, 246, 111, 0.08);
}

.sample-size-field p {
  margin: 6px 0 0;
  color: var(--quiet);
  font-size: 10px;
  line-height: 1.45;
}

.key-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 3px 6px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-deep);
}

.key-chip.is-draft {
  border-color: rgba(217, 246, 111, 0.62);
  border-style: dashed;
  box-shadow: 0 0 0 2px rgba(217, 246, 111, 0.08);
}

.key-chip-swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: var(--chip, #13e663);
}

.key-chip code {
  font-size: 11px;
  letter-spacing: 0.02em;
}

.key-chip-remove {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.key-chip-remove:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.color-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.color-field > label {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #d6d8dc;
  font-size: 12px;
  font-weight: 620;
}

.config-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.config-actions .button {
  width: 100%;
}

input[type="color"] {
  width: 64px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-deep);
  cursor: pointer;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slider-label label {
  margin: 0;
}

.slider-label output {
  min-width: 32px;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent);
  background: rgba(217, 246, 111, 0.08);
  font-size: 10px;
  text-align: center;
}

.slider-field p {
  margin: 4px 0 0;
  color: var(--quiet);
  font-size: 10px;
  line-height: 1.45;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
}

.switch-field strong,
.switch-field small {
  display: block;
}

.switch-field strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.switch-field small {
  color: var(--quiet);
  font-size: 10px;
  line-height: 1.45;
}

.switch-field input {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  appearance: none;
  border-radius: 999px;
  background: #40454d;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.switch-field input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d8dade;
  transition: transform 140ms ease, background-color 140ms ease;
}

.switch-field input:checked {
  background: rgba(217, 246, 111, 0.34);
}

.switch-field input:checked::after {
  background: var(--accent);
  transform: translateX(16px);
}

.diagnostic-card {
  margin-top: 14px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
}

.action-bar {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: 12px;
  left: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 72px;
  padding: 12px 14px 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(22, 25, 30, 0.9);
  box-shadow: 0 16px 54px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(22px);
}

.status-copy {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.status-copy strong,
.status-copy span {
  display: block;
}

.status-copy strong {
  margin-bottom: 3px;
  font-size: 12px;
}

.status-copy span:not(.status-dot) {
  overflow: hidden;
  color: var(--quiet);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(217, 246, 111, 0.08);
}

.status-dot.is-working {
  animation: pulse 1.1s ease-in-out infinite;
}

.status-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(255, 143, 143, 0.09);
}

@keyframes pulse {
  50% {
    opacity: 0.4;
    transform: scale(0.78);
  }
}

.progress-wrap {
  display: flex;
  max-width: 340px;
  flex: 1;
  align-items: center;
  gap: 10px;
}

.progress-wrap progress {
  width: 100%;
  height: 5px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #343941;
}

.progress-wrap progress::-webkit-progress-bar {
  background: #343941;
}

.progress-wrap progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.progress-wrap progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

.progress-wrap span {
  min-width: 34px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast {
  position: fixed;
  z-index: 30;
  top: 18px;
  left: 50%;
  max-width: min(520px, calc(100vw - 40px));
  padding: 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: rgba(25, 28, 34, 0.96);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.38);
  font-size: 12px;
  transform: translateX(-50%);
}

@media (max-width: 1180px) {
  .editor {
    grid-template-columns: minmax(220px, 0.68fr) minmax(440px, 1.55fr);
  }

  .controls-panel {
    grid-column: 1 / -1;
  }

  .controls-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
  }

  .controls-panel .panel-heading,
  .controls-panel .diagnostic-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .app-header,
  .action-bar {
    align-items: stretch;
  }

  .app-header,
  .drop-zone,
  .editor,
  .action-bar {
    display: flex;
    flex-direction: column;
  }

  .editor {
    overflow: auto;
  }

  .header-actions {
    justify-content: space-between;
  }

  .drop-zone {
    align-items: flex-start;
  }

  .drop-zone .button {
    width: 100%;
  }

  .sample-grid {
    width: 100%;
  }

  .sample-card img {
    height: 96px;
  }

  .preview-panel {
    min-height: 48vh;
  }

  .preview-viewport {
    min-height: 36vh;
  }

  .preview-grid[data-mode="compare"] {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    display: block;
  }

  .action-bar {
    right: 12px;
    bottom: 10px;
    left: 12px;
    gap: 10px;
  }

  .progress-wrap {
    max-width: none;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons .button {
    flex: 1;
  }
}
