:root {
  color-scheme: light;
  --bg: #fff8ed;
  --surface: #ffffff;
  --surface-strong: #fffdf7;
  --bg-light: #f4f6fb;
  --text: #142044;
  --muted: #52617f;
  --muted-soft: #74809a;
  --line: #dfe5f2;
  --accent: #2e469d;
  --accent-strong: #1f357d;
  --accent-soft: #ecfaf8;
  --mint-highlight: #d1f9f4;
  --mint-surface: #ecfaf8;
  --danger: #a33f38;
  --shadow: 0 18px 44px rgba(46, 70, 157, 0.1);
  font-family:
    "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--accent-strong);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.tool-header,
.control-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-header {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.brand__logo-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  text-decoration: none;
}

.brand__logo-link:focus-visible {
  outline: 3px solid var(--mint-highlight);
  outline-offset: 3px;
}

.brand h1 {
  font-size: 30px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 42px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.control-panel {
  padding: 22px;
}

.panel-section {
  min-width: 0;
  margin: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 0 18px;
}

.panel-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

legend {
  margin-bottom: 12px;
  padding: 0;
  font-weight: 800;
}

.upload-panel {
  display: grid;
  gap: 10px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 168px;
  border: 2px dashed #aeb9df;
  border-radius: 12px;
  background: var(--bg-light);
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--mint-surface);
}

.drop-zone[hidden] {
  display: none;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(23, 32, 74, 0.08);
}

.drop-zone__icon svg {
  width: 22px;
  height: 22px;
}

.drop-zone__title {
  display: block;
  font-size: 17px;
  font-weight: 800;
}

.drop-zone__hint,
.helper-text,
.empty-state span,
.naming-help {
  color: var(--muted);
  font-size: 13px;
}

.upload-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.upload-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app-status {
  min-height: 18px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.selected-files {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 10px;
  margin-top: 8px;
  overflow-x: auto;
  overflow-y: hidden;
}

.selected-files:empty {
  display: none;
}

.selected-files.is-dragging {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  border-radius: 8px;
}

.add-files-row {
  display: flex;
  justify-content: center;
}

.add-files-button {
  min-height: 36px;
  margin-top: 10px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  padding: 8px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.add-files-button:hover {
  background: var(--mint-highlight);
}

.add-files-button[hidden] {
  display: none;
}

.thumb-item {
  position: relative;
  flex: 0 0 auto;
  width: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.thumb-item:hover {
  border-color: var(--accent);
}

.thumb-item__preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  margin: 6px auto 0;
  background: #d1f9f4;
  border-radius: 6px;
  overflow: hidden;
}

.thumb-item__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.thumb-item__image[hidden] {
  display: none;
}

.thumb-item__error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  padding: 8px;
}

.thumb-item__meta {
  padding: 5px 8px 7px;
}

.thumb-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.thumb-item__size {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.thumb-item__remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 32, 74, 0.72);
  color: #fff;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.thumb-item__remove:hover {
  background: var(--danger);
}

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

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 70, 157, 0.16);
}

.target-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.target-hint {
  margin: 2px 0 0;
  color: var(--muted-soft);
  font-size: 12px;
  line-height: 1.5;
}

.range-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  align-items: center;
  gap: 12px;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, auto);
  gap: 0;
  grid-template-areas:
    "tl tc tr"
    "lc c rc"
    "bl bc br";
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.position-cell {
  min-height: 0;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.position-cell:nth-child(3n) {
  border-right: 0;
}

.position-cell:nth-child(n + 7) {
  border-bottom: 0;
}

/* Hover highlight intentionally disabled: only the active preset is colored. */
.position-cell.is-active {
  background: rgba(209, 249, 244, 0.4);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(46, 70, 157, 0.22);
}

.position-cell:disabled {
  background: var(--bg-light);
  color: #a8b0cf;
  cursor: not-allowed;
}

.position-cell[data-position="top-left"] {
  grid-area: tl;
}

.position-cell[data-position="top-center"] {
  grid-area: tc;
}

.position-cell[data-position="top-right"] {
  grid-area: tr;
}

.position-cell[data-position="left-center"] {
  grid-area: lc;
}

.position-cell[data-position="center"] {
  grid-area: c;
}

.position-cell[data-position="right-center"] {
  grid-area: rc;
}

.position-cell[data-position="bottom-left"] {
  grid-area: bl;
}

.position-cell[data-position="bottom-center"] {
  grid-area: bc;
}

.position-cell[data-position="bottom-right"] {
  grid-area: br;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.range-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(
    to right,
    var(--accent) var(--progress, 92%),
    var(--surface-strong) var(--progress, 92%)
  );
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(46, 70, 157, 0.3);
}

.range-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.range-slider::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.range-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(46, 70, 157, 0.3);
}

