:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --danger: #f43f5e;
    --bit-0-bg: #334155;
    --bit-1-bg: var(--primary);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 2rem;
    line-height: 1.5;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #818cf8, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 0; 
    color: #e2e8f0;
    font-weight: 600;
    border-left: 4px solid var(--primary);
    padding-left: 0.75rem;
    text-align: left !important;
}

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

.badge-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mapping-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    background: rgba(79, 70, 229, 0.15);
    color: #818cf8;
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.policy-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Config Grid */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

select {
    background: #1e293b;
    border: 1px solid var(--card-border);
    color: white;
    padding: 0.6rem;
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

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

/* Binary Input */
.input-panel {
    text-align: center;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.binary-display {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem; /* Reduced to pull hex/dec display closer */
    flex-wrap: wrap;
}

.bit {
    width: 36px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bit-0-bg);
    border-radius: 0.4rem;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    font-size: 1.25rem;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.bit:hover {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.2);
}

.bit[data-value="1"] {
    background: var(--bit-1-bg);
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.4);
}

.address-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem; /* Slightly smaller */
    margin-bottom: 0.75rem; /* Significant reduction */
    background: rgba(255, 255, 255, 0.03);
    padding: 0.4rem;
    border-radius: 0.5rem;
    display: inline-block;
}

.address-info span {
    margin: 0 1rem;
    color: var(--text-muted);
}

#hex-address {
    color: #fbbf24;
    font-weight: bold;
}

/* Button Group */
.button-group {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--card-border);
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* Row Highlighting */
/* Row Highlighting & Animations */
@keyframes breathe {
    0% { background: rgba(79, 70, 229, 0.05); }
    50% { background: rgba(79, 70, 229, 0.2); }
    100% { background: rgba(79, 70, 229, 0.05); }
}

@keyframes flash-green {
    0% { background: rgba(16, 185, 129, 0.4); }
    100% { background: transparent; }
}

@keyframes flash-red {
    0% { background: rgba(244, 63, 94, 0.4); }
    100% { background: transparent; }
}

.highlight-row {
    animation: breathe 3s infinite ease-in-out;
}

.row-loaded {
    animation: flash-green 3.5s ease-out;
}

.row-replaced {
    animation: flash-red 3.5s ease-out;
}

/* Aligned Address Layout */
.bit-group {
    display: flex;
    gap: 2px;
    padding: 12px 6px 6px 6px; /* Space for label at top */
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    position: relative;
    transition: all 0.3s ease;
    justify-content: center;
}

.bit-group-header {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    z-index: 10;
}

.bit-group::after {
    display: none;
}

.bit-group.tag-group { border-color: rgba(99, 102, 241, 0.4); }
.bit-group.index-group { border-color: rgba(139, 92, 246, 0.4); }
.bit-group.offset-group { border-color: rgba(236, 72, 153, 0.4); }

.tag-bg { background: #6366f1; color: white; }
.index-bg { background: #8b5cf6; color: white; }
.offset-bg { background: #ec4899; color: white; }

/* Table Column Spacing */
th, td {
    padding: 1rem 1rem;
}

.col-dec {
    padding-right: 0.5rem !important;
    text-align: right !important;
    font-size: 0.85rem;
}

.col-bin {
    padding-left: 0.5rem !important;
    text-align: left !important;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #cbd5e1;
}

.bin-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #818cf8;
    font-weight: 600;
}

.col-policy {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

/* Table styling */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

th {
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--card-border);
    text-align: center;
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-family: 'JetBrains Mono', monospace;
    text-align: center; /* Center align by default */
}

tr:hover {
    background: rgba(255,255,255,0.02);
}

.status-container {
    min-height: 42px; /* Fixed height to fit message without stretching */
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-message {
    padding: 0.5rem 1.5rem; /* Reduced padding to fit fixed height container */
    border-radius: 0.5rem;
    font-size: 0.875rem;
    display: none;
    width: 100%;
    box-sizing: border-box;
}

.status-message.conflict {
    display: block;
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.status-message.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Legend colors for table */
.tag-text { color: #818cf8; }
.index-text { color: #a78bfa; }
.offset-text { color: #f472b6; }
.valid-text { color: var(--accent); }
