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

:root {
    --db-dark-blue: #192340;
    --db-red: #C93225;
    --db-blue: #2D4EC5;
    --db-white: #FFFFFF;
    --db-light-blue: #C0E5F0;
    --db-light-accent: #FDEA67;
    --db-text-dark: #192340;
    --db-text-light: #FFFFFF;
    --db-text-body: #333333;
    --db-text-muted: #666666;
    --db-border-light: #E0E0E0;

    --db-font-heading: Georgia, 'Times New Roman', serif;
    --db-font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --db-font-weight-body: 200;
    --db-font-weight-bold: 700;

    --db-radius-button: 4px;
    --db-transition: all 0.2s ease;

    --db-red-hover: #A82A1E;
    --db-blue-hover: #1e3a9e;
    --db-green: #2ea043;
}

body {
    font-family: var(--db-font-body);
    font-weight: var(--db-font-weight-body);
    background: var(--db-white);
    color: var(--db-text-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: var(--db-dark-blue);
    padding: 1.25rem 2rem;
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo {
    height: 48px;
    width: auto;
}

.header-accent {
    height: 2px;
    background: var(--db-red);
}

/* Tool title */
.tool-title {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 0.5rem;
}

.tool-title h2 {
    font-family: var(--db-font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--db-text-dark);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.15rem;
}

.tool-subtitle {
    font-family: var(--db-font-body);
    font-size: 0.85rem;
    font-weight: var(--db-font-weight-body);
    color: var(--db-text-muted);
    letter-spacing: 0.04em;
}

/* Main */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

/* Input */
.input-section label {
    display: block;
    font-size: 14px;
    font-weight: var(--db-font-weight-body);
    color: var(--db-text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

#source-input {
    width: 100%;
    min-height: 240px;
    padding: 1rem;
    background: var(--db-white);
    border: 1px solid var(--db-border-light);
    color: var(--db-text-body);
    font-family: var(--db-font-body);
    font-size: 14px;
    font-weight: var(--db-font-weight-body);
    line-height: 1.7;
    resize: vertical;
    border-radius: var(--db-radius-button);
}

#source-input:focus {
    outline: none;
    border-color: var(--db-blue);
}

#source-input::placeholder {
    color: #aaa;
}

.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

#char-count {
    font-size: 12px;
    color: var(--db-text-muted);
}

#generate-btn {
    background: var(--db-red);
    color: var(--db-text-light);
    border: none;
    padding: 0.7rem 2rem;
    font-size: 14px;
    font-family: var(--db-font-body);
    font-weight: var(--db-font-weight-bold);
    cursor: pointer;
    border-radius: var(--db-radius-button);
    transition: var(--db-transition);
}

#generate-btn:hover {
    background: var(--db-red-hover);
    transform: scale(1.02);
}

#generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    color: #888;
    transform: none;
}

/* Loading */
.loading-section {
    text-align: center;
    padding: 3rem 0;
}

.loading-inner {
    display: inline-block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--db-border-light);
    border-top-color: var(--db-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-stage {
    font-size: 14px;
    font-weight: var(--db-font-weight-body);
    color: var(--db-text-dark);
    margin-bottom: 1.5rem;
}

.pipeline-steps {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #bbb;
    font-size: 12px;
    font-weight: var(--db-font-weight-body);
    transition: color 0.3s;
}

.step.active {
    color: var(--db-text-dark);
    font-weight: var(--db-font-weight-bold);
}

.step.done {
    color: var(--db-green);
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--db-font-weight-bold);
}

