:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-secondary: #71717a;
  --text-tertiary: #a1a1aa;
  --accent: #18181b;
  --accent-hover: #3f3f46;
  --include: #16a34a;
  --exclude: #dc2626;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--text);
}

.brand__mark {
  color: var(--text);
  flex-shrink: 0;
}

.brand__name {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.support-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.support-link:hover {
  color: var(--text);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.lang-select {
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  padding-right: 1.75rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: border-color 0.15s, color 0.15s;
}

.lang-select:hover,
.lang-select:focus {
  color: var(--text);
  border-color: var(--border-strong);
  outline: none;
}

@media (max-width: 480px) {
  .header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .header__actions {
    width: 100%;
    justify-content: flex-end;
  }

  .support-link {
    font-size: 0.75rem;
  }
}

/* Landing */
.landing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  padding: 0.5rem 0 1rem;
}

.landing__hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 2.5rem;
  align-items: center;
  width: 100%;
}

.landing__cta {
  display: flex;
  justify-content: center;
}

.upload__card {
  width: 100%;
  max-width: 440px;
  padding: 3rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

/* Demo showcase */
.demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
}

.demo__frame {
  width: 100%;
  max-width: 380px;
}

.demo__photo {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

.demo__photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 62%
  );
  transform: translateX(-120%);
  z-index: 6;
  pointer-events: none;
  animation: demo-shine 12s ease-in-out infinite;
}

.demo__bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, #bfdbfe 0%, #93c5fd 35%, #86efac 68%, #4ade80 100%);
  animation: demo-bg-fade 12s ease-in-out infinite;
}

.demo__checker {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-color: #f4f4f5;
  background-image:
    linear-gradient(45deg, #e4e4e7 25%, transparent 25%),
    linear-gradient(-45deg, #e4e4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e4e4e7 75%),
    linear-gradient(-45deg, transparent 75%, #e4e4e7 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  animation: demo-checker-in 12s ease-in-out infinite;
}

.demo__source,
.demo__cutout {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  z-index: 2;
}

.demo__source {
  animation: demo-source 12s ease-in-out infinite;
}

.demo__cutout {
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.12));
  animation: demo-cutout 12s ease-in-out infinite;
}

@keyframes demo-source {
  0%, 38% { opacity: 1; transform: scale(1); }
  42%, 92% { opacity: 0; transform: scale(1.02); }
  96%, 100% { opacity: 1; transform: scale(1); }
}

@keyframes demo-cutout {
  0%, 38% { opacity: 0; transform: scale(0.98); }
  42%, 86% { opacity: 1; transform: scale(1); }
  92%, 100% { opacity: 0; transform: scale(1.01); }
}

.demo__fuzz {
  position: absolute;
  right: 10%;
  top: 22%;
  width: 2.75rem;
  height: 1.75rem;
  border-radius: 40% 60% 50% 50%;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  opacity: 0;
  z-index: 3;
  transform: rotate(-12deg);
  animation: demo-fuzz 12s ease-in-out infinite;
}

.demo__refine-glow {
  position: absolute;
  left: 50%;
  top: 28%;
  width: 9rem;
  height: 11rem;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 2px solid rgba(22, 163, 74, 0.55);
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.25);
  z-index: 1;
  opacity: 0;
  animation: demo-refine-glow 12s ease-in-out infinite;
}

.demo__scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  top: -40%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 42%,
    rgba(24, 24, 27, 0.12) 50%,
    rgba(255, 255, 255, 0.55) 58%,
    transparent 100%
  );
  opacity: 0;
  z-index: 3;
  animation: demo-scan 12s ease-in-out infinite;
}

.demo__marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  z-index: 5;
  opacity: 0;
  transform: scale(0);
}

.demo__marker--keep {
  left: 48%;
  top: 38%;
  background: var(--include);
  animation: demo-marker-keep 12s ease-in-out infinite;
}

.demo__marker--remove {
  right: 12%;
  top: 18%;
  background: var(--exclude);
  animation: demo-marker-remove 12s ease-in-out infinite;
}

