/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1a2744;
    --bg-input: #0f0f1a;

    --accent-primary: #4f46e5;
    --accent-primary-hover: #6366f1;
    --accent-secondary: #06b6d4;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.3);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== App Container ===== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.select-compact {
    padding: 8px 12px;
    min-width: 90px;
}

.select-memory {
    padding: 8px 12px;
    min-width: 160px;
    max-width: 200px;
}

.btn-icon-only {
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
}

.btn-icon-only:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-icon-only svg {
    width: 18px;
    height: 18px;
}

/* Small icon-only buttons */
.btn.btn-sm.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-danger);
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: var(--accent-success);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Main Content Grid ===== */
.main-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.card-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

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

.card-body {
    padding: 20px;
}

/* ===== Badge ===== */
.badge {
    padding: 4px 10px;
    background: var(--accent-primary);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* ===== Connection Card ===== */
.connection-controls {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hint-text {
    margin-top: 12px;
    font-size: 0.813rem;
    color: var(--text-muted);
}

/* ===== Inputs ===== */
.select-input,
.text-input {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select-input:focus,
.text-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.select-input option {
    background: var(--bg-secondary);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.btn-connect {
    min-width: 120px;
}

.btn-connect.connected {
    background: var(--accent-success);
}

.btn-connect.connected:hover:not(:disabled) {
    background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-warning {
    background: var(--accent-warning);
    color: #000;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

/* Unsync Indicator */
.unsync-indicator {
    animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

/* Sync Modal */
.modal-header-warning {
    background: linear-gradient(135deg, #78350f, #92400e);
}

.modal-warning-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-warning);
}

.sync-message {
    font-size: 0.938rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.sync-hint {
    font-size: 0.813rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ===== Frequency Display ===== */
.frequency-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.direct-tune-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0 20px;
}

.freq-input {
    width: 160px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

.tune-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 120px;
}

.tune-status.tuning {
    color: var(--accent-warning);
}

.tune-status.success {
    color: var(--accent-success);
}

.tune-status.error {
    color: var(--accent-danger);
}

.tuning-buttons-vertical {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-tune-sm {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
}

.btn-tune-sm:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-tune-sm svg {
    width: 20px;
    height: 20px;
}

.btn-encoder-sm {
    width: 44px;
    height: 44px;
    padding: 0;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    color: white;
    border-radius: 50%;
}

.btn-encoder-sm:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.btn-encoder-sm svg {
    width: 22px;
    height: 22px;
}

.frequency-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    padding: 24px 32px;
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.frequency-value {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
    text-shadow: 0 0 20px rgba(6, 182, 212, 0.5);
}

.frequency-unit {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Status Grid ===== */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    text-align: center;
}

.status-label {
    font-size: 0.688rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-value {
    font-family: var(--font-mono);
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Signal Meters ===== */
.signal-meters {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meter {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.meter-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.meter-value {
    font-family: var(--font-mono);
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--text-primary);
}

.meter-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-normal);
    width: 0%;
}

.rssi-fill {
    background: linear-gradient(90deg, var(--accent-success), var(--accent-warning), var(--accent-danger));
}

.snr-fill {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.battery-fill {
    background: var(--accent-success);
}

.battery-fill.low {
    background: var(--accent-warning);
}

.battery-fill.critical {
    background: var(--accent-danger);
}

/* ===== Control Rows ===== */
.control-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-ctrl-arrow {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.btn-ctrl-arrow:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-ctrl-arrow svg {
    width: 16px;
    height: 16px;
}

.control-label-box {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    min-height: 32px;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-value {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

/* ===== Control Dropdowns (after discovery) ===== */
.control-row-dropdown {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-dropdown-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 80px;
}

.control-select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-select:hover:not(:disabled) {
    border-color: var(--accent-primary);
}

.control-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.control-select:disabled {
    opacity: 0.6;
    cursor: wait;
}

.control-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ===== Discovery Modal ===== */
.discovery-status {
    font-size: 1rem;
    font-weight: 500;
    color: var(--accent-secondary);
    margin-bottom: 16px;
}

.discovery-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.discovery-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
}

.discovery-label {
    font-size: 0.875rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.discovery-count {
    font-family: var(--font-mono);
    font-size: 0.813rem;
    color: var(--accent-success);
}

.discovery-hint {
    font-size: 0.813rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Full Discovery Progress */
.discovery-full-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.discovery-progress-bar {
    height: 24px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.discovery-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.3s ease;
}

.discovery-progress-text {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.discovery-progress-log {
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.discovery-log-item {
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-secondary);
}

.discovery-log-item.discovered {
    color: var(--accent-success);
}

.discovery-log-item.copied {
    color: var(--accent-secondary);
}

.discovery-log-item.skipped {
    color: var(--text-muted);
}

.discovery-abort-btn {
    margin-top: 16px;
}

/* ===== Sliders Section ===== */
.sliders-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.slider-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.slider-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.slider-value {
    font-family: var(--font-mono);
    font-size: 0.813rem;
    color: var(--text-primary);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-slider {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-slider:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-primary);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ===== Middle Card (Tuning) ===== */
.tuning-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.tuning-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.btn-tuning {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.btn-tuning:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.btn-tuning svg {
    width: 28px;
    height: 28px;
}

.btn-encoder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-encoder:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.btn-encoder svg {
    width: 24px;
    height: 24px;
}

/* ===== Tools Grid ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.btn-tool {
    flex-direction: column;
    gap: 12px;
    padding: 24px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius);
}

.btn-tool:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-tool svg {
    width: 32px;
    height: 32px;
}

.btn-tool span {
    font-size: 0.875rem;
}

.btn-tool-wide {
    flex-direction: row;
    justify-content: center;
    width: 100%;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* ===== Spectrum Analyzer ===== */
.spectrum-info {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.spectrum-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
}

#spectrumCanvas {
    width: 100%;
    height: 350px;
    display: block;
}

.spectrum-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: auto;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

/* ===== Memory Editor ===== */
.memory-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.memory-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.memory-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.memory-list-container label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
}

#memorySlotSelect {
    height: 250px;
    font-family: var(--font-mono);
    font-size: 0.813rem;
}

#memorySlotSelect option {
    padding: 6px 10px;
}

.memory-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== Memory Card ===== */
.card-header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.memory-card-body {
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.memory-slots {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.memory-slot {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.memory-slot:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.memory-slot-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 28px;
}

.memory-slot-freq {
    font-family: var(--font-mono);
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--accent-secondary);
    flex: 1;
}

.memory-slot-mode {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 2px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-right: 8px;
}

.memory-slot-edit {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.memory-slot-edit:hover {
    background: var(--accent-primary);
    color: white;
}

.memory-slot-edit svg {
    width: 14px;
    height: 14px;
}

.memory-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.memory-empty-state p {
    font-size: 0.875rem;
}

/* Add Memory Form */
.add-memory-form {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 12px;
    border: 1px dashed var(--accent-success);
}

.add-memory-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.add-memory-row .select-compact {
    min-width: 70px;
}

.add-memory-row .text-input {
    flex: 1;
    min-width: 100px;
}

.add-memory-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
}

.add-memory-buttons .btn {
    flex: 1;
}

.modal-small {
    max-width: 360px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--accent-success);
}

.toast.error {
    border-left: 4px solid var(--accent-danger);
}

.toast.warning {
    border-left: 4px solid var(--accent-warning);
}

.toast.info {
    border-left: 4px solid var(--accent-primary);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--accent-success); }
.toast.error .toast-icon { color: var(--accent-danger); }
.toast.warning .toast-icon { color: var(--accent-warning); }
.toast.info .toast-icon { color: var(--accent-primary); }

.toast-message {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .header-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .header-divider {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .status-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .memory-editor {
        grid-template-columns: 1fr;
    }

    .spectrum-info {
        flex-direction: column;
        gap: 8px;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

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

/* ===== Selection ===== */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* ===== Flash Messages ===== */
.flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.flash-message {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--accent-danger);
    color: #fca5a5;
}

.flash-success {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid var(--accent-success);
    color: #6ee7b7;
}

.flash-info {
    background: rgba(6, 182, 212, 0.2);
    border: 1px solid var(--accent-secondary);
    color: #67e8f9;
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

/* ===== Auth Pages ===== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-primary);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.auth-form label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.auth-form .form-checkbox {
    flex-direction: row;
    align-items: center;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.auth-footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

/* ===== Landing Page ===== */
.landing-container {
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 2rem;
}

.landing-hero {
    text-align: center;
    padding: 4rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.landing-logo {
    width: 80px;
    height: 80px;
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
}

.landing-hero h1 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.landing-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.landing-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 3rem auto 0;
    padding: 0 1rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

.feature-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-secondary);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== Memory Modals ===== */
.modal-medium {
    max-width: 500px;
}

.modal-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.sync-progress {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: var(--border-radius);
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/* Database Sets Section */
.db-sets-section {
    margin-bottom: 1.5rem;
}

.db-sets-section h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.save-set-form {
    display: flex;
    gap: 0.5rem;
}

.save-set-form .text-input {
    flex: 1;
}

.saved-sets-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.saved-set-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

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

.saved-set-item:hover {
    background: var(--bg-card-hover);
}

.saved-set-info {
    flex: 1;
    min-width: 0;
}

.saved-set-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.saved-set-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.saved-set-actions {
    display: flex;
    gap: 0.5rem;
}

.saved-sets-list .empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* CSV Info */
.csv-info {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.info-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.25rem 0;
}