/* Output */
.output-section {
    margin-top: 2rem;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.output-header h2 {
    font-family: var(--db-font-heading);
    font-size: 1.2rem;
    color: var(--db-text-dark);
}

.output-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-copy {
    background: var(--db-blue);
    color: var(--db-text-light);
    border: none;
    padding: 8px 16px;
    font-size: 12px;
    font-family: var(--db-font-body);
    font-weight: var(--db-font-weight-body);
    cursor: pointer;
    border-radius: var(--db-radius-button);
    transition: var(--db-transition);
}

.btn-copy:hover {
    background: var(--db-white);
    color: var(--db-blue);
    outline: 1px solid var(--db-blue);
    transform: scale(1.02);
}

.btn-secondary {
    background: transparent;
    color: var(--db-text-dark);
    border: 1px solid var(--db-text-dark);
    padding: 8px 16px;
    font-size: 12px;
    font-family: var(--db-font-body);
    font-weight: var(--db-font-weight-body);
    cursor: pointer;
    border-radius: var(--db-radius-button);
    transition: var(--db-transition);
}

.btn-secondary:hover {
    background: var(--db-dark-blue);
    color: var(--db-text-light);
    transform: scale(1.02);
}

/* Article output */
.article-output {
    background: var(--db-white);
    border: 1px solid var(--db-border-light);
    border-radius: 0;
    padding: 2rem;
    line-height: 1.5;
    font-size: 16px;
    font-weight: var(--db-font-weight-body);
    color: var(--db-text-body);
}

.article-output .field-label {
    color: var(--db-red);
    font-weight: var(--db-font-weight-bold);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: block;
    margin-top: 1.5rem;
    margin-bottom: 0.25rem;
}

.article-output .field-label:first-child {
    margin-top: 0;
}

.article-output .headline-text {
    font-family: var(--db-font-heading);
    font-size: 32px;
    font-weight: 700;
    line-height: 36px;
    color: var(--db-text-dark);
    margin-bottom: 0.25rem;
}

.article-output .subtitle-text {
    font-family: var(--db-font-body);
    font-size: 16px;
    font-weight: var(--db-font-weight-body);
    color: var(--db-text-muted);
    line-height: 24px;
    margin-bottom: 0.75rem;
}

.article-output .category-text {
    display: inline-block;
    background: var(--db-red);
    color: var(--db-text-light);
    padding: 0.15rem 0.6rem;
    font-size: 11px;
    font-weight: var(--db-font-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.article-output .body-text {
    margin-top: 0.5rem;
    font-size: 16px;
    font-weight: var(--db-font-weight-body);
    line-height: 24px;
    color: var(--db-text-body);
}

.article-output .body-text p {
    margin-bottom: 1rem;
}

.article-output .body-text a.source-link {
    color: var(--db-blue);
    text-decoration: none;
    font-size: 12px;
    font-weight: var(--db-font-weight-bold);
    vertical-align: baseline;
    transition: var(--db-transition);
}

.article-output .body-text a.source-link:hover {
    text-decoration: underline;
    color: var(--db-red);
}

.article-output .meta-block a.source-link {
    color: var(--db-blue);
    text-decoration: none;
    font-weight: var(--db-font-weight-bold);
}

.article-output .meta-block a.source-link:hover {
    text-decoration: underline;
}

.article-output .meta-block {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--db-border-light);
    font-size: 12px;
    color: var(--db-text-muted);
    line-height: 1.6;
}

/* Debug */
.debug-panel {
    margin-top: 1.5rem;
    background: #f8f8f8;
    border: 1px solid var(--db-border-light);
    padding: 1.5rem;
}

.debug-panel h3 {
    font-size: 12px;
    font-weight: var(--db-font-weight-bold);
    color: var(--db-red);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.debug-panel h3:not(:first-child) {
    margin-top: 1.5rem;
}

.debug-panel pre {
    background: var(--db-white);
    border: 1px solid var(--db-border-light);
    border-radius: var(--db-radius-button);
    padding: 1rem;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--db-text-muted);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.5;
}

/* Error */
.error-section {
    text-align: center;
    padding: 2rem;
    background: #fef2f2;
    border: 1px solid #f5c6c6;
    border-radius: var(--db-radius-button);
    margin-top: 2rem;
}

.error-section p {
    color: var(--db-red);
    margin-bottom: 1rem;
    font-size: 14px;
}

/* Footer */
footer {
    background: var(--db-dark-blue);
    padding: 1.5rem 2rem;
}

.footer-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-logo {
    height: 28px;
    width: auto;
    opacity: 0.6;
}

footer p {
    color: var(--db-text-light);
    opacity: 0.4;
    font-size: 11px;
    font-weight: var(--db-font-weight-body);
}

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 640px) {
    main {
        padding: 1rem;
    }

    header {
        padding: 1rem;
    }

    .header-logo {
        height: 36px;
    }

    .tool-title h2 {
        font-size: 1.5rem;
    }

    .pipeline-steps {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .article-output {
        padding: 1rem;
    }

    .article-output .headline-text {
        font-size: 24px;
        line-height: 26px;
    }

    .footer-inner {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* Login */
.login-main {
    max-width: 440px;
    margin: 0 auto;
    padding: 3rem 2rem;
    flex: 1;
    width: 100%;
}

.login-card {
    background: var(--db-white);
    border: 1px solid var(--db-border-light);
    border-radius: var(--db-radius-button);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.login-heading {
    font-family: var(--db-font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--db-text-dark);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.login-sub {
    font-size: 13px;
    color: var(--db-text-muted);
    margin-bottom: 1.5rem;
}

.login-card label {
    display: block;
    font-size: 13px;
    color: var(--db-text-muted);
    margin-bottom: 0.4rem;
    margin-top: 0.75rem;
    letter-spacing: 0.02em;
}

.login-card input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--db-white);
    border: 1px solid var(--db-border-light);
    color: var(--db-text-body);
    font-family: var(--db-font-body);
    font-size: 14px;
    font-weight: var(--db-font-weight-body);
    border-radius: var(--db-radius-button);
    transition: var(--db-transition);
}

.login-card input:focus {
    outline: none;
    border-color: var(--db-blue);
    box-shadow: 0 0 0 3px rgba(45, 78, 197, 0.15);
}

.login-btn {
    margin-top: 1.5rem;
    background: var(--db-red);
    color: var(--db-text-light);
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 14px;
    font-family: var(--db-font-body);
    font-weight: var(--db-font-weight-bold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: var(--db-radius-button);
    transition: var(--db-transition);
}

.login-btn:hover {
    background: var(--db-red-hover);
    transform: scale(1.02);
}

.login-error {
    background: #fdecea;
    border: 1px solid var(--db-red);
    color: var(--db-red);
    padding: 0.7rem 0.9rem;
    font-size: 13px;
    border-radius: var(--db-radius-button);
    margin-bottom: 1rem;
}