.demo__upload-float {
  position: absolute;
  top: 12%;
  right: 12%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 5;
  animation: demo-upload-float 12s ease-in-out infinite;
}

.demo__result-badge {
  position: absolute;
  bottom: 10%;
  right: 10%;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  z-index: 5;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  animation: demo-result-badge 12s ease-in-out infinite;
}

.demo__progress {
  display: flex;
  justify-content: center;
  gap: 0.375rem;
  margin-top: 0.875rem;
}

.demo__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}

.demo__dot--1 { animation: demo-dot 12s ease-in-out infinite; }
.demo__dot--2 { animation: demo-dot 12s ease-in-out infinite 3s; }
.demo__dot--3 { animation: demo-dot 12s ease-in-out infinite 6s; }
.demo__dot--4 { animation: demo-dot 12s ease-in-out infinite 9s; }

.demo__captions {
  position: relative;
  min-height: 2.5rem;
  margin-top: 0.5rem;
  text-align: center;
}

.demo__caption {
  position: absolute;
  inset: 0;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  opacity: 0;
  transform: translateY(6px);
}

.demo__caption--1 { animation: demo-caption 12s ease-in-out infinite; }
.demo__caption--2 { animation: demo-caption 12s ease-in-out infinite 3s; }
.demo__caption--3 { animation: demo-caption 12s ease-in-out infinite 6s; }
.demo__caption--4 { animation: demo-caption 12s ease-in-out infinite 9s; }

.demo__outcome {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-align: center;
  max-width: 320px;
}

@keyframes demo-upload-float {
  0%, 4% { opacity: 0; transform: translateY(-12px) scale(0.85); }
  7%, 20% { opacity: 1; transform: translateY(0) scale(1); }
  24%, 100% { opacity: 0; transform: translateY(6px) scale(0.9); }
}

@keyframes demo-scan {
  0%, 22% { opacity: 0; top: -40%; }
  26% { opacity: 1; top: -10%; }
  42% { opacity: 1; top: 110%; }
  46%, 100% { opacity: 0; top: 110%; }
}

@keyframes demo-bg-fade {
  0%, 26% { opacity: 1; }
  40%, 84% { opacity: 0; }
  94%, 100% { opacity: 1; }
}

@keyframes demo-checker-in {
  0%, 34% { opacity: 0; }
  42%, 86% { opacity: 1; }
  94%, 100% { opacity: 0; }
}

@keyframes demo-fuzz {
  0%, 42% { opacity: 0; transform: rotate(-12deg) scale(0.8); }
  46%, 58% { opacity: 0.95; transform: rotate(-12deg) scale(1); }
  62% { opacity: 0.95; transform: rotate(-12deg) scale(1); }
  68%, 100% { opacity: 0; transform: rotate(-12deg) scale(0.4); }
}

@keyframes demo-marker-keep {
  0%, 48% { opacity: 0; transform: scale(0); }
  52%, 58% { opacity: 1; transform: scale(1.15); }
  62%, 100% { opacity: 1; transform: scale(1); }
}

@keyframes demo-marker-remove {
  0%, 58% { opacity: 0; transform: scale(0); }
  62%, 68% { opacity: 1; transform: scale(1.2); }
  72%, 100% { opacity: 0; transform: scale(0.5); }
}

