/* ===== Design System: Light Theme ===== */
:root {
    --primary: #2563EB;
    --primary-light: #3B82F6;
    --primary-bg: rgba(37, 99, 235, 0.08);
    --primary-glow: rgba(37, 99, 235, 0.2);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.08);
    --warning: #f59e0b;
    --error: #ef4444;
    --cta: #F97316;
    --bg: #F8FAFC;
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.04);
    --radius: 0.75rem;
    --radius-lg: 1rem;
}

/* ===== Utility Classes ===== */
.text-red {
    color: var(--error) !important;
}

.cell-center {
    text-align: center !important;
}

.diff-key-info {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 0.2rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== App Container ===== */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.inline-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    flex-shrink: 0;
}

.tab-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

/* ===== Tabs ===== */
.tabs-container {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    background: var(--card-bg);
    padding: 0.35rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--border-light);
}

.tab-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.tab-btn.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* ===== Settings Grid & Compare Grid ===== */
.settings-grid,
.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .settings-grid,
    .compare-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Mode Selector ===== */
.mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.format-options {
    grid-template-columns: repeat(3, 1fr);
}

.feature-options-card {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.feature-options-card.is-disabled {
    opacity: 0.55;
}

.toggle-option {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--border-light);
    cursor: pointer;
}

.toggle-option input {
    margin-top: 0.2rem;
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.toggle-copy .title {
    font-weight: 700;
    color: var(--text);
}

.toggle-copy .desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.mode-card {
    cursor: pointer;
}

.mode-card input {
    display: none;
}

.mode-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: var(--border-light);
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.mode-inner-compact {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    padding: 1rem;
}

.mode-card:hover .mode-inner {
    border-color: var(--border);
    background: #fff;
}

.mode-card input:checked + .mode-inner {
    background: var(--primary-bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.mode-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg);
    border-radius: var(--radius);
    color: var(--primary);
    flex-shrink: 0;
}

.mode-icon i,
.mode-icon svg {
    width: 22px;
    height: 22px;
}

.mode-info span {
    display: block;
}

.mode-info .title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.mode-info .desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Encoding selector green tint */
.encoding-selector .mode-icon {
    background: var(--success-bg);
    color: var(--success);
}

.encoding-selector input:checked + .mode-inner {
    background: var(--success-bg);
    border-color: var(--success);
    box-shadow: 0 0 0 1px var(--success);
}

/* ===== Upload Drop Zone ===== */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.drop-zone.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    border-style: solid;
    background: var(--border-light);
}

