@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
:root { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color-scheme: light; color: #252525; background: #f2f2f2; }
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: #f2f2f2; }
button { font: inherit; }
.screen-container { position: relative; min-height: 100vh; overflow: hidden; }
.landing { width: 100%; max-width: 1920px; min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.page-screen { position: absolute; inset: 0; width: 100%; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(20px); filter: blur(5px); transition: opacity .5s ease, transform .65s cubic-bezier(.22,1,.36,1), filter .5s ease, visibility 0s linear .65s; }
.page-screen.is-active { position: relative; opacity: 1; visibility: visible; pointer-events: auto; transform: none; filter: none; transition: opacity .5s ease, transform .65s cubic-bezier(.22,1,.36,1), filter .5s ease, visibility 0s; }
/* Keep the inactive page from painting labels behind the active page. */
.page-screen:not(.is-active) { visibility: hidden; }
#home-screen { z-index: 1; }
#normative-screen { z-index: 2; background: #f2f2f2; }
.intro { width: 100%; height: 51.2vh; min-height: 300px; max-height: 552px; position: relative; overflow: hidden; flex-shrink: 0; }
.art-crop { position: absolute; inset: 0; overflow: hidden; }
/* Adjust --figure-top if you want the figure lower/higher. */

/* Плавное вертикальное движение фигуры */

/* Чёрная фигура — центрирование и вертикальная анимация */

#home-screen .art-crop img {
    position: absolute;

    width: 433px;
    height: 433px;
    max-width: none;

    left: 50%;
    top: 68px;

    transform-origin: center center;

    animation: figureFloat 5s ease-in-out infinite;
    will-change: transform;
}

@keyframes figureFloat {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-15px);
    }
}

