:root {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --bg-color: #0f1117;
    --surface-color: #1a1d27;
    --surface-hover: #22252f;
    --text-main: #e2e8f0;
    --text-muted: #8892a4;
    --border-color: #2d3348;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.app-main {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    flex: 1;
}

@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.panel-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.output-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

input[type="url"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: #141620;
    color: var(--text-main);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

input[type="url"] {
    padding-left: 2.75rem;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.url-list-area {
    min-height: 80px;
    font-size: 0.875rem;
    line-height: 1.6;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.editor-wrapper.dragover {
    box-shadow: 0 0 0 2px var(--primary-color);
}

.editor-wrapper.dragover textarea {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.05);
}


.editor-wrapper textarea {
    flex: 1;
    min-height: 400px;
    resize: none;
    background-color: #111320;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    line-height: 1.8;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--surface-hover);
    border-color: #3d4459;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
}

.btn-icon:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}

.btn-close {
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 0.25rem;
}

.btn-close:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Status Message */
.status-message {
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    text-align: center;
}

.status-message.error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-message.success {
    background-color: rgba(34, 197, 94, 0.1);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.status-message.info {
    background-color: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
}

.modal-content {
    position: relative;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 450px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 51;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    display: flex;
    justify-content: flex-end;
}

.hidden {
    display: none !important;
}

/* ============================================================
   Header Navigation
   ============================================================ */
.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: var(--transition);
}

.nav-link:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}

.nav-link.active {
    background-color: rgba(129, 140, 248, 0.12);
    color: var(--primary-color);
}

a.nav-link {
    opacity: 0;
}

/* ============================================================
   Step Progress Bar
   ============================================================ */
.step-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.5rem 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    cursor: default;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    border: 2px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.step-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.step-item.active .step-number {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 0 16px rgba(129, 140, 248, 0.35);
}

.step-item.active .step-label {
    color: var(--primary-color);
}

.step-item.completed .step-number {
    border-color: #22c55e;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.step-item.completed .step-number::after {
    content: '✓';
    font-size: 0.875rem;
}

.step-item.completed .step-number {
    font-size: 0;
}

.step-item.completed .step-label {
    color: #86efac;
}

.step-connector {
    width: 60px;
    height: 2px;
    background-color: var(--border-color);
    margin: 0 0.25rem;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s ease;
    border-radius: 1px;
}

.step-connector.active {
    background: linear-gradient(90deg, #22c55e, var(--primary-color));
}

@media (max-width: 480px) {
    .step-connector {
        width: 30px;
    }
    .step-label {
        font-size: 0.65rem;
    }
}

/* ============================================================
   Blog Page Layout
   ============================================================ */
.blog-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* ブログ作成ページはアプリ全体のコンテンツ幅に合わせる */
.blog-writing-main {
    max-width: none;
}

.blog-panel {
    width: 100%;
}

/* Step content show/hide */
.step-content {
    display: none;
    animation: fadeSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.step-content.active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   Style Guide Status Badge
   ============================================================ */
.style-guide-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.style-guide-status.loaded {
    background-color: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.style-guide-status.warning {
    background-color: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.style-guide-status-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.style-guide-status.loaded .style-guide-status-icon {
    color: #86efac;
}

.style-guide-status.warning .style-guide-status-icon {
    color: #fbbf24;
}

.style-guide-status-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.style-guide-status-label {
    font-weight: 500;
}

.style-guide-status.loaded .style-guide-status-label {
    color: #86efac;
}

.style-guide-status.warning .style-guide-status-label {
    color: #fbbf24;
}

.style-guide-status-detail {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.style-guide-status-detail a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.style-guide-status-detail a:hover {
    text-decoration: underline;
}

/* ============================================================
   Text Input (for theme input)
   ============================================================ */
input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: #141620;
    color: var(--text-main);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

/* Required Badge */
.required-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    margin-left: 0.375rem;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

/* ============================================================
   Research Results Area
   ============================================================ */
.research-result-area {
    background-color: #111320;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    max-height: 500px;
    overflow-y: auto;
}

.research-output {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-main);
}

/* Markdown Body */
.markdown-body h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.375rem;
}

.markdown-body h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0.75rem 0 0.375rem 0;
    color: var(--text-main);
}

.markdown-body h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem 0;
    color: var(--text-main);
}

.markdown-body ul {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.markdown-body li {
    margin-bottom: 0.375rem;
    line-height: 1.7;
}

.markdown-body strong {
    color: #c4b5fd;
    font-weight: 600;
}

.markdown-body code {
    background-color: rgba(129, 140, 248, 0.1);
    padding: 0.15rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.85em;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    color: var(--primary-color);
}

.markdown-body p {
    margin: 0.5rem 0;
}

/* Custom scrollbar for research area */
.research-result-area::-webkit-scrollbar {
    width: 6px;
}

.research-result-area::-webkit-scrollbar-track {
    background: transparent;
}

.research-result-area::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.research-result-area::-webkit-scrollbar-thumb:hover {
    background-color: #3d4459;
}

/* ============================================================
   Step Actions
   ============================================================ */
.step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ============================================================
   Generating Animation (STEP 3)
   ============================================================ */
.generating-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1.5rem;
    text-align: center;
}

.generating-animation h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.generating-animation p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 400px;
}

