:root {
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --accent: #EC4899;
    --bg-dark: #0F172A;
    /* Slate 900 */
    --bg-panel: #1E293B;
    /* Slate 800 */
    --bg-input: #0B1120;
    /* Darker Slate */
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: #334155;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --border-radius: 12px;
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.logo h1 span {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo svg {
    color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #9333EA);
    color: white;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #475569;
}

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

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 6px;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.btn-text {
    background: transparent;
    color: var(--primary);
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-text:hover {
    text-decoration: underline;
}

/* Main Layout */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
}

@media (max-width: 1024px) {
    .grid-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.panel-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

/* Input Section */
.input-panel textarea {
    flex: 1;
    background: var(--bg-input);
    color: var(--text-main);
    border: none;
    padding: 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    min-height: 300px;
}

.input-panel textarea::placeholder {
    color: #475569;
}

.input-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.stats-row {
    display: flex;
    gap: 1rem;
}

.stat-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.stat-badge.highlight {
    color: var(--accent);
    border-color: rgba(236, 72, 153, 0.3);
    background: rgba(236, 72, 153, 0.05);
}

.stat-badge span {
    font-weight: 600;
    color: var(--text-main);
}

/* Output Section */
.output-panel {
    position: relative;
}

.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-state svg {
    opacity: 0.5;
    margin-bottom: 1rem;
}

.empty-state p {
    max-width: 250px;
    font-size: 0.875rem;
}

.results-state {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
}

.hidden {
    display: none !important;
}

.mt-4 {
    margin-top: 1rem;
}

/* Score Ring */
.score-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.score-circle {
    width: 80px;
    height: 80px;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease-out;
}

.percentage {
    fill: var(--text-main);
    font-family: inherit;
    font-size: 0.5rem;
    font-weight: 700;
    text-anchor: middle;
}

.score-details h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

/* Feedback Grid */
.feedback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.feedback-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.feedback-card h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.tag-list,
.issue-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-list li {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    background: rgba(139, 92, 246, 0.1);
    color: #C4B5FD;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 4px;
}

.issue-list {
    flex-direction: column;
}

.issue-list li {
    font-size: 0.8rem;
    color: var(--text-main);
    display: flex;
    align-items: start;
    gap: 0.5rem;
}

.issue-list li::before {
    content: "•";
    color: var(--accent);
}

/* Optimized Output */
.optimized-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.optimized-output {
    background: var(--bg-input);
    padding: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    min-height: 150px;
    border-top: 1px solid var(--border-color);
}

/* Compare View */
.compare-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.compare-col {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.compare-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 600;
}

.badge.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.badge.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.compare-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #CBD5E1;
    white-space: pre-wrap;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: var(--bg-panel);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.template-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.template-item:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

.template-item h4 {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.template-item p {
    font-size: 0.8rem;
    color: var(--text-muted);
}