:root {
  --page: #f5f3ed;
  --surface: #ffffff;
  --surface-soft: #eef6f3;
  --ink: #18211f;
  --muted: #68736f;
  --line: rgba(24, 33, 31, 0.13);
  --line-strong: rgba(24, 33, 31, 0.24);
  --teal: #0f948c;
  --teal-dark: #0a605c;
  --green: #2f7a55;
  --orange: #c75d23;
  --yellow: #f1b928;
  --red: #b42318;
  --focus: #2563eb;
  --shadow: 0 22px 70px rgba(24, 33, 31, 0.14);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 148, 140, 0.1), transparent 34rem),
    linear-gradient(315deg, rgba(199, 93, 35, 0.09), transparent 30rem),
    var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.32);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(24, 33, 31, 0.08);
  background: rgba(245, 243, 237, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.02rem;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 0.8rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.3rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 1rem;
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.workspace-pane,
.control-pane {
  min-width: 0;
}

.workspace-pane {
  position: sticky;
  top: 5.25rem;
  align-self: start;
  display: grid;
  gap: 1rem;
  max-height: calc(100vh - 6.25rem);
  overflow: auto;
  padding: clamp(1rem, 2vw, 1.4rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.control-pane {
  display: grid;
  gap: 1rem;
}

.workspace-header,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0 0 0.22rem;
  color: var(--orange);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.workspace-header h1,
.panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.workspace-header h1 {
  font-size: clamp(1.85rem, 4vw, 3.6rem);
  line-height: 0.96;
}

.panel-heading h2 {
  font-size: 1.02rem;
}

.engine-badge {
  flex: 0 0 auto;
  max-width: 18rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(15, 148, 140, 0.24);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(15, 148, 140, 0.1);
  font-size: 0.84rem;
  font-weight: 850;
  white-space: nowrap;
}

.engine-badge.warn {
  border-color: rgba(199, 93, 35, 0.28);
  color: var(--orange);
  background: rgba(199, 93, 35, 0.1);
}

.engine-badge.danger {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--red);
  background: rgba(180, 35, 24, 0.1);
}

.promise-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(47, 122, 85, 0.22);
  border-radius: 8px;
  background: rgba(47, 122, 85, 0.08);
  color: var(--ink);
  font-size: 0.9rem;
}

.promise-strip a,
.site-footer a {
  color: var(--teal-dark);
  font-weight: 850;
  text-decoration: none;
}

.promise-strip a:hover,
.promise-strip a:focus-visible,
.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--ink);
  outline: none;
}