.generating-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(129, 140, 248, 0.15);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    border-right-color: var(--primary-color);
    animation: genSpin 1s ease-in-out infinite;
}

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

/* ============================================================
   Success state for buttons
   ============================================================ */
.btn-secondary.success {
    border-color: rgba(34, 197, 94, 0.4);
    color: #86efac;
    background-color: rgba(34, 197, 94, 0.08);
}

/* ============================================================
   Blog output editor
   ============================================================ */
.blog-panel .editor-wrapper {
    gap: 12px;
}

.blog-output-title {
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.75rem 1rem;
    background-color: #111320;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    width: 100%;
}

.blog-output-title:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

.blog-panel .editor-wrapper textarea {
    min-height: 500px;
}

/* ============================================================
   Toggle Switch
   ============================================================ */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 24px;
    transition: background-color 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(129, 140, 248, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background-color: var(--primary-color);
}

/* ============================================================
   Toast Notification (floating)
   ============================================================ */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: calc(100% - 2rem);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

.toast-notification.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-notification.toast-hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* Error Toast */
.toast-error {
    background-color: rgba(30, 15, 18, 0.95);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.toast-error .toast-icon {
    color: #ef4444;
}

/* Success Toast */
.toast-success {
    background-color: rgba(15, 30, 20, 0.95);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.toast-success .toast-icon {
    color: #22c55e;
}

/* Info Toast */
.toast-info {
    background-color: rgba(15, 18, 35, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
}

.toast-info .toast-icon {
    color: var(--primary-color);
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-top: 1px;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 0.25rem;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    background: none;
    border: none;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.toast-close:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.08);
}

section.ad-area {
    height: 80px;
}

@media (max-width: 480px) {
    .toast-notification {
        bottom: 1rem;
        max-width: calc(100% - 1rem);
    }
}

/* ============================================================
   Value Score Meter
   ============================================================ */
.value-score-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.value-score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-score-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.value-score-label svg {
    color: var(--primary-color);
}

.value-score-percent {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 48px;
    text-align: right;
}

.value-score-track {
    width: 100%;
    height: 8px;
    background-color: #1e2130;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.value-score-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary-color), #a78bfa);
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    width: 0%;
    position: relative;
}

.value-score-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.value-score-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================
   Context Cards (Accordion)
   ============================================================ */
.context-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.context-card {
    background-color: #141620;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.context-card:hover {
    border-color: #3d4459;
}

.context-card.has-content {
    border-color: rgba(129, 140, 248, 0.3);
}

.context-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    gap: 0.75rem;
}

.context-card-header:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.context-card-header-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
}

.context-card-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.context-card-icon.icon-persona {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.08));
    color: #fbbf24;
}

.context-card-icon.icon-experience {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.08));
    color: #60a5fa;
}

.context-card-icon.icon-data {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.08));
    color: #4ade80;
}

.context-card-icon.icon-tips {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(147, 51, 234, 0.08));
    color: #c084fc;
}

.context-card-icon.icon-qa {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15), rgba(234, 88, 12, 0.08));
    color: #fb923c;
}

.context-card-icon.icon-comparison {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(219, 39, 119, 0.08));
    color: #f472b6;
}

.context-card-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-card-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.context-card-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.context-card-badge.badge-empty {
    background-color: rgba(100, 116, 139, 0.12);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.2);
}

.context-card-badge.badge-filled {
    background-color: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.context-card-chevron {
    color: var(--text-muted);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.context-card.open .context-card-chevron {
    transform: rotate(180deg);
}

/* Card Body (collapsible) */
.context-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), padding 0.35s ease;
    padding: 0 1rem;
}

