:root {
    /* Light Mode */
    --bg-main: #F8FAFC;
    --surface: #FFFFFF;
    --surface-hover: #F1F5F9;
    --border: #E2E8F0;
    
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #FBBF24;
    
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: 200ms ease;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-main: #0B0F19;
    --surface: #1E293B;
    --surface-hover: #334155;
    --border: #334155;
    
    --primary: #6366F1;
    --primary-hover: #818CF8;
    
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;

    --shadow-sm: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.5);
}

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

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

/* Header */
.app-header {
    height: 64px;
    background: rgba(var(--surface-rgb), 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

:root:not([data-theme="dark"]) .app-header { background: rgba(255, 255, 255, 0.85); }
[data-theme="dark"] .app-header { background: rgba(30, 41, 59, 0.85); }

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

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

.logo span {
    font-weight: 400;
    color: var(--text-muted);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--primary);
    background: var(--surface-hover);
}

/* Layout */
.app-layout {
    flex: 1;
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem;
    gap: 2rem;
}

/* Sidebar */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (max-width: 800px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; gap: 1rem; }
}

.sidebar-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.history-list, .favorites-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-list li, .favorites-list li {
    font-size: 0.9rem;
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface);
    border: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-list li:hover, .favorites-list li:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.empty-text {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
    font-style: italic;
    cursor: default !important;
    padding: 0 !important;
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* Input Section */
.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.input-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.tone-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tone-selector label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tone-selector select {
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.tone-selector select:focus {
    border-color: var(--primary);
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#microcopyInput {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1.05rem;
    resize: none;
    outline: none;
    transition: var(--transition);
}

#microcopyInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Results */
.results-section {
    position: relative;
    min-height: 200px;
}

.results-header {
    margin-bottom: 1.5rem;
}

.results-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

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

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.suggestion-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.suggestion-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition);
}

.suggestion-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.suggestion-card:hover::before {
    opacity: 1;
}

.suggestion-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.4;
}

.suggestion-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    opacity: 0.7;
    transition: var(--transition);
}

.suggestion-card:hover .suggestion-actions { opacity: 1; }

.copy-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-star {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-star:hover, .btn-star.active {
    color: var(--secondary);
    fill: var(--secondary);
}

.btn-star.active svg { fill: var(--secondary); }

/* Empty / Loading */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

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

.loading-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(var(--bg-main), 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
    border-radius: var(--radius-lg);
    color: var(--primary);
    font-weight: 600;
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(79, 70, 229, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.toast.show {
    bottom: 2rem;
}
