

:root {
    --ocr-accent: #0d6efd;
    --ocr-accent-soft: rgba(13, 110, 253, 0.12);
    --ocr-accent-soft-2: rgba(13, 110, 253, 0.22);
    --ocr-glass-bg: rgba(255, 255, 255, 0.55);
    --ocr-glass-bg-strong: rgba(255, 255, 255, 0.72);
    --ocr-glass-border: rgba(255, 255, 255, 0.65);
    --ocr-shadow: 0 18px 48px rgba(18, 38, 63, 0.12);
    --ocr-shadow-soft: 0 8px 24px rgba(18, 38, 63, 0.08);
    --ocr-text-muted: #6b7280;

    --ocr-radius: 1rem;
    --ocr-field-shadow: 0 2px 16px rgba(18, 38, 63, 0.12);
}

.ocr-workspace {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ocr-stage {
    transition: opacity .45s cubic-bezier(.22, 1, .36, 1),
                transform .45s cubic-bezier(.22, 1, .36, 1),
                filter .45s ease;
    will-change: opacity, transform;
}

.ocr-stage.ocr-stage-enter {
    opacity: 0;
    transform: translateY(16px) scale(.985);
    filter: blur(6px);
}

.ocr-stage.ocr-stage-leave {
    opacity: 0;
    transform: translateY(-12px) scale(.985);
    filter: blur(6px);
    pointer-events: none;
}

.ocr-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ocr-dropzone {
    position: relative;
    border-radius: var(--ocr-radius);
    padding: 34px 24px;
    background: var(--ocr-glass-bg);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border: 1.5px dashed rgba(13, 110, 253, 0.35);
    box-shadow: var(--ocr-shadow-soft);
    cursor: pointer;
    transition: border-color .25s ease, background .25s ease,
                box-shadow .3s ease, transform .25s cubic-bezier(.22, 1, .36, 1);
    outline: none;
}

.ocr-dropzone:hover,
.ocr-dropzone:focus-visible {
    border-color: var(--ocr-accent);
    background: var(--ocr-glass-bg-strong);
    box-shadow: var(--ocr-shadow);
}

.ocr-dropzone.dragover {
    border-color: var(--ocr-accent);
    border-style: solid;
    background: linear-gradient(180deg, var(--ocr-accent-soft), var(--ocr-glass-bg-strong));
    transform: translateY(-2px) scale(1.005);
    box-shadow: var(--ocr-shadow);
}

.ocr-dropzone.has-file {
    cursor: default;
    border-style: solid;
    border-color: rgba(13, 110, 253, 0.25);
    padding: 16px;
}

.ocr-dropzone-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.ocr-dropzone-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    font-size: 26px;
    color: var(--ocr-accent);
    background: var(--ocr-accent-soft);
    box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.12);
    margin-bottom: 4px;
}

.ocr-dropzone-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.ocr-dropzone-hint {
    font-size: 14px;
    color: var(--ocr-text-muted);
    max-width: 460px;
}

.ocr-link-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--ocr-accent);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ocr-camera-btn {
    margin-top: 6px;
    border: none;
    border-radius: 14px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ocr-accent);
    background: var(--ocr-accent-soft);
    cursor: pointer;
    transition: background .2s ease, transform .15s ease;
}

.ocr-camera-btn:hover {
    background: var(--ocr-accent-soft-2);
    transform: translateY(-1px);
}

.ocr-dropzone-formats {
    margin-top: 8px;
    font-size: 12px;
    color: #9aa3af;
}