.context-card.open .context-card-body {
    max-height: 600px;
    padding: 0 1rem 1rem 1rem;
}

.context-card-body textarea {
    min-height: 80px;
    font-size: 0.875rem;
}

/* Persona card has multiple inputs instead of textarea */
.persona-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.persona-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.persona-field label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.persona-field input[type="text"] {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

/* ============================================================
   Starter Chips
   ============================================================ */
.starter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.starter-chip {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    background-color: rgba(129, 140, 248, 0.06);
    border: 1px solid rgba(129, 140, 248, 0.15);
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.starter-chip:hover {
    background-color: rgba(129, 140, 248, 0.12);
    border-color: rgba(129, 140, 248, 0.3);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.starter-chip:active {
    transform: translateY(0);
}

/* Card section divider label */
.context-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 0 0.25rem 0;
    margin-top: 0.25rem;
}

/* ============================================================
   Progress Bar
   ============================================================ */
.progress-bar-container {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background-color: #1e2130;
    border-radius: 3px;
    overflow: hidden;
    margin: 0.5rem auto 0 auto;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #a78bfa);
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================================
   MD File Upload Area
   ============================================================ */
.md-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background-color: rgba(20, 22, 32, 0.5);
    position: relative;
}

.md-upload-area:hover {
    border-color: rgba(129, 140, 248, 0.4);
    background-color: rgba(129, 140, 248, 0.04);
}

.md-upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(129, 140, 248, 0.08);
    box-shadow: 0 0 16px rgba(129, 140, 248, 0.15);
}

.md-upload-area.has-file {
    border-color: rgba(34, 197, 94, 0.35);
    background-color: rgba(34, 197, 94, 0.04);
    border-style: solid;
    cursor: default;
}

.md-upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    transition: color 0.25s ease;
}

.md-upload-area:hover .md-upload-icon {
    color: var(--primary-color);
}

.md-upload-area.has-file .md-upload-icon {
    color: #86efac;
}

.md-upload-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.md-upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.md-upload-file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.md-upload-file-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #86efac;
}

.md-upload-file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.md-upload-remove {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.md-upload-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.35);
}

.md-upload-input {
    display: none;
}

/* ============================================================
   Rewrite workspace / AI editorial chat
   ============================================================ */
.rewrite-main {
    max-width: 1400px;
}

.rewrite-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.9fr);
    gap: 1.5rem;
    align-items: start;
}

.rewrite-editor-panel,
.ai-chat-panel {
    min-width: 0;
}

.rewrite-editor-panel {
    min-height: 720px;
}

.rewrite-editor-panel .panel-header {
    align-items: flex-start;
}

.panel-eyebrow {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--primary-color);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.ai-chat-panel {
    position: sticky;
    top: 1.25rem;
    min-height: 720px;
    max-height: calc(100vh - 2.5rem);
    gap: 1rem;
    padding: 1.25rem;
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.ai-chat-header h2 {
    font-size: 1.15rem;
    margin-bottom: 0.3rem;
}

.ai-chat-header p {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.6;
}

.ai-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
    color: #86efac;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.18);
    border-radius: 999px;
    font-size: 0.65rem;
    white-space: nowrap;
}

.ai-chat-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.ai-chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.85rem;
    min-height: 280px;
    max-height: 480px;
    padding: 0.25rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.ai-chat-empty {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 1.25rem;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.8rem;
}

.ai-chat-empty-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin-bottom: 0.75rem;
    color: #c4b5fd;
    background: rgba(129, 140, 248, 0.12);
    border-radius: 14px;
}

.ai-chat-message {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 92%;
}

.ai-chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.ai-chat-message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.ai-chat-message-label {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
}

.ai-chat-bubble {
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 0.85rem;
    font-size: 0.84rem;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ai-chat-message.user .ai-chat-bubble {
    color: #f8fafc;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    border-color: rgba(196, 181, 253, 0.25);
    border-bottom-right-radius: 0.25rem;
}

.ai-chat-message.assistant .ai-chat-bubble {
    background: #111320;
    border-bottom-left-radius: 0.25rem;
}

.ai-chat-apply-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    color: #c4b5fd;
    border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: 0.4rem;
    background: rgba(129, 140, 248, 0.08);
    font-size: 0.7rem;
    font-weight: 600;
}

