:root {
    --paper: #f5f3ee;
    --surface: #ffffff;
    --ink: #16201d;
    --muted: #66706c;
    --line: #dedfd9;
    --accent: #2c5b4c;
    --accent-dark: #20473b;
    --accent-soft: #dce8e2;
    --success: #26745d;
    --danger: #a13d3d;
    --shadow: 0 24px 60px rgba(22, 32, 29, 0.10);
    --radius-lg: 26px;
    --radius-md: 17px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 88% 4%, rgba(44, 91, 76, 0.10), transparent 26rem),
        var(--paper);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
label {
    font: inherit;
}

button,
label[for] {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
}

.topbar {
    display: flex;
    width: min(100%, 760px);
    margin: 0 auto;
    padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-decoration: none;
}

.brand-mark {
    position: relative;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 9px;
    background: var(--ink);
    transform: rotate(8deg);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
    position: absolute;
    width: 4px;
    height: 14px;
    border-radius: 4px;
    background: var(--paper);
    content: "";
}

.brand-mark::before {
    left: 7px;
}

.brand-mark::after {
    right: 7px;
}

.brand-mark span {
    width: 12px;
    height: 4px;
}

.privacy-badge {
    display: inline-flex;
    min-height: 32px;
    padding: 7px 10px;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(44, 91, 76, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.54);
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.privacy-badge > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #39a77c;
    box-shadow: 0 0 0 4px rgba(57, 167, 124, 0.12);
}

.main-content {
    width: min(100%, 620px);
    margin: 0 auto;
    padding: 10px 18px 32px;
}

.intro {
    text-align: center;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.intro h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(42px, 13vw, 68px);
    font-weight: 500;
    letter-spacing: -0.052em;
    line-height: 0.95;
}

.intro > p:last-child {
    max-width: 390px;
    margin: 20px auto 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.55;
}

.step-row {
    display: grid;
    grid-template-columns: auto minmax(30px, 1fr) auto;
    margin: 14px auto 16px;
    padding: 0 10px;
    align-items: center;
    gap: 10px;
}

.step {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #929995;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.step span {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.step.is-active {
    color: var(--ink);
}

