:root {
    --bg: #f7f9f8;
    --surface: #ffffff;
    --surface-muted: #f4f7f5;
    --ink: #18211d;
    --ink-strong: #111915;
    --muted: #546159;
    --border: #cbd5cf;
    --border-light: #dce3df;
    --green: #178447;
    --green-dark: #0e6535;
    --green-soft: #e9f6ee;
    --coral: #dc665f;
    --coral-soft: #fff2f1;
    --blue: #345f7d;
    --blue-soft: #edf4fb;
    --danger: #a73d37;
    --shadow: 0 12px 32px rgba(31, 48, 39, 0.07);
    --radius: 8px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; overflow-x: hidden; }
body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #ffffff 0, var(--bg) 420px);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
    overflow-x: hidden;
}
button, input { font: inherit; letter-spacing: 0; }
button, input[type="range"] { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 3px solid rgba(23, 132, 71, 0.24);
    outline-offset: 2px;
}
button:disabled, input:disabled { cursor: not-allowed; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.header-inner, .footer-inner {
    width: calc(100% - 40px);
    max-width: 1200px;
    min-height: 64px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.brand img { display: block; width: 116px; height: auto; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.tools-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #37443d;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
}
.tools-link:hover { color: var(--green-dark); }
.tools-link svg { width: 16px; height: 16px; }
.lang-switch {
    display: inline-flex;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-muted);
}
.lang-btn {
    min-width: 42px;
    min-height: 34px;
    padding: 6px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}
.lang-btn.active {
    background: var(--surface);
    color: var(--ink-strong);
    box-shadow: 0 1px 4px rgba(24, 33, 29, 0.1);
}

main {
    width: calc(100% - 40px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 42px 0 64px;
    flex: 1;
}
.intro {
    max-width: 820px;
    margin: 0 auto 28px;
    text-align: center;
}
h1 {
    max-width: 820px;
    margin: 0;
    color: var(--ink-strong);
    font-size: 48px;
    line-height: 1.06;
    font-weight: 800;
    letter-spacing: 0;
}
.intro p {
    max-width: 720px;
    margin: 12px 0 0;
    margin-inline: auto;
    color: var(--muted);
    font-size: 1rem;
}

.tool-panel {
    position: relative;
    width: 100%;
    max-width: 1040px;
    min-width: 0;
    margin: 0 auto;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.domain-banner {
    margin-bottom: 18px;
    padding: 13px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid #e8bbb8;
    border-radius: var(--radius);
    background: var(--coral-soft);
    color: #8c332e;
    font-size: 0.86rem;
    font-weight: 700;
}
.domain-banner svg { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.model-picker {
    margin: 0 0 14px;
    padding: 12px 12px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-muted);
}
.model-picker-heading {
    min-width: 0;
    margin-bottom: 9px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.model-picker-title {
    color: var(--ink-strong);
    font-size: 0.78rem;
    font-weight: 800;
}
.model-picker-note {
    min-width: 0;
    color: var(--muted);
    font-size: 0.72rem;
    text-align: right;
}
.model-options {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
}
.model-option {
    min-width: 0;
    min-height: 42px;
    padding: 8px 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: white;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
    transition: border-color 160ms ease, color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.model-option svg { width: 16px; height: 16px; flex: 0 0 auto; }
.model-option:hover:not(:disabled) { border-color: #9eb7a7; color: var(--green-dark); }
.model-option.active {
    border-color: var(--green);
    background: var(--green-soft);
    color: var(--green-dark);
    box-shadow: inset 0 0 0 1px rgba(23, 132, 71, 0.08);
}
.model-option:disabled { opacity: 0.58; }
.work-area { min-width: 0; }
.drop-zone {
    position: relative;
    width: 100%;
    min-height: 330px;
    padding: 46px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow: hidden;
    border: 1px dashed #aebfb5;
    border-radius: var(--radius);
    background: #fbfcfb;
    color: var(--ink);
    text-align: center;
    transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.drop-zone:hover:not(:disabled), .drop-zone.dragover {
    border-color: var(--green);
    background: #f7fcf9;
    box-shadow: inset 0 0 0 1px rgba(23, 132, 71, 0.08);
}
.drop-zone.dragover { transform: translateY(-1px); }
.drop-zone:disabled { opacity: 0.55; }
.upload-art {
    position: relative;
    width: 100px;
    height: 86px;
    margin-bottom: 20px;
}
.upload-art::before,
.upload-art::after {
    content: '';
    position: absolute;
    top: 11px;
    left: 23px;
    width: 54px;
    height: 54px;
    border: 1px solid #cbd7d0;
    border-radius: 7px;
    background: white;
}
.upload-art::before { transform: rotate(-9deg) translate(-9px, 3px); }
.upload-art::after { transform: rotate(9deg) translate(9px, 3px); }
.upload-icon {
    position: absolute;
    z-index: 1;
    top: 8px;
    left: 19px;
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--green);
    color: white;
    box-shadow: 0 10px 24px rgba(23, 132, 71, 0.2);
}
.upload-icon svg { width: 27px; height: 27px; }
.drop-copy { display: grid; gap: 5px; }
.drop-title { color: var(--ink-strong); font-size: 1.34rem; line-height: 1.25; font-weight: 800; }
.drop-subtitle { color: var(--muted); font-size: 0.9rem; }
.drop-action {
    min-height: 44px;
    margin-top: 22px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 7px;
    background: var(--green);
    color: white;
    font-size: 0.85rem;
    font-weight: 800;
    box-shadow: 0 7px 18px rgba(23, 132, 71, 0.16);
}
.drop-action svg { width: 17px; height: 17px; }
.drop-zone:hover:not(:disabled) .drop-action { background: var(--green-dark); }
.drop-hint { margin-top: 13px; color: #69756e; font-size: 0.76rem; }
.upload-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
    padding: 0 4px;
}
.upload-facts > span {
    min-width: 0;
    min-height: 42px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}
.upload-facts svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--green); }

.processing-state {
    min-width: 0;
}
.processing-header {
    min-height: 66px;
    padding: 4px 4px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.processing-copy { min-width: 0; display: flex; align-items: center; gap: 13px; }
.processing-copy > span:last-child { min-width: 0; display: grid; gap: 2px; }
.processing-copy strong { color: var(--ink-strong); font-size: 0.96rem; line-height: 1.25; }
.processing-copy small { overflow: hidden; color: var(--muted); font-size: 0.78rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.spinner {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border: 3px solid #d8e6dc;
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-button {
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: white;
    color: var(--muted);
}
.icon-button:hover:not(:disabled) { border-color: var(--coral); color: var(--danger); }
.icon-button svg { width: 18px; height: 18px; }
.progress-track {
    height: 6px;
    margin: 0 4px 14px;
    overflow: hidden;
    border-radius: 4px;
    background: #e1e8e4;
}
.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green-dark), var(--green));
    transition: width 220ms ease;
}
.processing-preview {
    position: relative;
    height: 470px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}
.processing-preview img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: saturate(0.86);
    opacity: 0.9;
}
.processing-shade {
    position: absolute;
    z-index: 2;
    inset: 0;
    background: rgba(255, 255, 255, 0.18);
    pointer-events: none;
}
.scan-line {
    position: absolute;
    z-index: 3;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--green);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72), 0 4px 18px rgba(23, 132, 71, 0.42);
    animation: scan 2.2s ease-in-out infinite alternate;
    pointer-events: none;
}
@keyframes scan { to { transform: translateY(466px); } }

.result-state { min-width: 0; }
.checkerboard {
    background-color: white;
    background-image:
        linear-gradient(45deg, #e8ece9 25%, transparent 25%),
        linear-gradient(-45deg, #e8ece9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8ece9 75%),
        linear-gradient(-45deg, transparent 75%, #e8ece9 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.comparison-section { margin: 0; }
.comparison-wrapper {
    --image-ratio: 4 / 3;
    --comparison-width: 100%;
    position: relative;
    width: 100%;
    aspect-ratio: var(--image-ratio);
    max-height: 700px;
    min-height: 360px;
    overflow: hidden;
    border: 1px solid #bcc9c1;
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 10px 28px rgba(31, 48, 39, 0.08);
    user-select: none;
}
.compare-result-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.compare-original-layer {
    position: absolute;
    inset: 0 auto 0 0;
    width: 50%;
    overflow: hidden;
}
.compare-original-layer img {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--comparison-width);
    max-width: none;
    height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: none;
}
.compare-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    transform: translateX(-50%);
    background: white;
    box-shadow: 0 0 0 1px rgba(14, 101, 53, 0.24), 0 0 9px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}
.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 46px;
    height: 46px;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    border: 3px solid white;
    border-radius: 50%;
    background: var(--green);
    color: white;
    box-shadow: 0 7px 20px rgba(24, 33, 29, 0.24);
    pointer-events: none;
    z-index: 3;
}
.compare-handle svg { width: 20px; height: 20px; }
.compare-label {
    position: absolute;
    top: 14px;
    z-index: 2;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 6px;
    color: var(--ink-strong);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.35;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}
.compare-label-original { left: 14px; background: rgba(255, 255, 255, 0.86); }
.compare-label-result { right: 14px; background: rgba(233, 246, 238, 0.9); color: var(--green-dark); }
.compare-range {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
}
.result-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 9px;
    margin-top: 18px;
}
.button {
    min-height: 46px;
    padding: 10px 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 7px;
    font-size: 0.84rem;
    font-weight: 800;
}
.button svg { width: 17px; height: 17px; }
.button.primary { border: 1px solid var(--green); background: var(--green); color: white; }
.button.primary:hover:not(:disabled) { border-color: var(--green-dark); background: var(--green-dark); }
.button.secondary { border: 1px solid var(--border); background: white; color: var(--ink); }
.button.secondary:hover:not(:disabled) { border-color: var(--green); color: var(--green-dark); }
.button.ghost { border: 1px solid transparent; background: var(--surface-muted); color: var(--muted); }
.button.ghost:hover:not(:disabled) { color: var(--ink); }

.status {
    min-height: 44px;
    margin-top: 16px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 0.8rem;
    font-weight: 700;
}
.status svg { width: 17px; height: 17px; flex: 0 0 auto; }
.status.success { border-color: #bad9c6; background: var(--green-soft); color: var(--green-dark); }
.status.error { border-color: #e8bbb8; background: var(--coral-soft); color: var(--danger); }
.status.loading svg { animation: spin 0.8s linear infinite; }

.site-footer { border-top: 1px solid var(--border-light); background: white; }
.footer-inner { min-height: 76px; color: var(--muted); font-size: 0.8rem; }
.footer-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.footer-link:hover { color: var(--green-dark); text-decoration: underline; }

.is-locked [data-requires-license] { pointer-events: none; }
.is-locked .work-area { filter: grayscale(0.28); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 900px) {
    h1 { font-size: 42px; }
    .drop-zone { min-height: 320px; }
    .processing-preview { height: 420px; }
    @keyframes scan { to { transform: translateY(416px); } }
}

@media (max-width: 680px) {
    .header-inner, .footer-inner, main { width: calc(100% - 28px); }
    .header-inner { min-height: 60px; gap: 12px; }
    .brand img { width: 102px; }
    .header-actions { gap: 9px; }
    .tools-link span { display: none; }
    .tools-link { width: 34px; height: 34px; justify-content: center; }
    .lang-btn { min-width: 38px; min-height: 32px; padding: 5px 8px; }
    main { padding: 30px 0 46px; }
    h1 { font-size: 34px; line-height: 1.1; }
    .intro p { font-size: 0.9rem; }
    .intro { margin-bottom: 22px; }
    .tool-panel { padding: 10px; }
    .domain-banner { margin-bottom: 10px; }
    .model-picker { margin-bottom: 10px; padding: 10px 9px 9px; }
    .model-picker-heading { display: grid; gap: 2px; margin-bottom: 8px; }
    .model-picker-note { text-align: left; }
    .model-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
    .model-option { min-height: 40px; }
    .model-option:last-child { grid-column: 1 / -1; }
    .drop-zone { min-height: 300px; padding: 30px 14px; }
    .drop-title { font-size: 1.18rem; }
    .drop-subtitle { font-size: 0.84rem; }
    .processing-header { padding: 6px 2px 12px; }
    .processing-preview { height: 340px; }
    @keyframes scan { to { transform: translateY(336px); } }
    .comparison-wrapper { min-height: 280px; }
    .compare-handle { width: 40px; height: 40px; }
    .compare-label { top: 10px; }
    .compare-label-original { left: 10px; }
    .compare-label-result { right: 10px; }
    .result-actions { display: grid; grid-template-columns: 1fr; }
    .button { width: 100%; }
    .upload-facts { grid-template-columns: 1fr; gap: 2px; padding: 0; }
    .upload-facts > span { justify-content: flex-start; text-align: left; }
    .footer-inner { min-height: 70px; padding: 14px 0; flex-wrap: wrap; }
}

@media (max-width: 390px) {
    h1 { font-size: 31px; }
    .drop-zone { min-height: 290px; }
    .processing-preview { height: 300px; }
    @keyframes scan { to { transform: translateY(296px); } }
    .comparison-wrapper { min-height: 260px; }
}
