:root {
    --bg-dark: #07090e;
    --bg-card: rgba(16, 21, 34, 0.75);
    --bg-card-border: rgba(0, 240, 255, 0.15);
    --primary: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.35);
    --accent: #ff007b;
    --accent-glow: rgba(255, 0, 123, 0.35);
    --text-main: #f0f4fc;
    --text-muted: #8e9bb4;
    --success: #00ff88;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 0, 123, 0.05) 0%, transparent 40%);
}

/* Header & Navigation */
header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--bg-card-border);
    backdrop-filter: blur(12px);
    background: rgba(7, 9, 14, 0.85);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(90deg, #ffffff, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.offline-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    background: rgba(0, 255, 136, 0.1);
    color: var(--success);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.offline-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    background: rgba(16, 21, 34, 0.6);
    padding: 0.35rem;
    border-radius: 12px;
    border: 1px solid var(--bg-card-border);
    margin: 1.25rem 1.5rem 0;
    gap: 0.35rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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

/* Main Container */
main {
    flex: 1;
    padding: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Containers */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    margin-bottom: 1.5rem;
}

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

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Dropzone */
.dropzone {
    border: 2px dashed rgba(0, 240, 255, 0.3);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    background: rgba(0, 240, 255, 0.02);
    transition: all 0.25s ease;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(0, 240, 255, 0.08);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    fill: var(--primary);
    opacity: 0.8;
}

.dropzone-text {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

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

/* Transmission Screen */
.screen-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.canvas-container {
    position: relative;
    background: #050811;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--bg-card-border);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    width: 100%;
    max-width: 460px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qrCanvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

/* HUD & Metrics Grid */
.hud-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-top: 1.25rem;
    width: 100%;
}

.hud-item {
    background: rgba(7, 10, 18, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 0.75rem;
}

.hud-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.hud-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}

/* Sliders & Controls */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.control-label {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

.control-input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.segmented-control {
    display: flex;
    background: rgba(7, 10, 18, 0.8);
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    padding: 2px;
}

.segmented-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.segmented-btn.active {
    background: var(--primary);
    color: #050811;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Action Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    transition: all 0.25s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #00a2ff);
    color: #050811;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.6);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

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

.btn-danger {
    background: rgba(255, 0, 123, 0.15);
    color: #ff007b;
    border: 1px solid rgba(255, 0, 123, 0.4);
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Receiver Camera Viewport */
.camera-wrapper {
    position: relative;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    border: 2px solid var(--bg-card-border);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    aspect-ratio: 4 / 3;
}

#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#cameraOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.camera-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.icon-btn {
    background: rgba(7, 9, 14, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}

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

/* Progress Matrix */
.progress-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    box-shadow: 0 0 12px var(--primary-glow);
    transition: width 0.15s ease-out;
}

.chunk-matrix {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-height: 100px;
    overflow-y: auto;
    padding: 0.5rem;
    background: rgba(5, 8, 17, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chunk-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.1s ease;
}

.chunk-dot.solved {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}

/* Result Modal / Download Box */
.received-file-box {
    background: rgba(0, 255, 136, 0.08);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1.25rem;
    display: none;
    animation: fadeIn 0.3s ease;
}

.received-file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.file-name {
    font-weight: 700;
    font-size: 1.05rem;
}

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

/* Mobile Responsive */
@media (max-width: 600px) {
    header { padding: 0.75rem 1rem; }
    .tabs-nav { margin: 1rem 1rem 0; }
    main { padding: 1rem; }
    .card { padding: 1rem; }
    .hud-grid { grid-template-columns: 1fr 1fr; }
}
