:root {
    /* Teal Cyan Dark Palette */
    --primary: #00CEC9;
    --primary-hover: #00b5b1;
    --secondary: #81ECEC;
    --accent: #FDCB6E;
    --bg-dark: #0A1A1A;
    --bg-panel: #112A2A;
    --bg-input: #081414;
    --border: #1C4040;
    --border-focus: #00CEC9;

    --text-main: #F3F4F6;
    --text-muted: #8DBFBF;

    --error: #FF7675;
    --success: #55E6C1;
    --info: #00CEC9;

    --radius: 12px;
    --radius-sm: 8px;
    --transition: 200ms ease;

    /* Section Colors for Hex Dump / Tags */
    --color-s1: #FF7675;
    /* Type */
    --color-s2: #74B9FF;
    /* Import */
    --color-s3: #55E6C1;
    /* Function */
    --color-s4: #FDCB6E;
    /* Table */
    --color-s5: #E17055;
    /* Memory */
    --color-s6: #A29BFE;
    /* Global */
    --color-s7: #00CEC9;
    /* Export */
    --color-s8: #81ECEC;
    /* Start */
    --color-s9: #FFEAA7;
    /* Element */
    --color-s10: #FAB1A0;
    /* Code */
    --color-s11: #DFE6E9;
    /* Data */
    --color-s0: #636E72;
    /* Custom */
}

* {
    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;
    min-height: 100vh;
    /* Glassmorphism ambient glow */
    background-image:
        radial-gradient(circle at 15% 20%, rgba(0, 206, 201, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(253, 203, 110, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.text-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 15px rgba(0, 206, 201, 0.2);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-right: auto;
}

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

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    position: relative;
}

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

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

.border-top {
    border-top: 1px solid var(--border);
    border-bottom: none;
}

/* Sidebar Info */
.sidebar-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-block {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.9rem;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Section List */
.section-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.section-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    font-size: 0.85rem;
    text-align: left;
}

.section-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.section-item.active {
    background: rgba(0, 206, 201, 0.1);
    border-color: var(--border-focus);
    color: var(--primary);
    font-weight: 500;
}

.section-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.section-item.active .section-size {
    color: var(--secondary);
}

/* Tabs Header */
.tabs-header {
    padding: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}

.tabs {
    display: flex;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 2px solid transparent;
    font-family: 'Inter', sans-serif;
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-panel);
}

/* Viewer Area */
.tab-content-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: var(--bg-panel);
}

.tab-pane {
    display: none;
    padding: 1.5rem;
    height: 100%;
    flex-direction: column;
}

.tab-pane.active {
    display: flex;
}

/* Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.summary-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
}

.summary-val {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
}

.summary-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Detail Table */
.section-detail-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-height: 300px;
}

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

.table-responsive {
    overflow: auto;
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-main);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table td.mono {
    font-family: 'JetBrains Mono', monospace;
    color: var(--secondary);
}

/* Code/WAT Viewer */
#tab-wat {
    padding: 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
}

pre {
    margin: 0;
    padding: 1.5rem;
    flex: 1;
    overflow: auto;
    background: var(--bg-input);
}

code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-main);
}

/* Super simple highlight for WAT */
.language-wat .keyword {
    color: var(--primary);
}

.language-wat .string {
    color: var(--accent);
}

.language-wat .variable {
    color: var(--secondary);
}

/* Hex Dump Viewer */
#tab-hex {
    padding: 0;
    background: var(--bg-input);
}

.hex-viewer {
    height: 100%;
    display: flex;
    flex-direction: column;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

.hex-header {
    display: flex;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 10;
}

.hex-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.hex-row {
    display: flex;
    padding: 0.1rem 0;
}

.hex-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.hex-col-offset {
    width: 80px;
    color: var(--text-muted);
    padding-right: 1rem;
    user-select: none;
}

.hex-col-bytes {
    flex: 1;
    display: flex;
    gap: 0.25rem;
}

.hex-col-ascii {
    width: 160px;
    color: var(--text-muted);
    padding-left: 1rem;
    letter-spacing: 0.1em;
    white-space: pre;
}

.hex-byte {
    width: 22px;
    text-align: center;
    border-radius: 3px;
    cursor: pointer;
}

.hex-byte.hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Dynamic section coloring for hex bytes applied via JS inline styles based on map */

/* Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.badge.info {
    background: rgba(0, 206, 201, 0.1);
    color: var(--primary);
    border: 1px solid rgba(0, 206, 201, 0.3);
}

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

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

.btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 10px rgba(0, 206, 201, 0.3);
}

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

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn.outline {
    background: transparent;
    border: 1px solid var(--border);
}

.btn.outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn.primary.outline {
    border-color: var(--primary);
    color: var(--primary);
}

.btn.primary.outline:hover {
    background: var(--primary);
    color: var(--bg-dark);
}

.btn.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    height: 32px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(0, 206, 201, 0.1);
    border-color: rgba(0, 206, 201, 0.2);
}

.icon-btn.sm {
    width: 28px;
    height: 28px;
}

/* Global Empty State */
.global-empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 100;
    text-align: center;
    padding: 2rem;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 206, 201, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.global-empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.global-empty-state p {
    color: var(--text-muted);
    max-width: 400px;
}

.hidden {
    display: none !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--success);
    color: var(--bg-dark);
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(85, 230, 193, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.toast.error {
    background: var(--error);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 118, 117, 0.3);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-panel {
        margin-bottom: 1.5rem;
        max-height: 400px;
    }

    .viewer-panel {
        min-height: 600px;
    }
}