.ai-chat-apply-btn:hover {
    background: rgba(129, 140, 248, 0.18);
    border-color: var(--primary-color);
}

.ai-chat-apply-btn.applied {
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
}

.ai-chat-context-note {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.65rem;
    color: var(--text-muted);
    background: rgba(129, 140, 248, 0.05);
    border: 1px solid rgba(129, 140, 248, 0.12);
    border-radius: 0.45rem;
    font-size: 0.68rem;
    line-height: 1.4;
}

.ai-chat-context-note svg {
    flex-shrink: 0;
    color: var(--primary-color);
}

.ai-chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ai-chat-form textarea {
    min-height: 80px;
    max-height: 180px;
    padding: 0.7rem 0.75rem;
    resize: vertical;
    font-size: 0.84rem;
    line-height: 1.6;
}

.ai-chat-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.ai-chat-char-count {
    color: var(--text-muted);
    font-size: 0.68rem;
}

.ai-chat-send-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.8rem;
    font-size: 0.8rem;
}

.ai-chat-send-btn .spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1050px) {
    .rewrite-workspace {
        grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.95fr);
        gap: 1rem;
    }

    .rewrite-editor-panel,
    .ai-chat-panel {
        padding: 1.15rem;
    }

    .rewrite-editor-panel .actions {
        gap: 0.4rem;
    }
}

@media (max-width: 820px) {
    .rewrite-workspace {
        grid-template-columns: 1fr;
    }

    .rewrite-editor-panel,
    .ai-chat-panel {
        min-height: auto;
    }

    .ai-chat-panel {
        position: static;
        max-height: none;
    }

    .ai-chat-messages {
        min-height: 240px;
        max-height: 420px;
    }
}

@media (max-width: 560px) {
    .rewrite-editor-panel .panel-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .rewrite-editor-panel .actions {
        width: 100%;
    }

    .rewrite-editor-panel .actions .btn-sm {
        flex: 1 1 auto;
    }

    .ai-chat-header {
        flex-direction: column;
    }
}

/* Diff View Elements */
.diff-container {
    background-color: #1a1d27;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 250px;
    overflow-y: auto;
    line-height: 1.5;
}

.diff-ins {
    background-color: rgba(46, 160, 67, 0.25);
    text-decoration: none;
    color: #58a6ff;
    border-bottom: 1.5px solid #2ea043;
    padding: 2px 4px;
    border-radius: 2px;
}

.diff-del {
    background-color: rgba(248, 81, 73, 0.25);
    color: #ff7b72;
    text-decoration: line-through;
    padding: 2px 4px;
    border-radius: 2px;
}

.ai-chat-diff-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-top: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
}

.ai-chat-diff-btn:hover {
    color: var(--text-main);
    border-color: var(--primary-color);
    background-color: var(--surface-hover);
}

.diff-action-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;
}

.ai-chat-diff-apply-btn {
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    color: #ffffff;
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
}

.ai-chat-diff-apply-btn:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.ai-chat-diff-apply-btn.applied {
    background-color: var(--surface-hover);
    border-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Main Editor Diff Area */
.rewrite-diff-area {
    width: 100%;
    min-height: 400px;
    background-color: #1a1d27;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.7;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.rewrite-diff-area .diff-ins {
    background-color: rgba(46, 160, 67, 0.25);
    text-decoration: none;
    color: #58a6ff;
    border-bottom: 1.5px solid #2ea043;
    padding: 2px 4px;
    border-radius: 2px;
}

.rewrite-diff-area .diff-del {
    background-color: rgba(248, 81, 73, 0.25);
    color: #ff7b72;
    text-decoration: line-through;
    padding: 2px 4px;
    border-radius: 2px;
}

/* ============================================================
   Redesigned Rewrite Workflow (1:1 Split & Marking)
   ============================================================ */

/* 1:1 Split Layout Container */
.rewrite-split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .rewrite-split-container {
        grid-template-columns: 1fr;
    }
}

.panel-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.analysis-badge {
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Original Article View & Scroll Wrapper */
.original-article-scroll-wrapper {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    background-color: #141722;
}

.original-article-view {
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-main);
}

/* Analysis Highlight Mark */
mark.analysis-mark {
    background-color: rgba(234, 179, 8, 0.22);
    color: #fef08a;
    border-bottom: 2px solid #eab308;
    border-radius: 3px;
    padding: 2px 4px;
    cursor: pointer;
    transition: var(--transition);
}

