/* ===== TOKENS ===== */
:root {
  color-scheme: light;

  /* Surfaces */
  --bg:            #f3efe7;
  --surface:       #fffefa;
  --surface-raised: #ffffff;
  --surface-soft:  #ede8de;

  /* Text */
  --ink:           #131210;
  --ink-2:         #36312c;
  --muted:         #625d56;
  --quiet:         #948d84;

  /* Borders */
  --line:          #dcd6ca;
  --line-soft:     #e7e1d6;
  --line-strong:   #c4bbae;

  /* Accent — blue */
  --accent:        #1f52c4;
  --accent-dark:   #163e9c;
  --accent-soft:   #e8eeff;

  /* Green */
  --green:         #096658;
  --green-soft:    #e2f5f0;

  /* Warning / Danger */
  --warning:       #844e0e;
  --warning-soft:  #fdf1e4;
  --danger:        #951c16;

  /* Shadows */
  --shadow-sm:     0 1px 2px rgb(0 0 0 / 5%), 0 3px 8px rgb(0 0 0 / 4%);
  --shadow-md:     0 2px 6px rgb(0 0 0 / 6%), 0 10px 28px rgb(0 0 0 / 5%);
  --shadow-lg:     0 6px 18px rgb(0 0 0 / 8%), 0 28px 68px rgb(0 0 0 / 6%);
  --shadow-canvas: 0 2px 0 rgb(255 255 255 / 68%) inset,
                   0 28px 68px rgb(20 16 10 / 22%);

  /* Radii */
  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;
  --r-pill: 999px;
}

/* ===== BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgb(31 82 196 / 5%) 0%, transparent 68%),
    linear-gradient(180deg, #fdfaf3 0%, var(--bg) 55%, #e9e3d8 100%);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle dot grid */
body::after {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgb(0 0 0 / 9%) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 0 0;
  content: "";
  opacity: 0.35;
}

button,
input {
  font: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ===== ICONS ===== */
.icon-sprite {
  display: none;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: currentColor;
}

/* ===== SHELL ===== */
.shell {
  position: relative;
  z-index: 1;
  width: min(1760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 1.8vw, 28px);
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 62px;
  margin-bottom: clamp(12px, 1.6vw, 22px);
  padding: 10px 0;
  animation: rise-in 480ms cubic-bezier(.22, 1, .36, 1) both;
}

.topbar::before {
  position: absolute;
  inset: -16px -10px;
  z-index: -1;
  background: linear-gradient(180deg,
    rgb(243 239 231 / 98%) 0%,
    rgb(243 239 231 / 88%) 68%,
    rgb(243 239 231 / 0%) 100%);
  backdrop-filter: blur(10px);
  content: "";
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.2vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
}

.brand-sep {
  width: 1px;
  height: 22px;
  flex: 0 0 auto;
  background: var(--line-strong);
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green {
  border: 1px solid rgb(9 102 88 / 22%);
  background: rgb(255 255 255 / 82%);
  color: var(--green);
  box-shadow: 0 2px 8px rgb(9 102 88 / 6%);
}

.badge-neutral {
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 62%);
  color: var(--muted);
}

/* ===== WORKSPACE ===== */
.workspace {
  display: grid;
  grid-template-areas: "file preview settings";
  grid-template-columns: minmax(240px, 272px) minmax(0, 1fr) minmax(296px, 340px);
  gap: 18px;
  align-items: start;
  min-height: calc(100vh - 140px);
}

/* ===== RAIL SHARED ===== */
.file-rail,
.settings-rail,
.preview {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: rgb(255 254 250 / 92%);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.file-rail {
  grid-area: file;
  display: grid;
  align-content: start;
  animation: rise-in 560ms cubic-bezier(.22, 1, .36, 1) both;
}

.settings-rail {
  grid-area: settings;
  display: grid;
  align-content: start;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  animation: rise-in 560ms cubic-bezier(.22, 1, .36, 1) 80ms both;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.preview {
  grid-area: preview;
  min-width: 0;
  animation: rise-in 560ms cubic-bezier(.22, 1, .36, 1) 160ms both;
}

/* ===== PANEL ===== */
.panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.file-rail .panel + .panel {
  border-top: 1px solid var(--line-soft);
}

.settings-rail .panel {
  border-bottom: 1px solid var(--line-soft);
}

.settings-rail .panel:last-child {
  border-bottom: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title,
.preview-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.section-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--accent);
  background: var(--surface-raised);
  box-shadow: 0 1px 3px rgb(0 0 0 / 5%);
}

.section-icon .icon {
  width: 14px;
  height: 14px;
}

.panel h2,
.preview-head h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--ink-2);
}

