:root {
  color-scheme: light;
  --accent: #0f172a;
  --font-heading: "Barlow Condensed", Arial, sans-serif;
  --font-body: "IBM Plex Sans", Arial, sans-serif;
  --content-gutter: 1.5rem;
  --surface-border: rgba(0, 0, 0, 0.1);
  --text-main: rgba(0, 0, 0, 0.82);
  --text-muted: rgba(0, 0, 0, 0.62);
  --check-light: #d9d9d9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body), Arial, sans-serif;
  background: #000;
  color: var(--text-main);
}

.app-shell {
  min-height: 100vh;
  background: #000;
}

.site-surface {
  min-height: 100vh;
  background-color: #fff;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 120px 120px;
}

.site-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #000;
}

.site-nav-wrap {
  position: relative;
  width: min(100%, 64rem);
  margin: 0 auto;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}

.site-logo-link {
  display: inline-flex;
  align-items: center;
}

.site-logo {
  height: 2.45rem;
  width: auto;
}

.site-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.site-back-link {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid #fff;
  background: #fff;
  color: #000;
  padding: 0.6rem 1rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.site-back-link:hover {
  border-color: #fff;
  background: #000;
  color: #fff;
}

.page-hero {
  border-bottom: 1px solid var(--surface-border);
  padding: 1.2rem var(--content-gutter) 0.9rem;
}

.site-header-inner {
  width: min(100%, 64rem);
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-family: var(--font-heading), Arial, sans-serif;
  font-size: clamp(2.25rem, 4vw, 4rem);
  line-height: 1.08;
  font-weight: 600;
  color: #000;
}

.lead {
  margin: 0.75rem 0 0;
  max-width: 56rem;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.accent-rule {
  height: 4px;
  width: 80px;
  background: var(--accent);
  margin-top: 0.65rem;
}

.micro-label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.5);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.preview-header .micro-label {
  margin: 0;
}

.preview-header-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.preview-replace-photo-btn {
  min-height: 38px;
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 999px;
  background: #fff;
  color: rgba(0, 0, 0, 0.8);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.36rem 0.8rem;
  cursor: pointer;
}

.preview-grayscale-toggle {
  min-height: 38px;
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 999px;
  background: #fff;
  color: rgba(0, 0, 0, 0.8);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.36rem 0.8rem;
  cursor: pointer;
}

.preview-replace-photo-btn:hover,
.preview-grayscale-toggle:hover {
  border-color: rgba(0, 0, 0, 0.5);
  color: #000;
}

.preview-grayscale-toggle.is-active {
  background: #111;
  border-color: #111;
  color: #fff;
}

.preview-controls-menu {
  position: relative;
}

.preview-controls-menu[hidden] {
  display: none !important;
}

.preview-controls-menu summary {
  list-style: none;
}

.preview-controls-menu summary::-webkit-details-marker {
  display: none;
}

.preview-gear-btn {
  min-width: 38px;
  min-height: 38px;
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 999px;
  background: #fff;
  color: rgba(0, 0, 0, 0.8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.preview-gear-btn:hover {
  border-color: rgba(0, 0, 0, 0.5);
  color: #000;
}

.preview-gear-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.preview-controls-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 0.7rem;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.preview-controls-menu:not([open]) .preview-controls-popover {
  display: none;
}

.preview-size-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.preview-size-control input[type="range"] {
  width: 118px;
  min-height: 34px;
}

.preview-size-row {
  padding-bottom: 0.28rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.preview-contrast-row {
  padding-top: 0.28rem;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.resize-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  font-size: 1.25rem;
  color: rgba(0, 0, 0, 0.68);
  line-height: 1;
  user-select: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.layout {
  width: min(calc(100% - (var(--content-gutter) * 2)), 64rem);
  margin: 0 auto;
  padding: 1.1rem 0 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0.8rem;
  align-items: stretch;
  min-height: 200px;
}

.panel {
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  background: #fff;
  padding: 0.85rem;
}

.control-label {
  display: block;
  margin: 0.9rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.56);
}

.drop {
  border: 1.5px dashed rgba(0, 0, 0, 0.3);
  border-radius: 1rem;
  min-height: 92px;
  padding: 1rem;
  display: grid;
  place-items: center;
  gap: 0.4rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.03);
  transition: border-color 160ms ease, background 160ms ease;
}

.drop.active {
  border-color: var(--accent);
  background: rgba(127, 29, 29, 0.08);
}

.drop-small {
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.48);
}

.form-control,
input[type="range"] {
  width: 100%;
  min-height: 44px;
}

.hidden-file-input {
  display: none;
}

.form-control {
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  background: #fff;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: #000;
}

select.form-control {
  font-weight: 600;
}

.overlay-panel {
  height: 100%;
  padding-bottom: 0.8rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overlay-strip {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.15rem 0.2rem 0.4rem 0.1rem;
  flex: 1;
  min-height: 0;
  scrollbar-gutter: stable;
}

.overlay-controls {
  margin-top: 0.2rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.overlay-control {
  border: 1px solid var(--surface-border);
  border-radius: 0.75rem;
  padding: 0.42rem;
  background: #fff;
}

.overlay-control-label {
  margin: 0 0 0.35rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.56);
}

.overlay-control-options {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.overlay-swatch {
  width: 20px;
  height: 20px;
  border-radius: 0.35rem;
  border: 1.5px solid rgba(0, 0, 0, 0.45);
  cursor: pointer;
  padding: 0;
  margin: 0;
  background: #fff;
}

.overlay-swatch:hover {
  border-color: rgba(0, 0, 0, 0.78);
}

.overlay-swatch.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(127, 29, 29, 0.28);
}

.overlay-swatch.is-transparent {
  background:
    linear-gradient(45deg, #e4e4e4 25%, transparent 25%) -4px 0 / 8px 8px,
    linear-gradient(-45deg, #e4e4e4 25%, transparent 25%) -4px 0 / 8px 8px,
    linear-gradient(45deg, transparent 75%, #e4e4e4 75%) -4px 0 / 8px 8px,
    linear-gradient(-45deg, transparent 75%, #e4e4e4 75%) -4px 0 / 8px 8px;
}

.overlay-card {
  flex: 0 0 auto;
  width: 100%;
  border: 1px solid var(--surface-border);
  border-radius: 0.95rem;
  background: #fff;
  padding: 0.3rem;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 0.3rem;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.overlay-card:hover {
  border-color: rgba(0, 0, 0, 0.38);
}

.overlay-card.is-selected {
  border-color: var(--accent);
  background: rgba(127, 29, 29, 0.05);
}

.overlay-thumb {
  width: 100%;
  height: 70px;
  border: 1px solid var(--surface-border);
  border-radius: 0.7rem;
  padding: 0.35rem;
  object-fit: contain;
  background:
    repeating-conic-gradient(
      #c2c2c2 0 25%,
      #e0e0e0 0 50%
    ) 0 0 / 24px 24px;
}

.overlay-preview-btn {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 0.65rem;
}

.overlay-preview-btn:focus-visible {
  outline: 2px solid rgba(127, 29, 29, 0.4);
  outline-offset: 2px;
}

.overlay-nav {
  width: 24px;
  height: 24px;
  border: 1px solid var(--surface-border);
  border-radius: 9999px;
  background: #fff;
  color: rgba(0, 0, 0, 0.75);
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.overlay-nav:hover {
  border-color: rgba(0, 0, 0, 0.5);
  color: #000;
}

.overlay-nav:focus-visible {
  outline: 2px solid rgba(127, 29, 29, 0.4);
  outline-offset: 2px;
}

.overlay-empty {
  border: 1px solid var(--surface-border);
  border-radius: 0.9rem;
  padding: 0.7rem 0.8rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-control:focus-visible,
input[type="range"]:focus-visible,
button:focus-visible,
.site-back-link:focus-visible {
  outline: 2px solid rgba(127, 29, 29, 0.35);
  outline-offset: 2px;
}

.meta {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: center;
}

.range-row input[type="range"] {
  min-height: 44px;
}

.range-value {
  min-width: 3.9rem;
  text-align: right;
  font-weight: 600;
  color: #000;
}

.button-row {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  padding: 0.75rem 1.2rem;
  font-size: 0.85rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid #000;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

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

.btn-primary {
  background: #000;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  color: #000;
}

.btn-secondary {
  background: #fff;
  color: #000;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.6);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

.canvas-wrap {
  flex: 1;
  min-height: 120px;
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  padding: 0.65rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    repeating-linear-gradient(
      to right,
      rgba(0, 0, 0, 0.13) 0 1px,
      transparent 1px 36px
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.13) 0 1px,
      transparent 1px 36px
    ),
    linear-gradient(#f4f4f4, #f4f4f4);
}

.canvas-wrap.can-open-file {
  cursor: pointer;
}

.canvas-wrap.is-drop-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.1);
}

canvas {
  width: auto;
  height: auto;
  display: block;
  background: #fff;
  margin: 0 auto;
}

.position-dots {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.position-dot {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border-radius: 9999px;
  border: 1.5px solid rgba(0, 0, 0, 0.9);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, background-color 140ms ease;
}

.position-dots.is-visible .position-dot {
  opacity: 1;
  pointer-events: auto;
}

.position-dot:hover {
  background: rgba(255, 255, 255, 0.86);
}

.position-dot.is-active {
  display: none;
}

.preview-primary-actions {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 0.55rem;
  padding-top: clamp(0.35rem, 1.2vh, 0.65rem);
}

.download-btn {
  width: 100%;
  min-width: 0;
}

.advanced-inline-btn {
  min-width: 0;
  padding: 0.72rem 0.7rem;
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  gap: 0.35rem;
}

.advanced-inline-btn::after {
  content: "+";
  font-size: 1rem;
  line-height: 1;
}

.advanced-inline-btn.is-open::after {
  content: "-";
}

.advanced-panel {
  padding: 0.7rem 0.9rem 0.95rem;
}

.advanced-content {
  margin-top: 0;
  padding-top: 0;
}

@media (max-width: 900px) {
  :root {
    --content-gutter: 1rem;
  }

  .site-nav {
    padding: 1rem;
  }

  .site-logo {
    height: 2rem;
  }

  .site-back-link {
    display: none;
  }

  .page-hero {
    padding: 1.05rem var(--content-gutter) 0.8rem;
  }

  .layout {
    padding: 0.9rem 0 1rem;
  }

  .editor-row {
    grid-template-columns: 1fr;
  }

  .overlay-panel {
    order: 1;
  }

  .preview-panel {
    order: 2;
  }

  .overlay-strip {
    height: clamp(240px, 40vh, 360px);
    min-height: 0;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.58rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.2rem 0.15rem 0.35rem 0.1rem;
  }

  .overlay-card {
    width: 100%;
    min-width: 0;
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    padding: 0.34rem;
    gap: 0.32rem;
  }

  .overlay-thumb {
    height: 64px;
  }

  .overlay-nav {
    width: 26px;
    height: 26px;
  }

  .overlay-controls {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    min-height: 220px;
  }

}

@media (min-width: 640px) {
  .btn {
    border-radius: 9999px;
  }
}