.drop-zone {
  position: relative;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fffdfa;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone.dragging {
  border-color: var(--teal);
  background: rgba(15, 148, 140, 0.08);
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.drop-label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem;
  min-height: 6.5rem;
  padding: 1rem;
  cursor: pointer;
}

.drop-title,
.drop-note {
  display: block;
}

.drop-title {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
}

.drop-note {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.drop-icon,
.button-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
}

.drop-icon {
  width: 2.8rem;
  height: 2.8rem;
  border: 2px solid var(--teal);
  border-radius: 8px;
  background: rgba(15, 148, 140, 0.1);
}

.upload-icon::before,
.download-icon::before,
.selected-icon::before,
.zip-icon::before,
.reset-icon::before {
  position: absolute;
  content: "";
}

.upload-icon::before {
  left: 50%;
  top: 0.65rem;
  width: 0.72rem;
  height: 0.72rem;
  border-left: 3px solid var(--teal-dark);
  border-top: 3px solid var(--teal-dark);
  transform: translateX(-50%) rotate(45deg);
}

.upload-icon::after {
  position: absolute;
  left: 50%;
  top: 0.75rem;
  width: 3px;
  height: 1.45rem;
  background: var(--teal-dark);
  content: "";
  transform: translateX(-50%);
}

.workspace-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.workspace-stats div {
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.workspace-stats span,
.field span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.workspace-stats strong {
  display: block;
  margin-top: 0.1rem;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.08rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.8rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 900;
}

.button.primary {
  border-color: var(--teal);
  color: #ffffff;
  background: var(--teal);
}

.button.ghost {
  color: var(--muted);
  background: transparent;
}

.button:disabled,
.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.mini-button {
  min-height: 2.25rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
}

.mini-button.danger {
  border-color: rgba(180, 35, 24, 0.24);
  color: var(--red);
}

.download-icon::before {
  left: 0.45rem;
  top: 0.12rem;
  width: 0.4rem;
  height: 0.75rem;
  border-bottom: 3px solid currentColor;
  border-right: 3px solid currentColor;
  transform: rotate(45deg);
}

.download-icon::after {
  position: absolute;
  left: 0.2rem;
  bottom: 0.05rem;
  width: 0.85rem;
  height: 0.28rem;
  border-bottom: 3px solid currentColor;
  content: "";
}

.selected-icon::before {
  inset: 0.1rem;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.selected-icon::after {
  position: absolute;
  left: 0.36rem;
  top: 0.42rem;
  width: 0.52rem;
  height: 0.28rem;
  border-left: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  content: "";
  transform: rotate(-45deg);
}

.zip-icon::before {
  inset: 0.12rem 0.24rem;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.zip-icon::after {
  position: absolute;
  left: 0.55rem;
  top: 0.18rem;
  width: 0.18rem;
  height: 0.88rem;
  background: repeating-linear-gradient(to bottom, currentColor 0 0.12rem, transparent 0.12rem 0.24rem);
  content: "";
}

.reset-icon::before {
  inset: 0.2rem;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
}

.reset-icon::after {
  position: absolute;
  top: 0.06rem;
  right: 0.12rem;
  width: 0.42rem;
  height: 0.42rem;
  border-top: 3px solid currentColor;
  border-right: 3px solid currentColor;
  content: "";
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.empty-state {
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.84);
}

.empty-state h2 {
  margin-bottom: 0.35rem;
  font-size: 1.1rem;
}

.empty-state p {
  max-width: 56rem;
  margin-bottom: 0;
  color: var(--muted);
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 0.75rem;
}

.page-card {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.page-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 148, 140, 0.13);
}

.page-card.dragging {
  opacity: 0.42;
}

.thumb-wrap {
  display: grid;
  place-items: center;
  aspect-ratio: 0.76;
  overflow: hidden;
  border: 1px solid rgba(24, 33, 31, 0.1);
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(24, 33, 31, 0.04) 25%, transparent 25% 75%, rgba(24, 33, 31, 0.04) 75%),
    linear-gradient(45deg, rgba(24, 33, 31, 0.04) 25%, transparent 25% 75%, rgba(24, 33, 31, 0.04) 75%) 10px 10px,
    #f8faf9;
  background-size: 20px 20px;
}

.thumb-wrap img,
.thumb-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 10px 26px rgba(24, 33, 31, 0.14);
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  width: 70%;
  height: 82%;
  border: 2px solid rgba(15, 148, 140, 0.3);
  border-radius: 5px;
  color: var(--teal-dark);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

.page-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.page-topline label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 900;
}

.page-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-meta {
  min-height: 2.7rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.page-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.32rem;
}

.icon-action {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 2.05rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdfa;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 950;
}

.icon-action.danger {
  color: var(--red);
}

.panel {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 1px 0 rgba(24, 33, 31, 0.04);
}

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

.field,
.range-field,
.check-field {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.62rem 0.68rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdfa;
}

.color-field input {
  padding: 0.28rem;
}

.check-field {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  margin-top: 0.9rem;
  color: var(--ink);
  font-weight: 820;
}

.range-field {
  padding: 0.75rem;
  border: 1px solid rgba(24, 33, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.74);
}

.range-field span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.range-field strong {
  font-size: 0.88rem;
}

.range-field em {
  color: var(--teal-dark);
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.field-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.limits-list {
  display: grid;
  gap: 0.5rem;
  padding-left: 1.2rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.84rem;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace-pane {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar,
  .workspace-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .app-shell {
    padding: 0.75rem;
  }

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

  .drop-label {
    grid-template-columns: 1fr;
  }

  .action-row .button {
    flex: 1 1 12rem;
  }
}

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

  .button {
    width: 100%;
  }

  .action-row {
    flex-direction: column;
  }

  .action-row .button {
    flex: 0 0 auto;
  }

  .promise-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}