.step.is-active span,
.step.is-done span {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.step-line {
    height: 1px;
    background: var(--line);
}

.work-card {
    overflow: hidden;
    border: 1px solid rgba(22, 32, 29, 0.08);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.view {
    padding: 34px 22px 26px;
    text-align: center;
}

.view.is-visible {
    animation: view-in 260ms ease-out both;
}

.view h2 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -0.025em;
}

.view > p {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.upload-visual {
    position: relative;
    display: grid;
    width: 86px;
    height: 86px;
    margin: 0 auto 22px;
    place-items: center;
    border-radius: 25px;
    background: var(--accent-soft);
}

.photo-shape {
    position: relative;
    width: 39px;
    height: 33px;
    overflow: hidden;
    border: 2px solid var(--accent);
    border-radius: 7px;
}

.photo-shape::before {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    content: "";
}

.photo-shape::after {
    position: absolute;
    right: -3px;
    bottom: -12px;
    width: 31px;
    height: 31px;
    border-radius: 7px;
    background: var(--accent);
    content: "";
    transform: rotate(45deg);
}

.photo-shape span {
    position: absolute;
    z-index: 1;
    bottom: -15px;
    left: -7px;
    width: 31px;
    height: 31px;
    border-radius: 7px;
    background: #79a091;
    transform: rotate(45deg);
}

.plus-shape {
    position: absolute;
    right: 8px;
    bottom: 7px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 3px solid white;
    border-radius: 50%;
    background: var(--ink);
    color: white;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

.button {
    display: inline-flex;
    width: 100%;
    min-height: 56px;
    padding: 14px 20px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.button:active {
    transform: scale(0.985);
}

.button:focus-visible,
.text-button:focus-visible,
label[for]:focus-visible {
    outline: 3px solid rgba(44, 91, 76, 0.28);
    outline-offset: 3px;
}

#photo-input:focus-visible + .button {
    outline: 3px solid rgba(44, 91, 76, 0.28);
    outline-offset: 3px;
}

.button-primary {
    margin-top: 24px;
    background: var(--accent);
    box-shadow: 0 12px 24px rgba(44, 91, 76, 0.20);
    color: #fff;
}

.button-primary:hover {
    background: var(--accent-dark);
}

.button-secondary {
    margin-top: 10px;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
}

.button-add-more {
    min-height: 50px;
    margin-top: 9px;
    background: transparent;
    color: var(--accent);
    font-size: 14px;
}

.button-add-more:hover {
    background: var(--accent-soft);
}

.add-icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 500;
    line-height: 1;
}

.view .format-note {
    margin-top: 12px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.03em;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

.processing-view {
    min-height: 340px;
    padding-top: 67px;
}

.loader {
    display: flex;
    height: 56px;
    margin-bottom: 25px;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loader span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    animation: loader-bounce 1s ease-in-out infinite;
}

.loader span:nth-child(2) {
    animation-delay: 120ms;
}

.loader span:nth-child(3) {
    animation-delay: 240ms;
}

.progress-track {
    width: min(100%, 270px);
    height: 5px;
    margin: 29px auto 0;
    overflow: hidden;
    border-radius: 999px;
    background: #e7e8e3;
}

.progress-track span {
    display: block;
    width: 8%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 350ms ease;
}

.processing-thumbs {
    display: flex;
    min-height: 0;
    margin: 20px auto 0;
    justify-content: center;
    gap: 7px;
}

.processing-thumbs:empty {
    display: none;
}

.processing-thumbs img {
    width: 42px;
    height: 42px;
    border: 2px solid white;
    border-radius: 10px;
    background: #eceeea;
    box-shadow: 0 4px 12px rgba(22, 32, 29, 0.12);
    object-fit: cover;
    animation: view-in 180ms ease-out both;
}

.ready-view {
    padding-top: 23px;
}

.ready-heading {
    display: flex;
    margin-bottom: 18px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.success-label {
    display: flex;
    margin: 0 0 5px;
    align-items: center;
    gap: 6px;
    color: var(--success);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.success-label span {
    display: grid;
    width: 18px;
    height: 18px;
    place-items: center;
    border-radius: 50%;
    background: var(--success);
    color: white;
    font-size: 11px;
}

.ready-heading h2 {
    font-size: 19px;
}

.results-grid {
    display: grid;
    max-height: 54vh;
    overflow-y: auto;
    gap: 10px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.result-card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid #e5e6e1;
    border-radius: 15px;
    background: #fafaf8;
    text-align: left;
}

.result-thumb-wrap {
    display: grid;
    width: 92px;
    height: 92px;
    overflow: hidden;
    place-items: center;
    background:
        linear-gradient(45deg, #e8e9e5 25%, transparent 25%),
        linear-gradient(-45deg, #e8e9e5 25%, transparent 25%),
        #f1f2ef;
    background-size: 14px 14px;
}

.result-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-card-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 11px 10px 11px 12px;
    align-items: center;
    gap: 9px;
}

.result-card-copy {
    min-width: 0;
}

.result-card-copy strong,
.result-card-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-card-copy strong {
    font-size: 12px;
}

.result-card-copy small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
}

.quick-save {
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid rgba(44, 91, 76, 0.2);
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.quick-save:active {
    transform: scale(0.97);
}

.results-grid.is-single .result-card {
    display: block;
}

.results-grid.is-single .result-thumb-wrap {
    width: 100%;
    height: min(44vh, 390px);
}

.results-grid.is-single .result-thumb-wrap img {
    object-fit: contain;
}

.text-button {
    min-height: 40px;
    padding: 8px 0 8px 12px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.preview-frame {
    display: grid;
    min-height: 190px;
    max-height: 48vh;
    margin: 0;
    overflow: hidden;
    place-items: center;
    border-radius: 18px;
    background:
        linear-gradient(45deg, #e8e9e5 25%, transparent 25%),
        linear-gradient(-45deg, #e8e9e5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8e9e5 75%),
        linear-gradient(-45deg, transparent 75%, #e8e9e5 75%),
        #f3f4f1;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.preview-frame img {
    display: block;
    width: 100%;
    max-height: 48vh;
    object-fit: contain;
}

.file-summary {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 24px;
    margin-top: 13px;
    padding: 11px 12px;
    align-items: center;
    gap: 10px;
    border: 1px solid #e5e6e1;
    border-radius: 13px;
    background: #fafaf8;
    text-align: left;
}

.file-summary > span:nth-child(2) {
    min-width: 0;
}

.file-summary strong,
.file-summary small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-summary strong {
    font-size: 12px;
}

.file-summary small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.file-icon {
    position: relative;
    display: block;
    width: 29px;
    height: 33px;
    border: 1.5px solid #8d9692;
    border-radius: 5px;
}

.file-icon::after {
    position: absolute;
    right: 5px;
    bottom: 7px;
    left: 5px;
    height: 7px;
    border-radius: 3px;
    background: var(--accent-soft);
    content: "";
}

.check-mark {
    display: grid;
    width: 21px;
    height: 21px;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--success);
    font-size: 12px;
    font-weight: 800;
}

.save-button {
    margin-top: 17px;
}

.save-icon {
    display: grid;
    width: 23px;
    height: 23px;
    place-items: center;
    border-bottom: 2px solid currentColor;
    font-size: 22px;
    line-height: 1;
}

.ready-view .save-help {
    margin: 10px auto 0;
    font-size: 11px;
}

.error-icon {
    display: grid;
    width: 65px;
    height: 65px;
    margin: 4px auto 22px;
    place-items: center;
    border-radius: 50%;
    background: #f6e6e4;
    color: var(--danger);
    font-family: Georgia, serif;
    font-size: 32px;
    font-weight: 700;
}

.trust-note {
    display: flex;
    margin: 21px auto 0;
    padding: 0 12px;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
}

.trust-note p {
    max-width: 390px;
    margin: 0;
    font-size: 11px;
    line-height: 1.5;
}

.trust-note strong {
    color: var(--ink);
}

.lock-icon {
    position: relative;
    display: block;
    width: 13px;
    height: 11px;
    flex: 0 0 13px;
    margin-top: 4px;
    border-radius: 2px;
    background: var(--accent);
}

.lock-icon::before {
    position: absolute;
    top: -7px;
    left: 3px;
    width: 7px;
    height: 8px;
    border: 2px solid var(--accent);
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    content: "";
}

footer {
    display: flex;
    width: min(100%, 760px);
    margin: auto auto 0;
    padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid rgba(22, 32, 29, 0.08);
    color: #8a918e;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.toast {
    position: fixed;
    z-index: 10;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    left: 18px;
    width: min(calc(100% - 36px), 440px);
    margin: 0 auto;
    padding: 14px 17px;
    border-radius: 13px;
    background: var(--ink);
    box-shadow: 0 12px 32px rgba(22, 32, 29, 0.25);
    color: white;
    font-size: 13px;
    font-weight: 650;
    text-align: center;
}

@keyframes view-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes loader-bounce {
    0%, 65%, 100% { transform: translateY(0); opacity: 0.45; }
    32% { transform: translateY(-12px); opacity: 1; }
}

@media (min-width: 620px) {
    .topbar {
        padding-right: 28px;
        padding-left: 28px;
    }

    .main-content {
        padding-top: 18px;
        padding-right: 24px;
        padding-left: 24px;
    }

    .view {
        padding-right: 35px;
        padding-left: 35px;
    }

    .work-card {
        border-radius: 30px;
    }
}

@media (max-width: 370px) {
    .privacy-badge {
        padding-right: 8px;
        padding-left: 8px;
        font-size: 10px;
    }

    .brand {
        font-size: 11px;
    }

    .intro h1 {
        font-size: 40px;
    }
}

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