.panel output,
.panel .caption,
.preview-size {
  color: var(--quiet);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

/* ===== DROP ZONE ===== */
.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 158px;
  padding: 20px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-soft);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 200ms ease,
    background 200ms ease,
    box-shadow 200ms ease,
    transform 200ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging,
.drop-zone:focus-within {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgb(31 82 196 / 8%);
  transform: translateY(-1px);
}

.drop-zone.is-dragging {
  animation: drop-pulse 900ms ease-in-out infinite alternate;
}

.drop-zone.is-loaded {
  border-style: solid;
  border-color: rgb(9 102 88 / 32%);
  background: var(--green-soft);
}

.drop-zone.is-loaded:hover {
  border-color: var(--green);
  background: rgb(9 102 88 / 10%);
  box-shadow: 0 0 0 4px rgb(9 102 88 / 8%);
}

.drop-zone.is-loaded:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgb(31 82 196 / 12%);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-copy {
  display: grid;
  justify-items: center;
  gap: 9px;
  pointer-events: none;
}

.upload-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  color: var(--muted);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  transition: color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.upload-mark .icon {
  width: 22px;
  height: 22px;
}

.drop-zone:hover .upload-mark,
.drop-zone.is-dragging .upload-mark {
  color: var(--accent);
  border-color: rgb(31 82 196 / 26%);
  box-shadow: 0 4px 14px rgb(31 82 196 / 14%);
}

.drop-zone.is-loaded .upload-mark {
  color: var(--green);
  border-color: rgb(9 102 88 / 26%);
  box-shadow: 0 4px 14px rgb(9 102 88 / 12%);
}

.drop-copy strong {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink-2);
}

.drop-zone.is-loaded .drop-copy strong {
  color: var(--green);
}

.drop-copy span {
  max-width: 240px;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.55;
}

/* ===== FILE META ===== */
.file-meta {
  display: grid;
  gap: 3px;
  min-height: 42px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.file-meta strong {
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ===== EXIF FIELDS ===== */
.field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

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

.exif-empty {
  display: grid;
  gap: 10px;
  min-height: 148px;
  place-items: center;
  padding: 22px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 70%), rgb(237 232 222 / 58%)),
    radial-gradient(circle at 50% 0%, rgb(31 82 196 / 6%), transparent 58%);
  color: var(--muted);
  text-align: center;
}

.exif-empty-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-raised);
  color: var(--quiet);
  box-shadow: var(--shadow-sm);
}

.exif-empty p {
  margin: 0;
}

.exif-empty b {
  display: block;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
}

.exif-empty span {
  display: block;
  max-width: 230px;
  margin: 0 auto;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.field-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-left: 2.5px solid transparent;
  border-radius: var(--r);
  background: var(--surface-raised);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
  cursor: pointer;
}

.field-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.field-row.is-selected {
  border-color: rgb(31 82 196 / 22%);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.field-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.field-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.field-text b {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--quiet);
}

.field-text span {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--ink-2);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.field-row.is-selected .field-text b {
  color: var(--accent-dark);
}