.range-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
}

.range-value input[type="number"] {
  min-width: 0;
  padding-right: 6px;
  padding-left: 6px;
  text-align: center;
  -moz-appearance: textfield;
}

.range-value input[type="number"]::-webkit-outer-spin-button,
.range-value input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.range-value > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.color-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

.color-picker:hover {
  border-color: var(--accent);
}

.color-picker input[type="color"] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.color-picker input[type="color"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.color-picker__swatch {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(46, 70, 157, 0.08);
}

.color-picker__icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.color-picker > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.helper-text {
  margin: 0;
}

.naming-help {
  border-radius: 8px;
  background: var(--bg);
  padding: 10px 12px;
}

.naming-help summary {
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.naming-help p {
  margin: 8px 0 0;
  line-height: 1.55;
}

.naming-help code {
  border-radius: 6px;
  background: #fff;
  color: var(--accent-strong);
  padding: 2px 5px;
  font-size: 12px;
  font-weight: 800;
}

.action-row,
.result-header,
.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-row {
  margin-bottom: 22px;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 800;
}

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

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

.button-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button-secondary {
  border-color: var(--accent);
  background: var(--mint-surface);
  color: var(--accent-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--mint-highlight);
}

.button-ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.result-panel {
  min-height: 720px;
  min-width: 0;
  padding: 22px;
}

.result-header {
  margin-bottom: 16px;
}

.watermark-panel {
  display: grid;
  grid-template-areas:
    "upload position size rotation"
    "upload position opacity trim";
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 1fr) minmax(200px, 1fr) minmax(150px, 1fr);
  grid-template-rows: auto auto;
  column-gap: 24px;
  row-gap: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-light);
  padding: 20px 18px;
  margin-bottom: 14px;
}

.watermark-cell {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.watermark-cell__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.watermark-cell--upload {
  grid-area: upload;
  grid-row: 1 / 3;
}

.watermark-cell--position {
  grid-area: position;
  grid-row: 1 / 3;
}

.watermark-cell--size {
  grid-area: size;
}

.watermark-cell--rotation {
  grid-area: rotation;
}

.watermark-cell--opacity {
  grid-area: opacity;
}

.watermark-cell--trim {
  grid-area: trim;
}

.logo-drop {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  width: 100%;
  max-width: 220px;
  min-height: 112px;
  border: 2px dashed #aeb9df;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.logo-drop:hover {
  border-color: var(--accent);
  background: var(--mint-surface);
}

.logo-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.logo-drop__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--accent);
}

.logo-drop__icon svg {
  width: 20px;
  height: 20px;
}