.drop-zone.disabled:hover {
    border-color: var(--border);
    background: var(--border-light);
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.upload-lucide {
    width: 48px;
    height: 48px;
    stroke-width: 1.5;
}

.upload-text {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Startup Overlay */
.startup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 250, 252, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: var(--radius-lg);
    z-index: 10;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Status Card ===== */
.status-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.indicator.running {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: blink 1.5s infinite;
}

.indicator.success {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.indicator.error {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.status-text h4 {
    font-size: 1.1rem;
    color: var(--text);
}

.status-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.spinner {
    margin-left: auto;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== Terminal (keep dark) ===== */
.terminal-container {
    background: #1E293B;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid #334155;
}

.terminal-header {
    background: #334155;
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94A3B8;
}

.terminal {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    padding: 1.25rem;
    height: 180px;
    overflow-y: auto;
    font-size: 0.8rem;
    color: #E2E8F0;
    white-space: pre-wrap;
    word-break: break-all;
    background: #0F172A;
}

.clear-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 0.7rem;
    font-family: inherit;
    transition: color 0.2s;
}

.clear-btn:hover {
    color: #E2E8F0;
}

.clear-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-window {
    width: 100%;
    max-width: 450px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal-header h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.modal-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.sheet-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.sheet-item {
    background: var(--border-light);
    border: 1px solid var(--border);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    text-align: left;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.sheet-item:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    transform: translateX(4px);
}

.sheet-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-secondary {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
}

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

/* ===== Primary Button ===== */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--primary-glow);
    font-family: inherit;
}

.btn-primary:hover:not(:disabled) {
    background: #1D4ED8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

/* Compare actions */
.compare-actions {
    text-align: center;
    margin-top: 1rem;
}

/* Compare result */
#compare-result {
    margin-top: 1.5rem;
}

.compare-logic-card {
    margin-top: 1.5rem;
}

.compare-logic-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.compare-logic-list li + li {
    margin-top: 0.35rem;
}

/* ===== Footer ===== */
.app-footer {
    margin-top: auto;
    padding-top: 4rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.version-tag {
    font-size: 0.7rem;
    opacity: 0.5;
}

.privacy-note {
    margin-top: 1rem;
    font-size: 0.75rem;
    background: var(--success-bg);
    color: var(--success);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .mode-options {
        grid-template-columns: 1fr;
    }

    .format-options {
        grid-template-columns: repeat(3, 1fr);
    }

    h1 {
        font-size: 1.75rem;
    }

    .app-container {
        padding: 1.5rem 0.75rem;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem;
    }
}

/* ===== Scrollbar (light track) ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--border-light);
}

::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Terminal scrollbar stays dark */
.terminal::-webkit-scrollbar-track {
    background: #0F172A;
}

.terminal::-webkit-scrollbar-thumb {
    background: #334155;
}

.terminal::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ===== Focus States ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== Diff Styles ===== */

/* Diff Summary */
.diff-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
}

.diff-stat {
    flex: 1;
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--border-light);
    border: 1px solid var(--border);
}

.diff-stat-num {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
}

.diff-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.diff-stat.modified .diff-stat-num {
    color: var(--warning);
}

.diff-stat.added .diff-stat-num {
    color: var(--success);
}

.diff-stat.deleted .diff-stat-num {
    color: var(--error);
}

/* Diff Table */
.diff-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.diff-table thead {
    background: var(--border-light);
}

.diff-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.diff-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diff-table tr:hover {
    background: var(--border-light);
}

.diff-table tr.diff-modified {
    border-left: 3px solid var(--warning);
}

.diff-table tr.diff-added {
    border-left: 3px solid var(--success);
}

.diff-table tr.diff-deleted {
    border-left: 3px solid var(--error);
}

.diff-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 600;
}

.diff-badge.diff-modified {
    background: rgba(245, 158, 11, 0.12);
    color: #D97706;
}

.diff-badge.diff-added {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.diff-badge.diff-deleted {
    background: rgba(239, 68, 68, 0.12);
    color: #DC2626;
}

td.diff-old {
    color: var(--error);
    text-decoration: line-through;
    opacity: 0.7;
}

td.diff-new {
    color: var(--success);
    font-weight: 600;
}

/* Compare Side */
.compare-side .drop-zone {
    padding: 3rem 1.5rem;
}

td.diff-sheet {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Diff Section */
.diff-section {
    margin-top: 1.5rem;
}

.diff-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding-left: 0.25rem;
}

/* Diff Sheet Tabs */
.diff-sheet-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.diff-sheet-tab {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.diff-sheet-tab:hover {
    background: var(--border-light);
    color: var(--text);
}

.diff-sheet-tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.diff-sheet-tab.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.diff-tab-count {
    display: inline-block;
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
    font-size: 0.65rem;
    margin-left: 0.3rem;
}

.diff-tab-count.consistent {
    background: var(--success-bg);
    color: var(--success);
}

.diff-sheet-panel {
    margin-top: 0.75rem;
}

/* ===== Version History ===== */
.history-timeline {
    position: relative;
    padding: 1rem 0;
}

.history-item {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 2rem;
    border-left: 2px solid var(--primary);
}

.history-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.history-date {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.history-content {
    background: var(--border-light);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius);
}

.history-content p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    color: var(--text);
}

.history-content ul {
    margin-left: 1.2rem;
    list-style-type: square;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-content li {
    margin-bottom: 0.3rem;
}

.history-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1rem;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: opacity 0.2s;
}

.history-link:hover {
    text-decoration: underline;
}

.badge-version {
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.5rem;
}