/* ===== NOTICE ===== */
.notice {
  display: none;
  align-items: start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid rgb(132 78 14 / 22%);
  border-radius: var(--r);
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.notice.is-visible {
  display: flex;
  animation: fade-in 240ms ease both;
}

/* ===== FRAME RANGE ===== */
.range-row {
  display: grid;
  gap: 13px;
}

.control-group {
  display: grid;
  gap: 10px;
}

.range-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 600;
}

input[type="range"] {
  --range-fill: 0%;
  width: 100%;
  height: 26px;
  appearance: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}

input[type="range"].range-fill-0 { --range-fill: 0%; }
input[type="range"].range-fill-1 { --range-fill: 1%; }
input[type="range"].range-fill-2 { --range-fill: 2%; }
input[type="range"].range-fill-3 { --range-fill: 3%; }
input[type="range"].range-fill-4 { --range-fill: 4%; }
input[type="range"].range-fill-5 { --range-fill: 5%; }
input[type="range"].range-fill-6 { --range-fill: 6%; }
input[type="range"].range-fill-7 { --range-fill: 7%; }
input[type="range"].range-fill-8 { --range-fill: 8%; }
input[type="range"].range-fill-9 { --range-fill: 9%; }
input[type="range"].range-fill-10 { --range-fill: 10%; }
input[type="range"].range-fill-11 { --range-fill: 11%; }
input[type="range"].range-fill-12 { --range-fill: 12%; }
input[type="range"].range-fill-13 { --range-fill: 13%; }
input[type="range"].range-fill-14 { --range-fill: 14%; }
input[type="range"].range-fill-15 { --range-fill: 15%; }
input[type="range"].range-fill-16 { --range-fill: 16%; }
input[type="range"].range-fill-17 { --range-fill: 17%; }
input[type="range"].range-fill-18 { --range-fill: 18%; }
input[type="range"].range-fill-19 { --range-fill: 19%; }
input[type="range"].range-fill-20 { --range-fill: 20%; }
input[type="range"].range-fill-21 { --range-fill: 21%; }
input[type="range"].range-fill-22 { --range-fill: 22%; }
input[type="range"].range-fill-23 { --range-fill: 23%; }
input[type="range"].range-fill-24 { --range-fill: 24%; }
input[type="range"].range-fill-25 { --range-fill: 25%; }
input[type="range"].range-fill-26 { --range-fill: 26%; }
input[type="range"].range-fill-27 { --range-fill: 27%; }
input[type="range"].range-fill-28 { --range-fill: 28%; }
input[type="range"].range-fill-29 { --range-fill: 29%; }
input[type="range"].range-fill-30 { --range-fill: 30%; }
input[type="range"].range-fill-31 { --range-fill: 31%; }
input[type="range"].range-fill-32 { --range-fill: 32%; }
input[type="range"].range-fill-33 { --range-fill: 33%; }
input[type="range"].range-fill-34 { --range-fill: 34%; }
input[type="range"].range-fill-35 { --range-fill: 35%; }
input[type="range"].range-fill-36 { --range-fill: 36%; }
input[type="range"].range-fill-37 { --range-fill: 37%; }
input[type="range"].range-fill-38 { --range-fill: 38%; }
input[type="range"].range-fill-39 { --range-fill: 39%; }
input[type="range"].range-fill-40 { --range-fill: 40%; }
input[type="range"].range-fill-41 { --range-fill: 41%; }
input[type="range"].range-fill-42 { --range-fill: 42%; }
input[type="range"].range-fill-43 { --range-fill: 43%; }
input[type="range"].range-fill-44 { --range-fill: 44%; }
input[type="range"].range-fill-45 { --range-fill: 45%; }
input[type="range"].range-fill-46 { --range-fill: 46%; }
input[type="range"].range-fill-47 { --range-fill: 47%; }
input[type="range"].range-fill-48 { --range-fill: 48%; }
input[type="range"].range-fill-49 { --range-fill: 49%; }
input[type="range"].range-fill-50 { --range-fill: 50%; }
input[type="range"].range-fill-51 { --range-fill: 51%; }
input[type="range"].range-fill-52 { --range-fill: 52%; }
input[type="range"].range-fill-53 { --range-fill: 53%; }
input[type="range"].range-fill-54 { --range-fill: 54%; }
input[type="range"].range-fill-55 { --range-fill: 55%; }
input[type="range"].range-fill-56 { --range-fill: 56%; }
input[type="range"].range-fill-57 { --range-fill: 57%; }
input[type="range"].range-fill-58 { --range-fill: 58%; }
input[type="range"].range-fill-59 { --range-fill: 59%; }
input[type="range"].range-fill-60 { --range-fill: 60%; }
input[type="range"].range-fill-61 { --range-fill: 61%; }
input[type="range"].range-fill-62 { --range-fill: 62%; }
input[type="range"].range-fill-63 { --range-fill: 63%; }
input[type="range"].range-fill-64 { --range-fill: 64%; }
input[type="range"].range-fill-65 { --range-fill: 65%; }
input[type="range"].range-fill-66 { --range-fill: 66%; }
input[type="range"].range-fill-67 { --range-fill: 67%; }
input[type="range"].range-fill-68 { --range-fill: 68%; }
input[type="range"].range-fill-69 { --range-fill: 69%; }
input[type="range"].range-fill-70 { --range-fill: 70%; }
input[type="range"].range-fill-71 { --range-fill: 71%; }
input[type="range"].range-fill-72 { --range-fill: 72%; }
input[type="range"].range-fill-73 { --range-fill: 73%; }
input[type="range"].range-fill-74 { --range-fill: 74%; }
input[type="range"].range-fill-75 { --range-fill: 75%; }
input[type="range"].range-fill-76 { --range-fill: 76%; }
input[type="range"].range-fill-77 { --range-fill: 77%; }
input[type="range"].range-fill-78 { --range-fill: 78%; }
input[type="range"].range-fill-79 { --range-fill: 79%; }
input[type="range"].range-fill-80 { --range-fill: 80%; }
input[type="range"].range-fill-81 { --range-fill: 81%; }
input[type="range"].range-fill-82 { --range-fill: 82%; }
input[type="range"].range-fill-83 { --range-fill: 83%; }
input[type="range"].range-fill-84 { --range-fill: 84%; }
input[type="range"].range-fill-85 { --range-fill: 85%; }
input[type="range"].range-fill-86 { --range-fill: 86%; }
input[type="range"].range-fill-87 { --range-fill: 87%; }
input[type="range"].range-fill-88 { --range-fill: 88%; }
input[type="range"].range-fill-89 { --range-fill: 89%; }
input[type="range"].range-fill-90 { --range-fill: 90%; }
input[type="range"].range-fill-91 { --range-fill: 91%; }
input[type="range"].range-fill-92 { --range-fill: 92%; }
input[type="range"].range-fill-93 { --range-fill: 93%; }
input[type="range"].range-fill-94 { --range-fill: 94%; }
input[type="range"].range-fill-95 { --range-fill: 95%; }
input[type="range"].range-fill-96 { --range-fill: 96%; }
input[type="range"].range-fill-97 { --range-fill: 97%; }
input[type="range"].range-fill-98 { --range-fill: 98%; }
input[type="range"].range-fill-99 { --range-fill: 99%; }
input[type="range"].range-fill-100 { --range-fill: 100%; }

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border: 1px solid rgb(196 187 174 / 62%);
  border-radius: var(--r-pill);
  background:
    linear-gradient(90deg, var(--ink) 0 var(--range-fill), transparent var(--range-fill) 100%),
    linear-gradient(90deg, rgb(196 187 174 / 64%), rgb(220 214 202 / 82%));
  box-shadow: 0 1px 0 rgb(255 255 255 / 82%) inset;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -9px;
  border: 1px solid rgb(19 18 16 / 16%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, #ffffff 0 24%, #f8f5ef 25% 100%);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 80%) inset,
    0 3px 10px rgb(20 16 10 / 18%),
    0 0 0 5px rgb(31 82 196 / 0%);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb {
  border-color: rgb(31 82 196 / 34%);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 80%) inset,
    0 5px 16px rgb(20 16 10 / 20%),
    0 0 0 5px rgb(31 82 196 / 10%);
  transform: scale(1.08);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border: 1px solid rgb(196 187 174 / 62%);
  border-radius: var(--r-pill);
  background: rgb(220 214 202 / 82%);
  box-shadow: 0 1px 0 rgb(255 255 255 / 82%) inset;
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--ink);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 1px solid rgb(19 18 16 / 16%);
  border-radius: 50%;
  background: #fffefa;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 80%) inset,
    0 3px 10px rgb(20 16 10 / 18%);
  cursor: pointer;
}