.logo-drop__text {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.watermark-upload-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo-remove {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.logo-remove:hover {
  border-color: var(--danger);
  background: #fff1ee;
}

.logo-remove[hidden] {
  display: none;
}

.watermark-trim__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.watermark-trim__actions .button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.preview-area {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-light);
  padding: 18px 14px;
  overflow: hidden;
}

.preview-info {
  grid-column: 1 / -1;
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px 14px;
  text-align: center;
  justify-items: center;
}

.preview-info[hidden] {
  display: none;
}

.preview-info__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.preview-info__meta {
  font-size: 12px;
  color: var(--muted);
}

.preview-info__saving {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(209, 249, 244, 0.4);
  color: var(--accent-strong);
  font-weight: 700;
}

.preview-info__target,
.result-target {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  font-weight: 700;
}

.preview-info__target.is-met,
.result-target.is-met {
  background: rgba(209, 249, 244, 0.4);
  color: var(--accent-strong);
}

.preview-info__target.is-miss,
.result-target.is-miss {
  background: rgba(163, 63, 56, 0.1);
  color: var(--danger);
}

.result-target {
  margin-top: 2px;
  font-size: 10px;
}

.canvas-nav {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.canvas-nav__icon {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

.canvas-nav:hover:not(:disabled) {
  border-color: var(--bg);
  background: var(--accent);
}

.canvas-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.canvas-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 680px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 1px solid #bfc8e6;
  border-radius: 8px;
  background-color: #d1f9f4;
  overflow: hidden;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
}

.preview-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.logo-editor {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
}

.logo-editor[hidden] {
  display: none;
}

.logo-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

.logo-editor.is-editing .logo-canvas {
  cursor: grabbing;
}

.logo-bounds {
  position: absolute;
  z-index: 3;
  border: 1px dashed rgba(46, 70, 157, 0.85);
  border-radius: 2px;
  transform-origin: center;
  pointer-events: none;
}

.logo-bounds[hidden] {
  display: none;
}

.logo-bounds .logo-handle {
  pointer-events: auto;
}

.logo-editor.is-editing .logo-bounds {
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(46, 70, 157, 0.25);
}

.logo-handle {
  position: absolute;
  z-index: 3;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(46, 70, 157, 0.35);
  padding: 0;
  transform: translate(-50%, -50%);
  cursor: pointer;
  touch-action: none;
}

.logo-handle--nw {
  left: 0;
  top: 0;
}

.logo-handle--ne {
  left: 100%;
  top: 0;
}

.logo-handle--sw {
  left: 0;
  top: 100%;
}

.logo-handle--se {
  left: 100%;
  top: 100%;
}

.logo-handle--rotate {
  left: 50%;
  top: -30px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-color: var(--accent);
  cursor: grab;
}

.logo-handle--rotate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 23px;
  background: var(--accent);
  transform: translateX(-50%);
}

.crop-box {
  position: absolute;
  z-index: 4;
  border: 2px solid var(--accent);
  background: rgba(46, 70, 157, 0.08);
  box-shadow: 0 0 0 9999px rgba(23, 32, 74, 0.45);
  pointer-events: none;
}

.crop-box[hidden] {
  display: none;
}

.crop-handle {
  position: absolute;
  z-index: 5;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(46, 70, 157, 0.35);
  padding: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  touch-action: none;
}

.crop-handle--nw {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}

.crop-handle--ne {
  left: 100%;
  top: 0;
  cursor: nesw-resize;
}

.crop-handle--sw {
  left: 0;
  top: 100%;
  cursor: nesw-resize;
}

.crop-handle--se {
  left: 100%;
  top: 100%;
  cursor: nwse-resize;
}

.rotation-control__value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 5px 10px;
}

.rotation-control__value input[type="number"] {
  width: 64px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  text-align: center;
  outline: none;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.rotation-control__value input[type="number"]::-webkit-outer-spin-button,
.rotation-control__value input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rotation-control__value span {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.watermark-cell--rotation:focus-within .rotation-control__value {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 70, 157, 0.16);
}

.result-list {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  margin-top: 16px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.result-item {
  position: relative;
  flex: 0 0 auto;
  width: 168px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.result-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46, 70, 157, 0.35);
}

.result-thumb {
  display: block;
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

.result-thumb__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 6px;
  background: var(--mint-surface);
}

.result-info {
  width: 100%;
  min-width: 0;
  padding: 2px 0 0;
  text-align: center;
}

.result-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.result-meta,
.result-size {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  justify-content: center;
  margin-top: 2px;
}

.download-link {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.download-link svg {
  width: 16px;
  height: 16px;
}

.download-link:hover {
  background: var(--accent-strong);
}

.result-actions .download-link {
  width: 36px;
  flex: 0 0 auto;
}

.result-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 32, 74, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.result-remove:hover {
  background: var(--danger);
}

.error-text {
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 980px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .watermark-panel {
    grid-template-areas:
      "upload position"
      "upload position"
      "size rotation"
      "opacity trim";
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding: 10px 0;
  }

  .tool-header,
  .control-panel,
  .result-panel {
    padding: 16px;
  }

  h1 {
    font-size: 30px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .watermark-panel {
    grid-template-areas:
      "upload"
      "position"
      "size"
      "rotation"
      "opacity"
      "trim";
    grid-template-columns: 1fr;
  }

  .watermark-cell--upload,
  .watermark-cell--position {
    grid-row: auto;
  }

  .action-row,
  .result-header,
  .result-item {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .download-link {
    width: 100%;
    text-align: center;
  }
}

/* Brand color overrides */
#downloadZipButton,
#trimButton {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

#downloadZipButton:hover:not(:disabled),
#trimButton:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--surface);
}

.preview-area {
  border-color: #1a2656;
  background: var(--bg-light);
}

.canvas-frame {
  background-color: var(--surface);
}

.canvas-nav {
  border-color: var(--mint-highlight);
  background: var(--accent);
  color: var(--bg);
}

.canvas-nav:hover:not(:disabled) {
  border-color: var(--bg);
  background: var(--bg);
  color: var(--accent);
}
/* End brand color overrides */
