:root {
    --bg-base: #f9fafb;
    --bg-panel: #ffffff;
    --bg-element: #f3f4f6;
    --bg-hover: #e5e7eb;

    --border-light: #e5e7eb;
    --border-highlight: #d1d5db;

    --text-main: #111827;
    --text-muted: #6b7280;

    --primary: #3b82f6;
    --primary-hover: #2563eb;

    /* Category Colors */
    --cat-added: #10b981;
    --cat-changed: #f59e0b;
    --cat-fixed: #ef4444;
    --cat-removed: #6366f1;

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body.dark-theme {
    --bg-base: #0f172a;
    --bg-panel: #1e293b;
    --bg-element: #334155;
    --bg-hover: #475569;

    --border-light: #334155;
    --border-highlight: #475569;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s;
}

svg {
    display: block;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.w-5 {
    width: 1.25rem;
}

.h-5 {
    height: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.h-6 {
    height: 1.5rem;
}

.hidden {
    display: none !important;
}

.text-primary {
    color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
}

.font-bold {
    font-weight: 700;
}

.mt-3 {
    margin-top: 0.75rem;
}

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

.flex-1 {
    flex: 1;
}

.w-full {
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-outline {
    background: transparent;
    border-color: var(--border-highlight);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-element);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

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

.btn-danger {
    color: #ef4444;
    background: transparent;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    gap: 1.5rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

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

.main-content {
    display: grid;
    grid-template-columns: minmax(400px, 3fr) 2fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

@media (max-width: 900px) {
    .app-layout {
        height: auto;
        min-height: 100vh;
    }

    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Panes */
.pane {
    display: flex;
    flex-direction: column;
}

.glass-pane {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.pane-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-element);
}

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

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-highlight);
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
}

.search-bar input {
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.875rem;
    outline: none;
    width: 150px;
}

/* Form */
.entry-form {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-panel);
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-element);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    color-scheme: light dark;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
}

/* Entry List */
.entries-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.entry-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem;
    position: relative;
    box-shadow: var(--shadow-sm);
}

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

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

.version-date strong {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

.version-date span {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.badge {
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
}

.badge-added {
    background-color: var(--cat-added);
}

.badge-changed {
    background-color: var(--cat-changed);
}

.badge-fixed {
    background-color: var(--cat-fixed);
}

.badge-removed {
    background-color: var(--cat-removed);
}

.badge-primary {
    background-color: var(--primary);
}

.entry-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.entry-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

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

/* Side Cards */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

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

.card-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Widget Sandbox Styles */
.widget-sandbox {
    padding: 1.5rem;
    background: #e2e8f0;
    /* Default neutral background for sandbox */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 350px;
    overflow: hidden;
    position: relative;
    border-bottom: inherit;
}

.widget-sandbox[data-theme="dark"] {
    background: #0f172a;
}

.mock-widget {
    width: 320px;
    height: 100%;
    margin: 0 auto;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.widget-sandbox[data-theme="dark"] .mock-widget {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
}

.widget-sandbox[data-theme="light"] .mock-widget {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

.mock-widget-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    flex-shrink: 0;
}

.mock-widget-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.mock-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.widget-item {
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    padding-bottom: 1rem;
}

.widget-item:last-child {
    border-bottom: none;
}

.widget-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.widget-item-version {
    font-weight: 600;
    font-size: 0.875rem;
}

.widget-item-date {
    font-size: 0.75rem;
    opacity: 0.7;
}

.widget-item-content {
    font-size: 0.8125rem;
    line-height: 1.4;
    opacity: 0.9;
}

/* Theme Controls inside preview header */
.theme-controls {
    display: flex;
    gap: 0.5rem;
}

.theme-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg);
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-color input {
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    margin: 0;
    cursor: pointer;
}

.theme-color input:checked {
    background: var(--primary);
    border-color: transparent;
}

/* Code Area */
.code-area {
    width: 100%;
    height: 100%;
    resize: none;
    background: #0f172a;
    /* Always dark for code */
    color: #60a5fa;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    border: none;
    outline: none;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: var(--bg-base);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.875rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

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