.control-label {
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
}

.swatch-row,
.align-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.swatch-button::before {
  width: 22px;
  height: 22px;
  border: 1px solid rgb(19 18 16 / 16%);
  border-radius: 50%;
  background: #ffffff;
  content: "";
}

.swatch-button[data-color="black"]::before {
  background: #111111;
}

.swatch-button[data-color="warm"]::before {
  background: #eee7db;
}

.swatch-button[data-color="auto"]::before {
  background: linear-gradient(135deg, #111315 0 50%, #ffffff 50% 100%);
}

.swatch-button[data-color="dark"]::before {
  background: #111315;
}

.swatch-button[data-color="light"]::before {
  background: #f8f5ef;
}

.swatch-button[data-color="muted"]::before {
  background: #6f675e;
}

.swatch-button.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(31 82 196 / 10%), var(--shadow-sm);
}

.swatch-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.align-button {
  min-width: 42px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.align-button:hover:not(.is-active) {
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.align-button.is-active {
  border-color: rgb(31 82 196 / 22%);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: var(--shadow-sm);
}

.text-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 0.9375rem;
  box-shadow: 0 1px 0 rgb(255 255 255 / 72%) inset;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.text-input:focus {
  border-color: rgb(31 82 196 / 48%);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 72%) inset,
    0 0 0 4px rgb(31 82 196 / 10%);
  outline: none;
}

/* ===== FORMAT TOGGLE ===== */
.format-toggle {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-soft);
}

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

