* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #f4f8fc;
  color: #0f172a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.photo-app {
  min-height: 100vh;
}

.photo-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  border-bottom: 1px solid #d8e7f5;
  background: rgba(255, 255, 255, .9);
  padding: 0 1.5rem;
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 14px;
  background: #0b7bd3;
  color: #fff;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1;
}

.brand span {
  color: #0b7bd3;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.step-nav {
  display: flex;
  gap: .4rem;
  border: 1px solid #d8e7f5;
  border-radius: 999px;
  background: #eef6fd;
  padding: .35rem;
}

.step-nav a {
  border-radius: 999px;
  color: #64748b;
  padding: .55rem .95rem;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
}

.step-nav a.active {
  background: #0b7bd3;
  color: #fff;
  box-shadow: 0 8px 18px rgba(11, 123, 211, .25);
}

.photo-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.photo-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  border: 1px solid #bde3ff;
  border-radius: 28px;
  background:
    linear-gradient(90deg, rgba(219, 241, 255, .94), rgba(255, 255, 255, .92)),
    repeating-linear-gradient(90deg, rgba(11, 123, 211, .08) 0 1px, transparent 1px 32px);
  padding: 1.2rem 1.35rem;
}

.kicker {
  display: inline-flex;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #fff;
  color: #075985;
  padding: .45rem .75rem;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: .55rem 0 .35rem;
  font-size: clamp(1.9rem, 3vw, 2.7rem);
  letter-spacing: 0;
  line-height: .98;
}

.photo-hero p {
  margin: 0;
  color: #52647a;
  font-size: .92rem;
}

.hero-actions,
.actions {
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(0, 1.5fr) minmax(300px, .8fr);
  gap: 1rem;
  margin-top: 1rem;
}

.crop-editor-grid {
  grid-template-columns: minmax(245px, 285px) minmax(420px, 1fr) minmax(245px, 285px);
  align-items: start;
}

.panel {
  align-self: start;
  border: 1px solid #d8e7f5;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 22px 52px rgba(15, 81, 132, .12);
  padding: .85rem;
}

.crop-control-panel {
  display: grid;
  gap: .82rem;
}

.panel-divider {
  height: 1px;
  background: #e2edf7;
}

.subsection-title {
  margin-top: .35rem !important;
}