.actions, .normative-content { width: min(932px, calc(100% - 56px)); display: flex; flex-direction: column; align-items: center; }
.upload-panel { position: relative; width: 100%; height: 173px; border: 1px solid #555; border-radius: 17px; background: transparent; transition: border-color .3s ease; }
.upload-panel:hover { border-color: #222; }
.upload-title { position: absolute; z-index: 1; top: -13px; left: 50%; transform: translateX(-50%); padding: 0 12px; background: #f2f2f2; color: #5d5d5d; font-size: 22px; line-height: 25px; white-space: nowrap; }
.upload-target { width: 100%; height: 100%; padding: 18px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; cursor: pointer; border-radius: 17px; background: transparent; }
.upload-target:hover, .upload-target.is-dragging { background: transparent; }
.upload-target input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-target:focus-within { outline: none; }
.upload-target:has(input:focus-visible) { outline: 1px dashed #777; outline-offset: 4px; }
.upload-content { display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; width: 90%; max-width: 100%; color: #999; transition: transform .35s cubic-bezier(.22,1,.36,1), color .35s ease; }
.upload-icon { width: 26px; height: 26px; flex-shrink: 0; transition: transform .35s ease; }
#file-hint { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: inherit; font-size: 17px; text-align: center; }
.upload-description { color: #aaa; font-size: 12px; text-align: center; transition: color .35s ease; }
.upload-target:hover .upload-content, .upload-target.is-dragging .upload-content { transform: scale(1.055); color: #4b4b4b; }
.upload-target:hover .upload-icon, .upload-target.is-dragging .upload-icon { transform: translateY(-4px); }
.upload-target:hover .upload-description, .upload-target.is-dragging .upload-description { color: #777; }
.analyze-link { appearance: none; -webkit-appearance: none; border: 0; margin-top: 42px; display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 13px 32px; border-radius: 999px; background: #171717; color: #fff; text-decoration: none; font-size: 18px; font-weight: 500; line-height: 1.3; transition: background .28s ease, transform .28s ease, box-shadow .28s ease; }
.analyze-link:hover, .analyze-link:focus-visible { background: #333; transform: scale(1.045); box-shadow: 0 7px 20px rgba(0,0,0,.12); }
.analyze-link:active { transform: scale(.98); }
.analyze-link:focus-visible, .normative-open:focus-visible, .back-button:focus-visible { outline: 2px solid #444; outline-offset: 4px; }
.secondary-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 30px 0 44px; }
.secondary-links .placeholder, .secondary-links .normative-open { border: 1px solid #bbb; border-radius: 999px; background: transparent; color: #555; padding: 9px 17px; font-size: 14px; line-height: 1.3; }
.secondary-links .placeholder { cursor: default; }
.secondary-links .normative-open { cursor: pointer; transition: background .25s ease, transform .25s ease; }
.secondary-links .normative-open:hover { background: #e5e5e5; transform: translateY(-2px); }
.normative-content { padding-bottom: 40px; }
.documents-panel { width: 100%; min-width: 0; min-height: 405px; margin: 0; padding: 22px 34px 30px; border: 1px solid #555; border-radius: 11px; }
.documents-panel legend { margin: 0 auto; padding: 0 12px; color: #5d5d5d; background: #f2f2f2; font-size: 22px; font-weight: 400; line-height: 25px; text-align: center; }
.documents-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 42px; row-gap: 23px; align-content: start; padding-top: 3px; }
.document-item { display: flex; align-items: center; gap: 14px; min-height: 43px; min-width: 0; color: #111; text-decoration: none; transition: transform .25s ease, opacity .25s ease; }
.document-item:hover { transform: translateX(6px); opacity: .65; }
.document-item:focus-visible { outline: 2px solid #111; outline-offset: 4px; }
.document-name { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.pdf-icon { width: 30px; height: 38px; flex-shrink: 0; }
.pdf-icon svg { display: block; width: 100%; height: 100%; }
.empty-documents { grid-column: 1/-1; margin: 120px 0 0; text-align: center; color: #777; }
.back-button { width: 288px; max-width: 100%; height: 48px; margin-top: 40px; border: 0; border-radius: 999px; background: #171717; color: #fff; font-size: 20px; cursor: pointer; transition: background .3s ease, transform .3s ease; }
.back-button:hover { background: #333; transform: translateY(-3px); }
.normative-screen.is-active .document-item { animation: documentAppear .55s ease both; }
.normative-screen.is-active .document-item:nth-child(2) { animation-delay: .07s; }
.normative-screen.is-active .document-item:nth-child(3) { animation-delay: .14s; }
.normative-screen.is-active .document-item:nth-child(4) { animation-delay: .21s; }
.normative-screen.is-active .document-item:nth-child(n+5) { animation-delay: .28s; }
@keyframes documentAppear { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width:1100px) { .intro { height: 42vh; } .actions,.normative-content { width: min(740px,calc(100% - 48px)); } .upload-panel { height: 150px; } }
@media (max-width:700px) { .documents-panel { min-height: 350px; padding: 20px 18px; } .documents-grid { grid-template-columns: 1fr; row-gap: 15px; } .document-name { font-size: 14px; } .back-button { width: 220px; font-size: 17px; } }
@media (max-width:600px) { .intro { height: 34vh; min-height: 210px; max-height: 335px; } .art-crop img { width: 330px; height: 330px; top: 0; } .actions,.normative-content { width: calc(100% - 36px); } .upload-panel { height: 135px; border-radius: 13px; } .upload-title,.documents-panel legend { font-size: 17px; line-height: 21px; } .upload-title { top: -11px; } .upload-description { font-size: 10px; } .analyze-link { font-size: 16px; margin-top: 30px; } .secondary-links { gap: 9px; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } #home-screen .art-crop img { transform: translateX(-50%); } }

/* ==========================================
   ФИГУРА НА ГЛАВНОЙ И В НОРМАТИВНОЙ БАЗЕ
========================================== */

#home-screen .art-crop img,
#normative-screen .art-crop img {
    position: absolute;

    width: 433px;
    height: 433px;
    max-width: none;

    left: 50%;
    top: 68px;

    transform-origin: center center;

    animation: figureFloat 5s ease-in-out infinite;
    will-change: transform;
}

/* Плавное движение только вверх-вниз */

@keyframes figureFloat {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-15px);
    }
}

/* TEMPLATE SELECTION */
#templates-screen { z-index: 3; background: #f2f2f2; }
#templates-screen .art-crop img {
    position: absolute; width: 433px; height: 433px; max-width: none;
    left: 50%; top: 68px; transform-origin: center;
    animation: figureFloat 5s ease-in-out infinite;
}
.secondary-links .templates-open {
    border: 1px solid #bbb; border-radius: 999px; background: transparent;
    color: #555; padding: 9px 17px; font-size: 14px; line-height: 1.3;
    cursor: pointer; transition: background .25s ease, transform .25s ease;
}
.secondary-links .templates-open:hover { background: #e5e5e5; transform: translateY(-2px); }
.templates-content { width: min(1100px,calc(100% - 56px)); padding-bottom: 50px; }
.templates-panel { min-width: 0; width: 100%; min-height: 420px; padding: 28px 32px 40px; margin: 0; border: 1px solid #666; border-radius: 12px; }
.templates-panel legend { margin: 0 auto; padding: 0 12px; color: #666; font-size: 18px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%,280px),1fr)); align-items: start; gap: 20px; }
.template-card { position: relative; display: flex; flex-direction: column; min-height: 265px; padding: 22px; border: 1px solid #b7b7b7; border-radius: 12px; background: #f5f5f5; cursor: pointer; box-shadow: 2px 4px 0 rgba(0,0,0,.035); transition: border-color .25s, transform .25s, box-shadow .25s, background .25s; }
.template-card:hover { transform: translateY(-4px); border-color: #555; box-shadow: 0 9px 22px rgba(0,0,0,.08); }
.template-card:has(input:checked) { border: 2px solid #1d1d1d; padding: 21px; background: #fff; box-shadow: 0 8px 25px rgba(0,0,0,.1); }
.template-card:focus-within { outline: 2px solid #888; outline-offset: 3px; }
.template-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.template-card-header { display: flex; align-items: center; gap: 9px; margin-bottom: 20px; }
.template-card-name { font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.template-icon { font-size: 25px; line-height: 1; color: #555; }
.template-check { display: none; margin-left: auto; border-radius: 50%; padding: 2px 6px; background: #191919; color: white; }
.template-card:has(input:checked) .template-check { display: inline; }
.template-card-stats { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 15px; }
.template-card-stats > span { border: 1px solid #d7d7d7; border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.template-card-stats strong { font-size: 18px; }
.template-card-section { margin-top: 8px; margin-bottom: 5px; font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .09em; }
.template-card-details { display: block; font-size: 13px; line-height: 1.5; color: #444; overflow-wrap: anywhere; }
.template-card-entities { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.template-card--invalid { opacity: .55; cursor: not-allowed; }
.template-card-error { font-size: 13px; color: #900; }
.template-actions { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin-top: 30px; }
.template-actions .back-button, .template-actions .template-run { width: auto; min-width: 195px; height: 47px; margin: 0; font-size: 16px; }
.template-actions .template-run { min-height: 47px; padding: 10px 26px; border: 0; cursor: pointer; }
.template-actions .template-run:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }
.template-help { margin: 14px 0; color: #777; text-align: center; font-size: 13px; }
@media(max-width:600px) {
  #home-screen .art-crop img,
  #normative-screen .art-crop img,
  #templates-screen .art-crop img {
    width: min(240px, calc(34vh - 24px));
    height: min(240px, calc(34vh - 24px));
    top: 22px;
  }
  .templates-content { width: calc(100% - 36px); }
  .templates-panel { padding: 18px 13px 24px; }
  .template-actions { gap: 10px; }
  .template-actions .back-button, .template-actions .template-run { min-width: 135px; }
}
@media (prefers-reduced-motion: reduce) {
  #home-screen .art-crop img,
  #normative-screen .art-crop img,
  #templates-screen .art-crop img { transform: translateX(-50%); animation: none; }
}

/* Validation feedback below the main import button. */
.import-feedback:not([hidden]) {
    margin: 13px 0 0;
    max-width: 650px;
    color: #aa3848;
    font-size: 14px;
    text-align: center;
}
/* The main analysis action is unavailable until a graph file is selected. */
#choose-template:disabled,
#choose-template:disabled:hover,
#choose-template:disabled:focus-visible {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    outline: none;
    background: #b5b5b5;
    color: #fff;
    opacity: 1;
    box-shadow: none;
    filter: none;
    cursor: not-allowed;
    transform: none;
}

/* Normative base: keep the same monochrome style, but separate imported PDFs. */
#normative-screen .intro { height: min(43vh, 405px); min-height: 285px; }
#normative-screen .normative-content { width: min(1360px, calc(100% - 72px)); }
#normative-screen .normative-panel { min-height: 380px; padding: 24px 28px 28px; border-color: #8b8b8b; }
#normative-screen .normative-panel legend { font-size: 18px; color: #666; }
.normative-columns { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 26px; }
.normative-original { min-width: 0; padding: 8px 5px 6px 0; }
.normative-heading { margin: 0 0 26px; font-size: 19px; font-weight: 500; color: #202020; line-height: 1.3; }
.normative-original .documents-grid { column-gap: 26px; row-gap: 17px; }
.normative-original .document-item { gap: 12px; min-height: 42px; }
.normative-original .document-name { font-size: 14px; }
.normative-original .pdf-icon { width: 25px; height: 32px; }
.normative-import { min-width: 0; padding: 3px 0 0 24px; border-left: 1px solid #bcbcbc; }
.normative-import-form { margin: 0 0 25px; }
.normative-import-button { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 43px; padding: 10px 21px; border: 0; border-radius: 999px; background: #111; color: white; font-size: 15px; font-weight: 500; cursor: pointer; transition: background .25s, transform .25s, box-shadow .25s; }
.normative-import-button:hover { background: #303030; transform: translateY(-1px); box-shadow: 0 5px 14px rgba(0,0,0,.1); }
.normative-import-button:focus-visible { outline: 2px solid #777; outline-offset: 3px; }
.normative-import-button:disabled { opacity: .55; cursor: progress; transform: none; }
.normative-dropzone { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; min-height: 116px; margin-top: 16px; padding: 14px 10px; border: 1px dashed #aaa; border-radius: 11px; color: #777; cursor: pointer; text-align: center; transition: border-color .2s, background .2s; }
.normative-dropzone:hover, .normative-dropzone.is-dragging { border-color: #383838; background: rgba(0,0,0,.035); }
.normative-dropzone:focus-within { outline: 2px solid #666; outline-offset: 3px; }
.normative-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.normative-upload-icon { width: 31px; height: 31px; flex-shrink: 0; }
#normative-drop-hint { font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.normative-drop-subtitle { font-size: 11px; color: #999; }
.normative-submit { margin-top: 12px; }
.normative-import-feedback:not([hidden]), .normative-server-feedback { margin: 9px 0 0; color: #375b3a; text-align: center; font-size: 12px; line-height: 1.4; }
.normative-import-feedback.is-error, .normative-server-feedback.is-error { color: #a43e45; }
.imported-heading-row { display: flex; gap: 9px; align-items: baseline; margin-bottom: 15px; }
.imported-heading-row .normative-heading { margin: 0; font-size: 18px; }
.imported-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; padding: 2px 7px; border: 1px solid #d6d6d6; border-radius: 999px; color: #777; font-size: 11px; }
.imported-documents-list { display: flex; flex-direction: column; gap: 7px; max-height: 265px; overflow-y: auto; padding-right: 3px; }
.imported-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 0; }
.imported-item .pdf-icon { width: 23px; height: 29px; }
.imported-item .document-name { flex: 1; min-width: 0; font-size: 13px; }
.imported-badge { flex-shrink: 0; padding: 4px 8px; border-radius: 999px; background: #e6e6e6; color: #777; font-size: 11px; }
.imported-empty { margin: 11px 0 0; color: #8b8b8b; font-size: 13px; line-height: 1.5; }
.imported-item-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; }
.imported-delete-button { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #dddddd; border-radius: 10px; background: #f6f6f6; color: #7d7d7d; cursor: pointer; flex-shrink: 0; transition: border-color .22s ease, color .22s ease, background .22s ease, transform .22s ease; }
.imported-delete-button:hover { color: #3f3f3f; border-color: #bcbcbc; background: #efefef; transform: translateY(-1px); }
.imported-delete-button:focus-visible { outline: 2px solid #8a8a8a; outline-offset: 2px; }
.imported-delete-button svg { width: 18px; height: 18px; }
#normative-screen .back-button { margin-top: 32px; }
@media (max-width: 1100px) {
  #normative-screen .normative-content { width: min(940px, calc(100% - 48px)); }
  .normative-columns { grid-template-columns: 1fr; gap: 24px; }
  .normative-import { padding: 22px 0 0; border-left: 0; border-top: 1px solid #bbb; }
  .normative-import-form { max-width: 540px; }
  .imported-documents-list { max-height: 300px; }
}
@media (max-width: 700px) {
  #normative-screen .intro { height: 32vh; min-height: 210px; }
  #normative-screen .normative-content { width: calc(100% - 28px); }
  #normative-screen .normative-panel { padding: 20px 16px 25px; }
  .normative-heading { font-size: 17px; margin-bottom: 20px; }
  .normative-original .documents-grid { grid-template-columns: 1fr; gap: 12px; }
  .normative-original .document-name { font-size: 13px; }
  .imported-heading-row .normative-heading { font-size: 16px; }
  .imported-badge { font-size: 10px; }
  .imported-delete-button { width: 32px; height: 32px; border-radius: 9px; }
}

/* Keep the sculpture centered even before the floating animation starts. */
#normative-screen .art-crop img { width: 385px; height: 385px; top: 28px; transform: translateX(-50%); }
@media (max-width: 600px) {
  #normative-screen .art-crop img { width: min(240px, calc(34vh - 24px)); height: min(240px, calc(34vh - 24px)); top: 22px; }
}


/* Optional ephemeral security-requirements step after main graph selection. */
body.requirements-modal-open { overflow: hidden; }
.requirements-modal[hidden] { display: none !important; }
.requirements-modal {
    position: fixed; inset: 0; z-index: 80; padding: 24px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(30,30,30,.44); backdrop-filter: blur(8px);
    animation: requirementsBackdropIn .22s ease both;
}
.requirements-dialog {
    position: relative; width: min(600px, 100%); max-height: min(90vh, 760px);
    overflow-y: auto; padding: 36px 39px 33px;
    background: #f2f2f2; border: 1px solid #898989; border-radius: 19px;
    box-shadow: 0 24px 80px rgba(0,0,0,.22);
    animation: requirementsCardIn .36s cubic-bezier(.22,1,.36,1) both;
}
.requirements-close {
    position: absolute; top: 20px; right: 20px; width: 34px; height: 34px;
    border: 1px solid #c9c9c9; background: transparent; color: #666;
    border-radius: 50%; cursor: pointer; display: grid; place-items: center;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}
.requirements-close svg { width: 15px; height: 15px; }
.requirements-close:hover { background: #e3e3e3; color: #151515; transform: rotate(90deg); }
.requirements-dialog h2 { margin: 0; max-width: 460px; font-size: clamp(22px, 2.5vw, 29px); font-weight: 500; color: #191919; line-height: 1.24; }
.requirements-description { max-width: 485px; margin: 13px 0 22px; font-size: 14px; line-height: 1.6; color: #696969; }
.requirements-dropzone {
    position: relative; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 7px; min-height: 162px; padding: 22px 16px;
    border: 1px dashed #a3a3a3; border-radius: 13px; cursor: pointer;
    background: rgba(255,255,255,.2); text-align: center;
    transition: border-color .2s ease, background .2s ease;
}
.requirements-dropzone:hover, .requirements-dropzone.is-dragging { background: rgba(255,255,255,.52); border-color: #444; }
.requirements-dropzone:focus-within { outline: 2px solid #555; outline-offset: 3px; }
.requirements-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.requirements-upload-icon { width: 29px; height: 29px; color: #6d6d6d; margin-bottom: 5px; }
.requirements-drop-title { color: #303030; font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.requirements-drop-description { color: #8a8a8a; font-size: 12px; }
.requirements-drop-formats { margin-top: 4px; color: #999; font-size: 11px; }
.requirements-modal-error:not([hidden]) { margin: 0 0 13px; color: #aa3848; font-size: 13px; }
.requirements-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-top: 18px; }
.requirements-skip, .requirements-confirm { min-height: 46px; padding: 11px 19px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .2s ease, transform .2s ease; }
.requirements-skip { background: transparent; color: #555; border: 1px solid #aaa; }
.requirements-skip:hover { background: #e6e6e6; }
.requirements-confirm { background: #171717; border: 1px solid #171717; color: white; }
.requirements-confirm:hover:not(:disabled) { background: #333; transform: translateY(-1px); }
.requirements-confirm:disabled { opacity: .36; cursor: not-allowed; }
.requirements-skip:focus-visible, .requirements-confirm:focus-visible, .requirements-close:focus-visible { outline: 2px solid #555; outline-offset: 3px; }
@keyframes requirementsBackdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes requirementsCardIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@media(max-width: 600px) {
    .requirements-modal { padding: 14px; align-items: center; }
    .requirements-dialog { padding: 32px 20px 22px; border-radius: 15px; }
    .requirements-close { top: 12px; right: 12px; }
    .requirements-actions { flex-direction: column-reverse; }
    .requirements-actions button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .requirements-modal, .requirements-dialog { animation: none; } }

/* Responsive layout: desktop / laptop / tablet / phone.
   Overrides only presentation; upload, template and modal logic stays intact. */
html { -webkit-text-size-adjust: 100%; }
body { min-width: 0; }
.screen-container { min-width: 0; }
.landing, .actions, .normative-content, .templates-content,
.documents-panel, .templates-panel, .template-grid, .normative-columns,
.normative-original, .normative-import { min-width: 0; }
.document-item, .template-card, .imported-item-row, .requirements-dialog { max-width: 100%; }
.document-name, .template-card-details, .requirements-description { overflow-wrap: anywhere; }

@media (max-width: 1280px) {
    #normative-screen .normative-content { width: min(1100px, calc(100% - 48px)); }
    .normative-columns { gap: 20px; }
    .templates-content { width: min(1040px, calc(100% - 48px)); }
}

@media (max-width: 900px) {
    .intro { height: clamp(230px, 34vh, 360px); min-height: 0; }
    #home-screen .art-crop img,
    #normative-screen .art-crop img,
    #templates-screen .art-crop img {
        width: clamp(245px, 34vh, 330px);
        height: clamp(245px, 34vh, 330px);
        top: 22px;
    }
    #normative-screen .intro { height: clamp(215px, 31vh, 330px); min-height: 0; }
    .actions, .normative-content, .templates-content { width: calc(100% - 44px); }
    #normative-screen .normative-content { width: calc(100% - 44px); }
    .normative-columns { grid-template-columns: minmax(0, 1fr); }
    .normative-import { border-left: 0; border-top: 1px solid #bcbcbc; padding: 24px 0 0; }
    .normative-original { padding: 4px 0; }
    .normative-import-form { max-width: 100%; }
    .templates-panel { padding: 24px; }
    .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .template-card { min-height: 240px; padding: 19px; }
    .template-card:has(input:checked) { padding: 18px; }
}

@media (max-width: 600px) {
    .landing { min-height: 100svh; }
    .intro { height: clamp(190px, 31svh, 270px); min-height: 0; }
    #normative-screen .intro { height: clamp(178px, 28svh, 245px); min-height: 0; }
    #home-screen .art-crop img,
    #normative-screen .art-crop img,
    #templates-screen .art-crop img {
        width: clamp(190px, 27svh, 235px);
        height: clamp(190px, 27svh, 235px);
        top: 18px;
    }
    .actions, .normative-content, .templates-content,
    #normative-screen .normative-content { width: calc(100% - 28px); }
    .upload-panel { height: 142px; }
    .upload-target { padding: 16px 12px; }
    .upload-title { max-width: calc(100% - 20px); font-size: clamp(14px, 4vw, 17px); }
    #file-hint { font-size: 14px; }
    .upload-description { font-size: 11px; line-height: 1.45; }
    .analyze-link { width: min(100%, 340px); min-height: 48px; margin-top: 25px; font-size: 16px; }
    .secondary-links { margin: 22px 0 26px; gap: 9px; }
    .secondary-links > button, .secondary-links > a { min-height: 42px; }
    .templates-panel, #normative-screen .normative-panel { padding: 18px 13px 20px; }
    .templates-panel legend, #normative-screen .normative-panel legend {
        max-width: calc(100vw - 64px); font-size: 16px; white-space: normal;
        text-align: center; overflow-wrap: anywhere;
    }
    .template-grid { grid-template-columns: 1fr; gap: 12px; }
    .template-card { min-height: 0; padding: 17px; }
    .template-card:has(input:checked) { padding: 16px; }
    .template-card-header { margin-bottom: 12px; }
    .template-actions { flex-direction: column; align-items: stretch; }
    .template-actions .back-button, .template-actions .template-run { width: 100%; min-width: 0; }
    .documents-grid { grid-template-columns: 1fr; gap: 13px; }
    .documents-panel { min-height: 0; }
    .normative-heading { margin-bottom: 17px; }
    .normative-dropzone { min-height: 116px; }
    .imported-item { gap: 8px; }
    .imported-badge { display: none; }
    .back-button { width: min(100%, 340px); margin-top: 24px; }
    .requirements-modal { padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .requirements-dialog { width: 100%; max-height: calc(100dvh - 24px); padding: 31px 19px 20px; }
    .requirements-dialog h2 { padding-right: 24px; font-size: clamp(19px, 5.5vw, 25px); }
    .requirements-description { font-size: 13px; }
    .requirements-dropzone { min-height: 126px; padding: 15px 12px; }
    .requirements-drop-title { font-size: 15px; }
    .requirements-actions { gap: 9px; }
    .requirements-actions button { min-height: 46px; }
}

@media (max-width: 380px) {
    .actions, .normative-content, .templates-content,
    #normative-screen .normative-content { width: calc(100% - 22px); }
    .templates-panel, #normative-screen .normative-panel { padding-left: 10px; padding-right: 10px; }
    .secondary-links .templates-open, .secondary-links .normative-open { font-size: 12px; padding: 9px 12px; }
    .requirements-dialog { padding-left: 15px; padding-right: 15px; }
}

@media (max-height: 650px) and (orientation: landscape) {
    .intro, #normative-screen .intro { height: 150px; min-height: 0; }
    #home-screen .art-crop img,
    #normative-screen .art-crop img,
    #templates-screen .art-crop img { width: 170px; height: 170px; top: 8px; }
    .requirements-modal { align-items: flex-start; overflow-y: auto; }
    .requirements-dialog { max-height: none; margin: auto 0; }
}


/* Floating sculpture: reserve space for the entire animation on every screen.
   This override is placed LAST so older fixed top / size rules cannot clip it. */
#home-screen .intro,
#templates-screen .intro {
    height: clamp(255px, 48svh, 525px);
    min-height: 0;
    max-height: none;
}
#normative-screen .intro {
    height: clamp(232px, 42svh, 455px);
    min-height: 0;
    max-height: none;
}
#home-screen .art-crop img,
#templates-screen .art-crop img {
    width: clamp(186px, calc(48svh - 112px), 405px);
    height: auto;
    aspect-ratio: 1;
    top: 64px;
}
#normative-screen .art-crop img {
    width: clamp(165px, calc(42svh - 99px), 340px);
    height: auto;
    aspect-ratio: 1;
    top: 56px;
}
@media (max-width: 600px) {
    #home-screen .intro,
    #templates-screen .intro {
        height: clamp(210px, 34svh, 306px);
    }
    #normative-screen .intro {
        height: clamp(207px, 32svh, 292px);
    }
    #home-screen .art-crop img,
    #templates-screen .art-crop img {
        width: clamp(150px, calc(34svh - 84px), 202px);
        height: auto;
        top: 44px;
    }
    #normative-screen .art-crop img {
        width: clamp(148px, calc(32svh - 82px), 192px);
        height: auto;
        top: 44px;
    }
}
@media (max-height: 480px) and (orientation: landscape) {
    #home-screen .intro,
    #templates-screen .intro,
    #normative-screen .intro { height: 178px; }
    #home-screen .art-crop img,
    #normative-screen .art-crop img,
    #templates-screen .art-crop img { width: 118px; height: 118px; top: 40px; }
}