.format-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: calc(var(--r) - 3px);
  font-size: 0.9375rem;
  font-weight: 600;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.format-button {
  padding: 0 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.format-button:hover:not(.is-active) {
  color: var(--ink-2);
  background: rgb(255 255 255 / 58%);
}

.format-button.is-active {
  border-color: var(--line);
  background: var(--surface-raised);
  color: var(--accent-dark);
  box-shadow: var(--shadow-sm);
}

/* ===== DOWNLOAD BUTTON ===== */
.download-button {
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid #0d0d0d;
  background: #141414;
  color: #ffffff;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 8%) inset,
    0 1px 2px rgb(0 0 0 / 18%),
    0 8px 20px rgb(0 0 0 / 14%);
}

.download-button:not(:disabled):hover {
  background: #1c1c1c;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 8%) inset,
    0 2px 4px rgb(0 0 0 / 20%),
    0 14px 30px rgb(0 0 0 / 18%);
  transform: translateY(-1px);
}

.download-button:not(:disabled):active {
  transform: translateY(0);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 8%) inset,
    0 1px 2px rgb(0 0 0 / 18%);
}

.download-button:disabled {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--quiet);
  box-shadow: none;
}

/* ===== RESET BUTTON ===== */
.reset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 1px 0 rgb(255 255 255 / 72%) inset;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.reset-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}

.reset-button:active {
  background: var(--surface-soft);
  box-shadow: none;
}

/* ===== STATUS ===== */
.status {
  min-height: 24px;
  color: var(--quiet);
  font-size: 0.875rem;
  line-height: 1.5;
}

.status.is-error {
  color: var(--danger);
}

