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

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f7fb;
    color: #222;
}

.container {
    width: 90%;
    max-width: 1000px;
    margin: auto;
}

.site-header {
    background: #0f172a;
    color: white;
    padding: 20px 0;
}

.brand {
    color: white;
    text-decoration: none;
    font-size: 28px;
    font-weight: bold;
}

.hero {
    text-align: center;
    margin: 50px 0;
}

.hero h1 {
    font-size: 42px;
    margin: 15px 0;
}

.hero-text {
    color: #555;
    font-size: 18px;
}

.upload-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 6px 25px rgba(0,0,0,.08);
}

.drop-zone {
    border: 3px dashed #3b82f6;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: .3s;
}

.drop-zone:hover {
    background: #eef5ff;
}

.drop-zone.dragover {
    background: #dbeafe;
}

.drop-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.primary-button,
.secondary-button {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.primary-button {
    background: #2563eb;
    color: white;
    margin-top: 25px;
}

.primary-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.secondary-button {
    background: #f3f4f6;
}

.file-list {
    margin-top: 25px;
}

.source-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 28px 0;
    color: #6b7280;
    font-weight: 600;
}

.source-divider::before,
.source-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid #e5e7eb;
}

.webpage-source {
    text-align: left;
}

.webpage-source label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.webpage-source input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
}

.webpage-source input:focus {
    outline: 2px solid #bfdbfe;
    border-color: #2563eb;
}

.webpage-help {
    margin: 8px 0 0;
    color: #6b7280;
    font-size: 14px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.result-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 6px 25px rgba(0,0,0,.08);
    text-align: center;
}

.result-file {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    margin: 10px 0;
    border-bottom: 1px solid #eee;
}

.usage-result {
    display: block;
    text-align: left;
}

.usage-label-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.usage-label-row span {
    color: #4b5563;
}

.usage-meter {
    height: 8px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.usage-meter-fill {
    height: 100%;
    border-radius: inherit;
    background: #2563eb;
}

.usage-warning {
    color: #92400e;
}

.usage-danger {
    color: #991b1b;
}

.button-link {
    display: inline-block;
    margin-top: 25px;
    text-decoration: none;
}

.site-footer {
    text-align: center;
    padding: 40px;
    color: #666;
}

.alert {
    padding: 15px;
    margin: 20px 0;
    border-radius: 8px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.summary-box {
    margin-top: 30px;
    padding: 25px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    text-align: left;
}

.summary-box h2 {
    margin-bottom: 10px;
}

.summary-text {
    margin-top: 18px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 420px;
    margin: 25px 0;
    padding: 18px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: white;
}

.chat-messages:empty {
    display: none;
}

.chat-message {
    max-width: 80%;
    padding: 14px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.chat-message strong {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}

.chat-message p {
    margin: 0;
    white-space: pre-wrap;
}

.chat-message-user {
    align-self: flex-end;
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-ai {
    align-self: flex-start;
    background: #e5e7eb;
    color: #222;
    border-bottom-left-radius: 4px;
}

#chat-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chat-form label {
    font-weight: bold;
}

#chat-form textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    resize: vertical;
}

#chat-form textarea:focus {
    outline: 2px solid #93c5fd;
    border-color: #2563eb;
}

#chat-form .primary-button {
    align-self: flex-start;
    margin-top: 0;
}

.chat-error {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
}

@media (max-width: 600px) {
    .result-card {
        padding: 22px;
    }

    .result-file {
        flex-direction: column;
        gap: 6px;
        text-align: left;
    }

    .usage-label-row {
        align-items: flex-start;
    }

    .chat-message {
        max-width: 92%;
    }

    #chat-form .primary-button {
        width: 100%;
    }
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.site-nav a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
}

.site-nav a:hover {
    text-decoration: underline;
}

.logout-form {
    margin: 0;
}

.nav-button {
    border: 0;
    background: transparent;
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.nav-button:hover {
    text-decoration: underline;
}

@media (max-width: 700px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-nav {
        flex-wrap: wrap;
        gap: 12px;
    }
}

.generation-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0;
    cursor: pointer;
}

.generation-option input[type="checkbox"] {
    flex: 0 0 auto;
    width: auto;
    margin: 3px 0 0;
    accent-color: #2563eb;
}

.generation-option-text {
    display: block;
    line-height: 1.4;
}

.generation-option-help {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.45;
}
.generated-document-card {
    padding: 32px;
}

.generated-document-header {
    margin-bottom: 24px;
    text-align: center;
}

.document-preview {
    width: 100%;
    max-width: 850px;
    min-height: 900px;
    margin: 0 auto;
    padding: 48px 56px;
    background: #ffffff;
    border: 1px solid #dfe3ea;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    color: #222;
    text-align: left;
    line-height: 1.65;
}

.document-preview h1,
.document-preview h2,
.document-preview h3 {
    margin-top: 0;
    margin-bottom: 18px;
    text-align: left;
}

.document-preview p {
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .generated-document-card {
        padding: 16px;
    }

    .document-preview {
        min-height: 700px;
        padding: 28px 22px;
    }
}

.document-preview aside.global-knowledge {
    margin: 18px 0;
    padding: 14px 16px;
    border-left: 4px solid #d97706;
    border-radius: 4px;
    background: #fff7ed;
    color: #7c2d12;
}

.document-preview aside.global-knowledge p:last-child {
    margin-bottom: 0;
}

.document-preview span.global-knowledge {
    padding: 2px 4px;
    border-bottom: 2px dashed #d97706;
    background: #fff7ed;
    color: #7c2d12;
}