.ocr-preview {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ocr-preview-thumb {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    border-radius: var(--ocr-radius);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--ocr-shadow-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ocr-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ocr-preview-emoji {
    font-size: 46px;
    line-height: 1;
    user-select: none;
}

.ocr-preview-meta {
    flex: 1;
    min-width: 0;
}

.ocr-preview-name {
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ocr-preview-size {
    font-size: 13px;
    color: var(--ocr-text-muted);
    margin-top: 2px;
}

.ocr-progress {
    margin-top: 10px;
    height: 6px;
    border-radius: 999px;
    background: rgba(13, 110, 253, 0.12);
    overflow: hidden;
}

.ocr-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ocr-accent), #5aa0ff);
    transition: width .25s ease;
}

.ocr-remove {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: #4b5563;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .15s ease;
}

.ocr-remove:hover {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
    transform: scale(1.05);
}

.ocr-refine {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

.ocr-refine-toggle {
    border: none;
    background: none;
    padding: 4px 2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ocr-accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity .2s ease;
}

.ocr-switch {
    display: inline-block;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: #c7ccd4;
    position: relative;
    flex-shrink: 0;
    vertical-align: middle;
    transition: background .25s ease;
}

.ocr-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform .25s cubic-bezier(.22, 1, .36, 1);
}

.ocr-refine-toggle.active .ocr-switch {
    background: var(--ocr-accent);
}

.ocr-refine-toggle.active .ocr-switch-knob {
    transform: translateX(14px);
}

.ocr-refine-panel {
    width: 100%;
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transform: translateY(-6px);
    transition: grid-template-rows .45s cubic-bezier(.22, 1, .36, 1),
                opacity .4s ease, transform .45s cubic-bezier(.22, 1, .36, 1);
}

.ocr-refine-panel.open {
    grid-template-rows: 1fr;
    opacity: 1;
    transform: translateY(0);
    margin-top: 2px;
}

.ocr-refine-inner {
    overflow: hidden;
    min-height: 0;

    padding: 14px 16px 4px;
}

.ocr-query-wrap {
    position: relative;
    display: block;
    background: var(--ocr-glass-bg-strong);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(18, 38, 63, 0.08);
    border-radius: var(--ocr-radius);
    box-shadow: var(--ocr-field-shadow);
    padding: 11px 16px 22px;
    transition: border-color .2s ease, box-shadow .25s ease;
}

.ocr-query-wrap:focus-within {
    border-color: var(--ocr-accent);
    box-shadow: 0 0 0 4px var(--ocr-accent-soft);
}

.ocr-grow-wrap {
    display: grid;
}

.ocr-grow-wrap::after {
    content: attr(data-replicated-value) " ";
    visibility: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.ocr-grow-wrap > textarea {
    resize: none;
    overflow: hidden;
}

.ocr-grow-wrap > textarea,
.ocr-grow-wrap::after {
    grid-area: 1 / 1 / 2 / 2;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    border: none;
    background: transparent;
    outline: none;
    color: #1f2937;
    padding: 0;
    margin: 0;
}

.ocr-query-counter {
    position: absolute;
    right: 14px;
    bottom: 6px;
    font-size: 12px;
    color: var(--ocr-text-muted);
    white-space: nowrap;
}

.ocr-query-counter.is-custom {
    color: var(--ocr-accent);
    font-weight: 600;
}

.ocr-query-help {
    font-size: 12px;
    color: #9aa3af;
    margin-top: 6px;
    padding-left: 4px;
}

.ocr-submit-wrap {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.ocr-submit-wrap .write-submit-btn {
    min-width: 240px;
}

.ocr-submit-wrap .write-submit-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.ocr-result {
    position: relative;
    border-radius: var(--ocr-radius);
    background: var(--ocr-glass-bg-strong);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--ocr-glass-border);
    box-shadow: var(--ocr-shadow-soft);
    padding: 22px 24px 30px;
    min-height: 90px;
    overflow: hidden;
}

.ocr-result-body {
    font-size: 16px;
    line-height: 1.62;
    color: #1f2937;
    word-wrap: break-word;
    transition: opacity .3s ease;
}

.ocr-result-body:empty::before {
    content: "Ответ появится здесь…";
    color: #9aa3af;
}

.ocr-result-counter {
    position: absolute;
    right: 14px;
    bottom: 8px;
    font-size: 11px;
    color: #9aa3af;
    pointer-events: none;
}

.ocr-result.locked {
    user-select: none;
}

.ocr-result.locked .ocr-result-body {
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}

.ocr-result.locked::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg,
        rgba(13, 110, 253, 0) 25%,
        rgba(13, 110, 253, 0.07) 45%,
        rgba(13, 110, 253, 0.12) 50%,
        rgba(13, 110, 253, 0.07) 55%,
        rgba(13, 110, 253, 0) 75%);
    background-size: 220% 100%;
    animation: ocr-shimmer 1.5s linear infinite;
    pointer-events: none;
}

@keyframes ocr-shimmer {
    from { background-position: 120% 0; }
    to   { background-position: -120% 0; }
}

.ocr-result.error .ocr-result-body {
    color: #b42318;
    font-weight: 500;
}

.ocr-uploading {
    color: var(--ocr-text-muted);
    font-size: 15px;
    font-style: italic;
    padding: 6px 2px;
}

.ocr-check-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.66);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 3;
    animation: ocr-fade-in .3s ease;
}

.ocr-check-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--ocr-accent);
}

.ocr-check-svg {
    width: 56px;
    height: 56px;
}

.ocr-check-bg {
    stroke: var(--ocr-accent-soft-2);
    stroke-width: 3;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: ocr-circle .6s cubic-bezier(.65, 0, .45, 1) forwards;
}

.ocr-check-mark {
    stroke: var(--ocr-accent);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: ocr-check .35s .55s cubic-bezier(.65, 0, .45, 1) forwards;
}

@keyframes ocr-circle { to { stroke-dashoffset: 0; } }
@keyframes ocr-check { to { stroke-dashoffset: 0; } }
@keyframes ocr-fade-in { from { opacity: 0; } to { opacity: 1; } }