.status.is-complete {
  color: var(--green);
  animation: status-flash 700ms ease both;
}

/* ===== PREVIEW ===== */
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgb(255 254 250 / 80%);
}

.canvas-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 200px);
  padding: clamp(20px, 3.5vw, 56px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 3%) 1px, transparent 1px),
    linear-gradient(180deg, rgb(0 0 0 / 2%) 1px, transparent 1px),
    linear-gradient(170deg, #ece7dd 0%, #ddd6ca 100%);
  background-size: 52px 52px, 52px 52px, auto;
}

/* Inset border */
.canvas-stage::before {
  position: absolute;
  inset: 16px;
  border: 1px solid rgb(255 255 255 / 36%);
  border-radius: var(--r);
  content: "";
  pointer-events: none;
  z-index: 0;
}

/* Ground shadow */
.canvas-stage::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 28%;
  background: linear-gradient(0deg, rgb(0 0 0 / 9%), transparent);
  content: "";
  pointer-events: none;
}

canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 1080px);
  max-height: calc(100vh - 260px);
  border-radius: 2px;
  background: #ffffff;
  box-shadow: var(--shadow-canvas);
  transition: transform 280ms cubic-bezier(.22, 1, .36, 1), box-shadow 280ms ease;
}

canvas.is-updated {
  animation: print-pop 420ms cubic-bezier(.22, 1, .36, 1) both;
}

canvas.is-empty {
  display: none;
}

.empty-preview {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100%, 520px);
  min-height: min(340px, calc(100vh - 264px));
  padding: 40px 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  color: var(--muted);
  text-align: center;
}

.empty-preview-inner {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.empty-preview .icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  opacity: 0.55;
}

.empty-preview strong {
  color: var(--ink-2);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
}

.empty-preview span {
  max-width: 260px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.empty-preview.is-hidden {
  display: none;
}

/* ===== KEYFRAMES ===== */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes drop-pulse {
  from { box-shadow: 0 0 0 4px rgb(31 82 196 / 8%); }
  to   { box-shadow: 0 0 0 8px rgb(31 82 196 / 18%); }
}

@keyframes print-pop {
  0%   { opacity: 0.68; transform: translateY(8px) scale(0.988); }
  100% { opacity: 1;    transform: translateY(0)  scale(1); }
}

@keyframes status-flash {
  0%   { opacity: 0.3; }
  100% { opacity: 1; }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 1180px ===== */
@media (max-width: 1180px) {
  .workspace {
    grid-template-areas:
      "file preview"
      "settings preview";
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: auto;
  }

  .settings-rail {
    max-height: none;
    overflow: visible;
  }

  .canvas-stage {
    min-height: 56vh;
  }

  canvas {
    max-height: none;
  }
}

/* ===== 820px ===== */
@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    position: static;
  }

  .topbar::before {
    display: none;
  }

  .brand {
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand-sep {
    display: none;
  }

  .brand p {
    width: 100%;
    white-space: normal;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: start;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "file"
      "preview"
      "settings";
    gap: 12px;
  }
}

/* ===== 620px ===== */
@media (max-width: 620px) {
  .shell {
    padding: 14px;
  }

  .topbar {
    margin-bottom: 12px;
    gap: 12px;
  }

  .brand h1 {
    font-size: clamp(2rem, 11vw, 2.8rem);
  }

  .panel,
  .preview-head {
    padding: 14px;
  }

  .panel {
    gap: 12px;
  }

  .drop-zone {
    min-height: 126px;
    padding: 16px 12px;
  }

  .upload-mark {
    width: 40px;
    height: 40px;
  }

  .file-meta {
    min-height: 0;
  }

  .canvas-stage {
    min-height: 38vh;
    padding: 14px;
  }

  .field-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .field-row {
    padding: 9px;
  }

  .exif-empty {
    min-height: 118px;
    padding: 18px 14px;
  }

  .empty-preview {
    min-height: 240px;
    padding: 32px 24px;
  }
}