.panel h2,
.panel h3 {
  margin: 0 0 .65rem;
  color: #0f4f7a;
  font-size: .9rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.upload-zone {
  display: grid;
  min-height: 130px;
  place-items: center;
  border: 2px dashed #93c5fd;
  border-radius: 22px;
  background: #f8fbff;
  color: #64748b;
  text-align: center;
  cursor: pointer;
  padding: 1.1rem;
}

.compact-upload .upload-zone {
  min-height: 92px;
  border-radius: 16px;
  padding: .8rem;
}

.upload-zone strong {
  display: block;
  color: #0f172a;
  font-size: 1rem;
}

.upload-zone span {
  display: block;
  margin-top: .35rem;
  font-size: .84rem;
  font-weight: 700;
}

.stage {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border: 1.5px dashed #a7c7e7;
  border-radius: 22px;
  background-color: #eef5fb;
  background-image:
    linear-gradient(45deg, #dfeaf4 25%, transparent 25%),
    linear-gradient(-45deg, #dfeaf4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfeaf4 75%),
    linear-gradient(-45deg, transparent 75%, #dfeaf4 75%);
  background-position: 0 0, 0 13px, 13px -13px, -13px 0;
  background-size: 26px 26px;
  touch-action: none;
  user-select: none;
}

.crop-editor-grid .stage {
  min-height: 430px;
}

.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.crop-box {
  position: absolute;
  display: none;
  z-index: 5;
  min-width: 32px;
  min-height: 32px;
  border: 2px dashed #111827;
  background: rgba(255, 255, 255, .03);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .2), inset 0 0 0 1px #fff;
  cursor: move;
}

.crop-handle {
  position: absolute;
  z-index: 8;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0b7bd3;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .28);
}

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

.crop-handle-n {
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.crop-handle-ne {
  right: -8px;
  top: -8px;
  cursor: nesw-resize;
}

.crop-handle-e {
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.crop-handle-se {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.crop-handle-s {
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.crop-handle-sw {
  left: -8px;
  bottom: -8px;
  cursor: nesw-resize;
}

.crop-handle-w {
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.crop-box.visible {
  display: block;
}

.crop-box b {
  position: absolute;
  left: 50%;
  top: .55rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(17, 24, 39, .94);
  color: #fff;
  padding: .3rem .7rem;
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.preview-frame {
  display: grid;
  min-height: 300px;
  place-items: center;
  overflow: auto;
  border: 1px dashed #cbd5e1;
  border-radius: 20px;
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, #edf2f7 25%, transparent 25%),
    linear-gradient(-45deg, #edf2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf2f7 75%),
    linear-gradient(-45deg, transparent 75%, #edf2f7 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  padding: 1rem;
}

.preview-frame img,
.preview-frame canvas {
  max-width: 100%;
  height: auto;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5edf5 25%, transparent 25%),
    linear-gradient(-45deg, #e5edf5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5edf5 75%),
    linear-gradient(-45deg, transparent 75%, #e5edf5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
}

.control-stack {
  display: grid;
  gap: .7rem;
}

.remove-card {
  display: grid;
  gap: .65rem;
  border: 1px solid #d8e7f5;
  border-radius: 16px;
  background: #f8fbff;
  padding: .7rem;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #0f172a;
  font-size: .86rem;
  font-weight: 800;
}

.toggle-control input {
  width: 18px;
  height: 18px;
  accent-color: #0b7bd3;
}

.range-field {
  gap: .25rem;
}

.range-field span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #475569;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.range-field b {
  color: #0b7bd3;
  font-size: .72rem;
}

.range-field input[type="range"] {
  width: 100%;
  accent-color: #0b7bd3;
}

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

.field {
  display: grid;
  gap: .4rem;
}

.field span {
  color: #0f172a;
  font-size: .84rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  color: #0f172a;
  outline: none;
  padding: .65rem .75rem;
}

.field input:focus,
.field select:focus {
  border-color: #0b7bd3;
  box-shadow: 0 0 0 4px rgba(11, 123, 211, .12);
}

.workspace-actions {
  display: flex;
  justify-content: center;
  gap: .7rem;
  flex-wrap: wrap;
  margin-top: .75rem;
}

.crop-cta {
  min-height: 52px;
  font-size: .92rem;
}

.center-hint {
  margin: -.25rem 0 0;
  text-align: center;
}

.control {
  display: grid;
  gap: .45rem;
}

.control label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #475569;
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.control input[type="range"] {
  width: 100%;
  accent-color: #0b7bd3;
}

.color-row,
.seg-row {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
}

.transparent-swatch {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%),
    linear-gradient(-45deg, #cbd5e1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cbd5e1 75%),
    linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-size: 14px 14px;
}

.swatch.active {
  border-color: #0b7bd3;
  box-shadow: 0 0 0 4px rgba(11, 123, 211, .16);
}

.btn,
.seg {
  border: 1px solid #cfe1f2;
  border-radius: 14px;
  background: #fff;
  color: #0f4f7a;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .05em;
  padding: .68rem .9rem;
  text-decoration: none;
  text-transform: uppercase;
}

.btn.primary,
.seg.active {
  border-color: #0b7bd3;
  background: linear-gradient(180deg, #2e9af0, #0875c8);
  color: #fff;
  box-shadow: 0 12px 22px rgba(11, 123, 211, .24);
}

.btn.danger {
  border-color: #fecdd3;
  color: #be123c;
}

.btn.full {
  width: 100%;
}

.sheet-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
}

.hint {
  color: #64748b;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.5;
}

.tool-links {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: none;
  border-radius: 16px;
  background: #0f172a;
  color: #fff;
  padding: .8rem 1rem;
  font-size: .82rem;
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(15, 23, 42, .22);
}

.toast.show {
  display: block;
}

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

  .stage {
    min-height: 480px;
  }
}

@media (max-width: 760px) {
  .photo-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 1rem;
  }

  .step-nav {
    max-width: 100%;
    overflow-x: auto;
  }

  .photo-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 1.25rem;
  }

  .stage {
    min-height: 380px;
  }
}

/* Professional photo-suite refinements */
[hidden] {
  display: none !important;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid rgba(14, 165, 233, .3);
  outline-offset: 3px;
}

.brand .brand-mark {
  color: #fff;
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: none;
}

.hero-badges {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  padding: .42rem .7rem;
  font-size: .67rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.local-badge span {
  color: #22c55e;
  font-size: .52rem;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .7rem;
}

.panel-heading.compact {
  margin-bottom: .7rem;
}

.panel-heading h2,
.panel-heading h3 {
  margin-bottom: .2rem;
}

.panel-heading p {
  margin: 0;
  color: #64748b;
  font-size: .75rem;
  font-weight: 650;
  line-height: 1.45;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid #d8e7f5;
  border-radius: 999px;
  background: #f8fbff;
  color: #64748b;
  padding: .4rem .65rem;
  font-size: .66rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.has-image .status-pill {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.upload-zone {
  position: relative;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.upload-zone:hover,
.upload-zone.active {
  border-color: #0b7bd3;
  background: #eef8ff;
  transform: translateY(-1px);
}

.upload-icon {
  display: grid !important;
  width: 34px;
  height: 34px;
  margin: 0 auto .5rem !important;
  place-items: center;
  border-radius: 12px;
  background: #e0f2fe;
  color: #0369a1 !important;
  font-size: 1.15rem !important;
  font-weight: 900;
}

.file-meta {
  min-height: 1.25rem;
  margin-top: .5rem;
  overflow: hidden;
  color: #64748b;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.4;
  text-overflow: ellipsis;
}

.stage-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: .35rem;
  padding: 2rem;
  color: #64748b;
  text-align: center;
  pointer-events: none;
}

.stage-empty > span {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: .35rem;
  place-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  background: rgba(255, 255, 255, .9);
  color: #0b7bd3;
  font-size: 1.55rem;
  box-shadow: 0 12px 24px rgba(15, 81, 132, .1);
}

.stage-empty strong {
  color: #334155;
  font-size: 1rem;
}

.stage-empty small {
  font-size: .78rem;
  font-weight: 700;
}

.has-image .stage-empty {
  display: none;
}

.stage img:not([src]) {
  display: none;
}

.preview-frame:empty::before {
  content: "Preview";
  color: #94a3b8;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.mode-panel {
  display: grid;
  gap: .7rem;
  border: 1px solid #bae6fd;
  border-radius: 16px;
  background: #f0f9ff;
  padding: .75rem;
}

.mode-panel h3 {
  margin: 0;
}

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

.btn,
.seg {
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:hover:not(:disabled),
.seg:hover:not(:disabled) {
  border-color: #7dd3fc;
  transform: translateY(-1px);
}

.btn:disabled,
.seg:disabled {
  cursor: not-allowed;
  opacity: .45;
  box-shadow: none;
}

.output-summary {
  margin: 0;
  border-radius: 12px;
  background: #eef6fd;
  color: #0f4f7a;
  padding: .55rem .65rem;
  font-size: .7rem;
  font-weight: 850;
  line-height: 1.45;
  text-align: center;
}

.field input[aria-invalid="true"] {
  border-color: #e11d48;
  background: #fff1f2;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, .1);
}

.batch-list {
  display: grid;
  max-height: 300px;
  gap: .45rem;
  margin: .7rem 0;
  overflow: auto;
}

.batch-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: .65rem;
  width: 100%;
  border: 1px solid #d8e7f5;
  border-radius: 13px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  padding: .45rem;
  text-align: left;
}

.batch-item.active {
  border-color: #38bdf8;
  background: #f0f9ff;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .12);
}

.batch-item img {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  object-fit: cover;
}

.batch-item span,
.batch-item strong,
.batch-item small {
  display: block;
  min-width: 0;
}

.batch-item strong {
  overflow: hidden;
  font-size: .72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-item small {
  margin-top: .2rem;
  color: #64748b;
  font-size: .63rem;
}

.output-focus-mode .enhance-grid > aside:last-child {
  border-color: #bae6fd;
  box-shadow: 0 24px 56px rgba(14, 116, 144, .15);
}

.censor-mode .remove-card,
.censor-mode .color-row,
.censor-mode .transform-panel {
  display: none;
}

.manual-compare-mode .enhance-grid {
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.manual-compare-mode .enhance-grid > aside:last-child {
  display: none;
}

.manual-compare-mode .stage > img,
.manual-compare-mode .crop-box {
  display: none !important;
}

.manual-compare-mode .workspace-actions {
  display: none;
}

.comparison-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f8fbff;
}

.card-layout-mode .passport-grid > aside:last-child .preview-frame {
  min-height: 260px;
}

@media (max-width: 1050px) {
  .manual-compare-mode .enhance-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .photo-shell {
    width: min(100% - 20px, 1180px);
    padding-top: .75rem;
  }

  .photo-hero {
    border-radius: 22px;
  }

  .panel {
    border-radius: 16px;
  }

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

  .status-pill {
    align-self: flex-start;
  }

  .workspace-actions,
  .hero-actions {
    width: 100%;
  }

  .workspace-actions .btn,
  .hero-actions .btn {
    flex: 1 1 auto;
  }
}