.ocr-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    animation: ocr-rise .5s cubic-bezier(.22, 1, .36, 1);
}

@keyframes ocr-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ocr-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .25s ease;
}

.ocr-modal-overlay.show { opacity: 1; }

.ocr-modal {
    width: 100%;
    max-width: 420px;
    border-radius: 24px;
    background: var(--ocr-glass-bg-strong);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    border: 1px solid var(--ocr-glass-border);
    box-shadow: 0 24px 64px rgba(18, 38, 63, 0.28);
    padding: 28px 26px 24px;
    text-align: center;
    transform: scale(.92) translateY(8px);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
}

.ocr-modal-overlay.show .ocr-modal { transform: scale(1) translateY(0); }

.ocr-modal-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-size: 26px;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.14);
}

.ocr-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.ocr-modal-text {
    font-size: 14.5px;
    line-height: 1.55;
    color: #4b5563;
    margin-bottom: 20px;
}

.ocr-modal-btn {
    border: none;
    border-radius: 14px;
    padding: 11px 28px;
    font-weight: 600;
    color: #fff;
    background: var(--ocr-accent);
    cursor: pointer;
    transition: filter .2s ease, transform .15s ease;
}

.ocr-modal-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    font-weight: 700;
    line-height: 1.3;
    margin: 1.1em 0 .5em;
}
.markdown-body h1 { font-size: 1.5em; }
.markdown-body h2 { font-size: 1.32em; }
.markdown-body h3 { font-size: 1.16em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body p { margin: 0 0 .8em; }
.markdown-body ul, .markdown-body ol { margin: 0 0 .8em; padding-left: 1.5em; }
.markdown-body li { margin: .25em 0; }
.markdown-body blockquote {
    margin: 0 0 .8em;
    padding: .4em 1em;
    border-left: 3px solid var(--ocr-accent-soft-2);
    background: var(--ocr-accent-soft);
    border-radius: 0 10px 10px 0;
    color: #374151;
}
.markdown-body code {
    font-family: Consolas, "Courier New", monospace;
    background: rgba(0, 0, 0, 0.06);
    padding: .12em .4em;
    border-radius: 6px;
    font-size: .92em;
    margin: 0;
    color: #b4006e;
}
.markdown-body pre {
    background: rgba(15, 23, 42, 0.92);
    color: #e6edf3;
    padding: 14px 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 0 0 .9em;
}
.markdown-body pre code { background: none; color: inherit; padding: 0; }
.markdown-body a { color: var(--ocr-accent); text-decoration: underline; }
.markdown-body hr { border: none; border-top: 1px solid rgba(0, 0, 0, 0.1); margin: 1.2em 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 0 0 .9em; font-size: .95em; }
.markdown-body th, .markdown-body td { border: 1px solid rgba(0, 0, 0, 0.12); padding: 7px 10px; text-align: left; }
.markdown-body th { background: var(--ocr-accent-soft); font-weight: 600; }
.markdown-body strong { font-weight: 700; }
.markdown-body img { max-width: 100%; border-radius: 10px; }

.ocr-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding-top: 12px;
}

.ocr-catalog-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-radius: 18px;
    background: var(--ocr-glass-bg-strong);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--ocr-glass-border);
    box-shadow: var(--ocr-shadow-soft);
    color: #1f2937;
    text-decoration: none;
    transition: transform .25s cubic-bezier(.22, 1, .36, 1), box-shadow .3s ease;
}

a.ocr-catalog-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ocr-shadow);
    color: #1f2937;
}

.ocr-catalog-card__icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: var(--ocr-accent);
    background: var(--ocr-accent-soft);
    font-size: 22px;
    line-height: 1;
}

.ocr-catalog-card__name { flex: 1; font-weight: 600; font-size: 15px; }
.ocr-catalog-card__arrow { color: var(--ocr-accent); opacity: .7; }

.ocr-catalog-card--soon {
    cursor: default;
    opacity: .72;
}

.ocr-soon-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: #9aa3af;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px 10px;
    border-radius: 999px;
}

@media (max-width: 575.98px) {
    .ocr-dropzone { padding: 26px 16px; }
    .ocr-dropzone-title { font-size: 16px; }
    .ocr-dropzone-icon { width: 56px; height: 56px; font-size: 22px; }
    .ocr-result { padding: 18px 16px 28px; }
    .ocr-submit-wrap .write-submit-btn { width: 100%; min-width: 0; }
    .ocr-actions { flex-direction: column; }
    .ocr-actions .btn { width: 100%; }
    .ocr-preview-img { width: 76px; height: 76px; }
    .ocr-catalog-grid { grid-template-columns: 1fr; padding-top: 6px; }
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body > main {
    flex: 1 0 auto;
}

body > footer {
    flex-shrink: 0;
}