@keyframes demo-refine-glow {
  0%, 48% { opacity: 0; box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
  52%, 72% { opacity: 1; box-shadow: 0 0 18px 4px rgba(22, 163, 74, 0.22); }
  76%, 100% { opacity: 0; box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

@keyframes demo-result-badge {
  0%, 76% { opacity: 0; transform: translateY(8px) scale(0.9); }
  80%, 92% { opacity: 1; transform: translateY(0) scale(1); }
  96%, 100% { opacity: 0; transform: translateY(-4px) scale(0.95); }
}

@keyframes demo-caption {
  0%, 4%, 25%, 100% { opacity: 0; transform: translateY(6px); }
  7%, 20% { opacity: 1; transform: translateY(0); }
}

@keyframes demo-dot {
  0%, 4%, 25%, 100% { background: var(--border); transform: scale(1); }
  7%, 20% { background: var(--text); transform: scale(1.35); }
}

@keyframes demo-shine {
  0%, 78% { transform: translateX(-120%); opacity: 0; }
  82% { opacity: 1; }
  90% { transform: translateX(120%); opacity: 0; }
  100% { transform: translateX(120%); opacity: 0; }
}

@media (max-width: 860px) {
  .landing__hero {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .landing__demo {
    order: -1;
  }

  .demo__frame {
    max-width: 340px;
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo__bg,
  .demo__checker,
  .demo__scan,
  .demo__marker,
  .demo__upload-float,
  .demo__result-badge,
  .demo__source,
  .demo__cutout,
  .demo__fuzz,
  .demo__refine-glow,
  .demo__caption,
  .demo__dot,
  .demo__photo::after {
    animation: none;
  }

  .demo__bg { opacity: 0.35; }
  .demo__checker { opacity: 1; }
  .demo__source { opacity: 0; }
  .demo__cutout { opacity: 1; }
  .demo__fuzz { opacity: 0; }
  .demo__marker--keep { opacity: 1; transform: scale(1); }
  .demo__refine-glow { opacity: 0.6; }
  .demo__caption--4 { opacity: 1; transform: none; }
  .demo__result-badge { opacity: 1; transform: none; }
  .demo__dot--4 { background: var(--text); }
}

.upload__card:hover,
.upload__card.dragover {
  border-color: var(--border-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.upload__logo {
  color: var(--text);
  margin: 0 auto 1.5rem;
  display: block;
}

.upload__title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.upload__text {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

.upload__hint {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5625rem 1.125rem;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

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

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

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

.btn--text {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
}

.btn--text:hover:not(:disabled) {
  color: var(--text);
}

/* Editor */
.hidden {
  display: none !important;
}

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.editor__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.editor__actions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.editor__status {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.25rem 0;
}

.editor__status.is-loading {
  color: var(--text);
}

.editor__status.is-done {
  color: var(--include);
}

/* Mode tabs */
.mode-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.mode-tab {
  padding: 0.4rem 0.875rem;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-tab--active {
  background: var(--text);
  color: #fff;
}

/* Auto view — processing animation */
.auto-view {
  margin-top: 0.5rem;
}

.auto-stage {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.auto-stage__frame {
  position: relative;
  background: #f4f4f5;
  background-image:
    linear-gradient(45deg, #e4e4e7 25%, transparent 25%),
    linear-gradient(-45deg, #e4e4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e4e4e7 75%),
    linear-gradient(-45deg, transparent 75%, #e4e4e7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.auto-stage__canvas {
  display: block;
  max-width: 100%;
  max-height: 520px;
  width: 100%;
  height: auto;
}

.auto-stage__canvas--result {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.auto-stage--done .auto-stage__canvas--result {
  opacity: 1;
  transform: scale(1);
}

.auto-stage--done .auto-stage__canvas:not(.auto-stage__canvas--result) {
  visibility: hidden;
}

.auto-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(1px);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.auto-stage--done .auto-overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auto-overlay__scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(24, 24, 27, 0.06) 45%,
    rgba(24, 24, 27, 0.14) 50%,
    rgba(24, 24, 27, 0.06) 55%,
    transparent 100%
  );
  background-size: 100% 200%;
  animation: auto-scan 1.8s ease-in-out infinite;
}

@keyframes auto-scan {
  0% { background-position: 0 -100%; }
  100% { background-position: 0 100%; }
}

.auto-overlay__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.auto-overlay__ring {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.auto-overlay__text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Refine view */
.refine-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.refine-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.refine-toolbar__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  flex-wrap: wrap;
}

.refine-toolbar__group {
  display: flex;
  align-items: center;
}

.refine-toolbar__group--end {
  margin-left: auto;
}

@media (min-width: 769px) {
  .refine-toolbar__group + .refine-toolbar__group {
    padding-left: 0.75rem;
    margin-left: 0.125rem;
    border-left: 1px solid var(--border);
  }
}

.refine-toolbar__hint {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.refine-toolbar__hint-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: var(--text-tertiary);
  opacity: 0.85;
}

.refine-toolbar__hint-text {
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--text-tertiary);
}

.refine-toolbar__hint-text--mobile {
  display: none;
}

.refine-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}

.refine-action {
  padding: 0.4rem 0.625rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.refine-action:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg);
}

.refine-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tool-group {
  display: inline-flex;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  gap: 2px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.tool-btn + .tool-btn {
  border-left: none;
}

.tool-btn:hover:not(.tool-btn--active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.tool-btn--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tool-btn__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tool-btn__dot--green { background: var(--include); }
.tool-btn__dot--red { background: var(--exclude); }

.tool-btn__icon {
  flex-shrink: 0;
  opacity: 0.75;
}

.tool-btn--active .tool-btn__icon {
  opacity: 1;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.zoom-controls__sep {
  width: 1px;
  height: 1.25rem;
  margin: 0 0.125rem;
  background: var(--border);
}

.zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.zoom-btn:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
}

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

.zoom-controls__label {
  min-width: 2.75rem;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.zoom-btn--text {
  width: auto;
  min-width: 3.25rem;
  padding: 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

@media (max-width: 768px) {
  .refine-toolbar__hint-text--desktop {
    display: none;
  }

  .refine-toolbar__hint-text--mobile {
    display: inline;
  }

  .refine-toolbar__main {
    justify-content: center;
  }

  .refine-toolbar__group + .refine-toolbar__group {
    padding-left: 0;
    margin-left: 0;
    border-left: none;
  }

  .refine-toolbar__group--end {
    margin-left: 0;
    width: 100%;
    justify-content: center;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .refine-toolbar__main {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .refine-toolbar__group {
    justify-content: center;
  }

  .refine-toolbar__group--end {
    padding-top: 0.5rem;
  }

  .tool-group,
  .zoom-controls {
    width: 100%;
    justify-content: center;
  }

  .zoom-btn {
    width: 2.25rem;
    height: 2.25rem;
  }

  .tool-btn {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.5rem;
    min-height: 2.25rem;
  }

  .refine-actions {
    width: 100%;
    justify-content: center;
  }

  .refine-action {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
  }
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.frame__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.frame__hint,
.frame__count {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-tertiary);
}

.frame__body {
  position: relative;
  min-height: 300px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 1.25rem;
}

.source-viewport {
  width: 100%;
  max-height: 440px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.source-viewport--pan-tool,
.source-viewport--space-pan {
  cursor: grab;
}

.source-viewport--panning {
  cursor: grabbing;
  user-select: none;
}

.source-viewport--pan-tool .source-stack,
.source-viewport--panning .source-stack {
  pointer-events: none;
}

@media (max-width: 768px) {
  .source-viewport {
    max-height: min(42vh, 360px);
  }

  .frame__body {
    padding: 0.75rem;
    min-height: 240px;
  }

  .landing {
    min-height: auto;
    padding-bottom: 0;
  }

  .upload__card {
    padding: 2rem 1.25rem;
  }

  .editor__top {
    flex-direction: column;
    align-items: stretch;
  }

  .editor__actions {
    justify-content: flex-start;
  }

  .page {
    padding: 1rem 1rem 2rem;
  }
}

.source-viewport::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.source-viewport::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.source-stack {
  position: relative;
  flex-shrink: 0;
  line-height: 0;
}

.frame__body--checker {
  background-color: #f4f4f5;
  background-image:
    linear-gradient(45deg, #e4e4e7 25%, transparent 25%),
    linear-gradient(-45deg, #e4e4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e4e4e7 75%),
    linear-gradient(-45deg, transparent 75%, #e4e4e7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

canvas {
  max-width: 100%;
  max-height: 440px;
  display: block;
}

.source-stack canvas {
  max-width: none;
  max-height: none;
}

.canvas--include {
  cursor: crosshair;
}

.canvas--exclude {
  cursor: not-allowed;
}

.canvas--pan {
  cursor: grab;
}

.source-viewport--panning .canvas--pan {
  cursor: grabbing;
}

.overlay-canvas {
  position: absolute;
  pointer-events: none;
}

/* Mask picker */
.mask-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mask-picker__label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mask-picker__options {
  display: flex;
  gap: 0.5rem;
}

.mask-option {
  padding: 2px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s;
}

.mask-option:hover {
  border-color: var(--border-strong);
}

.mask-option--active {
  border-color: var(--text);
}

.mask-option img {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 4px;
}

/* Markers */
.markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s;
}

.marker:hover {
  transform: translate(-50%, -50%) scale(1.25);
}

@media (pointer: coarse) {
  .marker {
    width: 18px;
    height: 18px;
    border-width: 2.5px;
  }
}

.marker--include {
  background: var(--include);
}

.marker--exclude {
  background: var(--exclude);
}

/* Loader */
.loader {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.loader__ring {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 2.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--text);
}

.footer__sep {
  margin: 0 0.375rem;
}

.footer__legal {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  opacity: 0.85;
}

.footer__legal:hover {
  color: var(--text-secondary);
}

/* Full-screen upload feedback */
.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
}

.upload-overlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: min(100%, 320px);
  text-align: center;
}

.upload-overlay__preview {
  display: block;
  width: min(72vw, 220px);
  height: min(72vw, 220px);
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #f4f4f5;
  box-shadow: 0 12px 40px rgba(24, 24, 27, 0.12);
}

.upload-overlay__spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid #e4e4e7;
  border-top-color: var(--accent, #18181b);
  border-radius: 50%;
  animation: upload-spin 0.75s linear infinite;
}

.upload-overlay__text {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.upload__card--busy {
  opacity: 0.72;
  pointer-events: none;
}

@keyframes upload-spin {
  to {
    transform: rotate(360deg);
  }
}

.consent {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(24, 24, 27, 0.2);
  pointer-events: none;
}

.consent:not(.hidden) {
  pointer-events: auto;
}

@media (min-width: 520px) {
  .consent {
    align-items: center;
  }
}

.consent__panel {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
}

.consent__title {
  margin: 0 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.consent__lead {
  margin: 0 0 0.875rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.consent__links {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
}

.consent__official {
  margin: 0 0 1.25rem;
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--text-tertiary);
}

.consent__links a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.consent__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.page--legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.header--legal {
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
}

.legal-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-left: auto;
}

.legal-lang-select {
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.legal__notice {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-size: 0.6875rem;
}

.legal-nav a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.legal-nav a:hover {
  color: var(--text);
}

.legal {
  padding: 1.5rem 0 2rem;
  font-size: 0.75rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.legal__meta {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin-bottom: 2rem;
}

.legal__section {
  margin-bottom: 2.5rem;
}

.legal__section h1 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.legal__section h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.5rem;
}

.legal__section p,
.legal__section li {
  margin: 0 0 0.75rem;
}

.legal__section ul {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.legal__section a {
  color: var(--text-secondary);
}

.legal__section code {
  font-size: 0.6875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.legal__footer-note {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.footer--legal {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* SEO content */
.info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .info {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.info__story {
  grid-column: 1 / -1;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(165deg, var(--surface) 0%, rgba(244, 244, 245, 0.45) 100%);
}

.info__story h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 0.75rem;
}

.info__story-lead {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 1rem;
  max-width: 52rem;
}

.info__why-list {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  max-width: 52rem;
}

.info__why-list li {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 0.4rem;
}

.info__why-list li:last-child {
  margin-bottom: 0;
}

.info__story-close {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  max-width: 52rem;
  font-style: italic;
}

.info__block h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.625rem;
}

.info__block p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info__block p strong {
  font-weight: 500;
  color: var(--text);
}

.info__steps {
  list-style: none;
  counter-reset: step;
}

.info__steps li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info__steps li + li {
  margin-top: 0.375rem;
}

.info__steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.info__faq div + div {
  margin-top: 0.875rem;
}

.info__faq dt {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.125rem;
}

.info__faq dd {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
}