:root {
    --bg-top: #f6efe5;
    --bg-bottom: #e4ecf5;
    --surface: rgba(255, 251, 247, 0.86);
    --surface-strong: #fffdf9;
    --surface-muted: #f3eee7;
    --ink: #1f2933;
    --ink-soft: #5d6976;
    --line: rgba(104, 83, 53, 0.14);
    --line-strong: rgba(104, 83, 53, 0.24);
    --primary: #1f5c7a;
    --primary-dark: #18485f;
    --accent: #a56a2a;
    --success: #2f7d5c;
    --error: #b34337;
    --warning: #b5761e;
    --shadow-lg: 0 24px 70px rgba(47, 38, 26, 0.16);
    --shadow-md: 0 12px 30px rgba(47, 38, 26, 0.1);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

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

body {
    min-height: 100vh;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    line-height: 1.6;
    color: var(--ink);
    background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    padding: 32px 18px 60px;
}

.page-shell {
    max-width: 1320px;
    margin: 0 auto;
}

.container {
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 36px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-lg);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(240px, 0.8fr);
    gap: 24px;
    padding: 28px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, rgba(255, 252, 248, 0.96), rgba(242, 236, 225, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
    background: rgba(31, 92, 122, 0.1);
    margin-bottom: 12px;
}

h1,
h2 {
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    line-height: 1.05;
    color: #1e3442;
    max-width: 20ch;
    text-wrap: balance;
}

.subtitle {
    margin-top: 14px;
    max-width: none;
    color: var(--ink-soft);
    font-size: 1.02rem;
}

.hero-copy {
    min-width: 0;
}

.hero-panel {
    display: grid;
    gap: 14px;
    align-content: start;
}

.hero-stat {
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.hero-stat strong {
    display: block;
    font-size: 1.05rem;
    color: #223847;
}

.hero-stat span {
    display: block;
    margin-top: 4px;
    color: var(--ink-soft);
    font-size: 0.92rem;
}

.workflow-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 26px;
}

.workflow-step {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 10px;
    border-radius: 999px;
    background: rgba(255, 253, 249, 0.75);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 600;
}

.workflow-step span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: white;
    background: rgba(31, 92, 122, 0.5);
}

.workflow-step.active {
    color: var(--primary-dark);
    border-color: rgba(31, 92, 122, 0.26);
    background: linear-gradient(135deg, rgba(31, 92, 122, 0.16), rgba(165, 106, 42, 0.08));
}

.workflow-step.active span {
    background: var(--primary);
}

.step-card,
.error-section {
    margin-bottom: 22px;
    padding: 24px;
    border-radius: var(--radius-xl);
    background: rgba(255, 251, 247, 0.96);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

.upload-section {
    background: rgba(255, 250, 244, 0.98);
}

.results-section {
    position: relative;
}

.results-section::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent), var(--primary));
}

.hidden {
    display: none;
}

.section-heading {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.section-heading-spread {
    justify-content: space-between;
    flex-wrap: wrap;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(165, 106, 42, 0.14);
    color: #8a531f;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

h2 {
    color: #243746;
    font-size: 1.55rem;
    margin-bottom: 4px;
}

.section-description {
    color: var(--ink-soft);
    width: 100%;
    max-width: none;
}

.file-input-wrapper,
.draft-type-selector {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

input[type="file"],
.draft-type-select,
.custom-prompt-input,
.draft-textarea,
.full-text-textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input[type="file"] {
    flex: 1 1 280px;
    padding: 12px 14px;
}

.draft-type-selector label,
.custom-prompt-container label {
    font-weight: 700;
    color: #314859;
}

.draft-type-select {
    flex: 1 1 320px;
    padding: 12px 14px;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 12px 20px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.96rem;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 10px 24px rgba(31, 52, 66, 0.12);
}

.btn:hover {
    transform: translateY(-1px);
}

.button-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.95);
    animation: spin 0.8s linear infinite;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.btn:disabled .button-spinner {
    opacity: 1;
}

.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), #2b7598);
}

.btn-secondary {
    color: white;
    background: linear-gradient(135deg, #7b674f, #9a835f);
}

.btn-warning {
    color: white;
    background: linear-gradient(135deg, var(--warning), #c98c34);
}

.status-message {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 0.94rem;
}

.status-message.loading {
    color: var(--primary-dark);
    background: rgba(31, 92, 122, 0.11);
}

.status-message.success {
    color: #215b44;
    background: rgba(47, 125, 92, 0.12);
}

.status-message.error {
    color: #8d342b;
    background: rgba(179, 67, 55, 0.11);
}

.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

.alert-error {
    color: var(--error);
    background: rgba(179, 67, 55, 0.11);
    border: 1px solid rgba(179, 67, 55, 0.18);
}

.error-section {
    background: rgba(255, 245, 242, 0.92);
}

.info-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.info-chip {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(31, 92, 122, 0.1);
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 700;
}

.full-text-textarea,
.draft-textarea {
    padding: 16px 18px;
    resize: vertical;
    line-height: 1.65;
}

.full-text-textarea {
    min-height: 360px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.98rem;
    background: rgba(255, 255, 255, 0.88);
}

.draft-textarea {
    min-height: 340px;
    margin-top: 14px;
    font-family: "Courier New", monospace;
    font-size: 0.95rem;
}

.custom-prompt-container {
    margin-bottom: 15px;
}

.custom-prompt-input {
    min-height: 120px;
    padding: 14px 16px;
    font-size: 0.97rem;
    line-height: 1.6;
    resize: vertical;
}

.keywords-container,
.normas-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 6px;
}

.semantic-queries-list {
    list-style: none;
    display: grid;
    gap: 10px;
}

.semantic-query-item,
.norma-item {
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
}

.semantic-query-item {
    position: relative;
    padding-left: 52px;
}

.semantic-query-item::before {
    content: "Q";
    position: absolute;
    left: 18px;
    top: 16px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(31, 92, 122, 0.14);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
}

.norma-item strong {
    display: block;
    margin-bottom: 6px;
    color: #273847;
}

.norma-item p {
    color: var(--ink-soft);
}

.norma-more {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.56);
    border: 1px dashed var(--line-strong);
}

.draft-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

input[type="file"]:focus,
.draft-type-select:focus,
.custom-prompt-input:focus,
.draft-textarea:focus,
.full-text-textarea:focus {
    outline: none;
    border-color: rgba(31, 92, 122, 0.45);
    box-shadow: 0 0 0 4px rgba(31, 92, 122, 0.1);
}

@media (max-width: 900px) {
    .container {
        padding: 18px;
        border-radius: 24px;
    }

    .hero {
        grid-template-columns: 1fr;
        padding: 22px;
    }

    .workflow-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .section-heading,
    .section-heading-spread,
    .file-input-wrapper,
    .draft-type-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .step-badge {
        width: fit-content;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 560px) {
    body {
        padding: 16px 12px 40px;
    }

    .workflow-strip {
        grid-template-columns: 1fr;
    }

    h1 {
        max-width: none;
        text-wrap: pretty;
    }

    .step-card,
    .error-section {
        padding: 18px;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