mark.analysis-mark:hover,
mark.analysis-mark.active {
    background-color: rgba(234, 179, 8, 0.5);
    color: #ffffff;
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.4);
}

/* Analysis Popup Modal */
.analysis-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.analysis-popup-modal.hidden {
    display: none !important;
}

.analysis-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 17, 23, 0.75);
    backdrop-filter: blur(4px);
}

.analysis-popup-content {
    position: relative;
    z-index: 1001;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    background-color: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.analysis-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.analysis-popup-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-close-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.btn-close-sm:hover {
    color: var(--text-main);
    background-color: var(--surface-hover);
}

.analysis-popup-quote-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.analysis-popup-quote {
    font-size: 0.85rem;
    font-family: monospace;
    background-color: #11131c;
    border-left: 3px solid #eab308;
    padding: 0.5rem 0.75rem;
    border-radius: 0 4px 4px 0;
    margin-bottom: 0.75rem;
    color: #fef08a;
}

.analysis-popup-section {
    margin-bottom: 0.75rem;
}

.analysis-popup-section:last-child {
    margin-bottom: 0;
}

.analysis-popup-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-bottom: 0.35rem;
}

.analysis-popup-label.issue-label {
    background-color: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

.analysis-popup-label.suggestion-label {
    background-color: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

.analysis-popup-text {
    font-size: 0.875rem;
    color: var(--text-main);
    line-height: 1.6;
}

/* AI Chat Panel in Split Layout */
.ai-chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-messages {
    flex: 1;
    min-height: 320px;
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.75rem;
    background-color: #141722;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.ai-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.ai-chat-message.user {
    align-self: flex-end;
}

.ai-chat-message.assistant {
    align-self: flex-start;
}

.ai-chat-message-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.ai-chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.ai-chat-message.user .ai-chat-bubble {
    background-color: var(--primary-color);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.ai-chat-message.assistant .ai-chat-bubble {
    background-color: var(--surface-hover);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}

.ai-chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-chat-form textarea {
    width: 100%;
    background-color: #141722;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
}

.ai-chat-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ai-chat-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-char-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.rewrite-execute-wrapper {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
}

/* Tone Selector in AI Chat Panel Header */
.tone-select-wrapper {
    display: flex;
    align-items: center;
}

.tone-select {
    background-color: #141722;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.tone-select:hover,
.tone-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--surface-hover);
}

/* ============================================================
   Rewrite Analysis Panel & Highlights
   ============================================================ */
.analysis-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0;
    max-height: 70vh;
    overflow-y: auto;
}

.analysis-summary-card {
    background: rgba(20, 24, 38, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}

.analysis-summary-card h3,
.analysis-details-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analysis-summary-body {
    font-size: 0.925rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.analysis-summary-body p {
    margin-bottom: 0.75rem;
}

.analysis-summary-body ul,
.analysis-summary-body ol {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.analysis-summary-body li {
    margin-bottom: 0.35rem;
}

.analysis-highlight-item {
    background: rgba(15, 18, 30, 0.8);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.analysis-highlight-item:hover {
    background: rgba(20, 25, 42, 0.95);
    border-left-color: var(--primary-hover);
}

.analysis-highlight-item .original-snippet {
    font-size: 0.875rem;
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-family: inherit;
}

.analysis-highlight-item .suggestion-snippet {
    font-size: 0.875rem;
    color: #34d399;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.analysis-highlight-item .reason-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

/* ============================================================
   Fulltext View & Interactive Yellow Marker Highlights
   ============================================================ */
.analysis-fulltext-body {
    background: rgba(15, 18, 30, 0.85);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    font-size: 0.925rem;
    line-height: 1.85;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
}

.rewrite-highlight {
    background-color: rgba(253, 224, 71, 0.22);
    color: #fef08a;
    border-bottom: 2px solid #facc15;
    border-radius: 3px;
    padding: 0.15rem 0.35rem;
    margin: 0 0.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.rewrite-highlight:hover {
    background-color: rgba(253, 224, 71, 0.45);
    color: #ffffff;
    border-bottom-color: #ffe066;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
}

.highlight-modal-content {
    max-width: 600px;
    width: 90%;
}

.detail-section {
    margin-bottom: 1.25rem;
}

.detail-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    display: block;
}

.modal-original-text {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
    color: #f87171;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-suggestion-text {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid #10b981;
    color: #34d399;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-reason-text {
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--primary-color);
    color: var(--text-secondary);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
}


