/* ── Pi Multi-FX Pedal — Web UI Styles ──────────────────────────────
   Mobile-first, dark theme, 80-82% max-width for chat-bubble comfort.
   ─────────────────────────────────────────────────────────────────── */

/* ── Reset & Base ─────────────────────────────────────────────────── */

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

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-card: #222;
    --bg-card-hover: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --text-muted: #666;
    --accent: #4fc3f7;
    --accent-dark: #0288d1;
    --success: #66bb6a;
    --danger: #ef5350;
    --warning: #ffa726;
    --border: #333;
    --border-light: #444;
    --radius: 8px;
    --radius-sm: 4px;
    --max-width: 82%;
    --header-height: 48px;
}

html, body {
    height: 100%;
    width: 100%;
}

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

/* ── App Container ────────────────────────────────────────────────── */

.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────── */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left .logo {
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
}

.header-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-dark);
    color: white;
}

.header-right {
    display: flex;
    align-items: center;
}

.connection-indicator {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--danger);
    color: white;
    white-space: nowrap;
}

.connection-indicator.connected {
    background: var(--success);
}

/* ── Main Content ─────────────────────────────────────────────────── */

.app-main {
    flex: 1;
    padding: 12px 0;
    padding-bottom: 24px;
}

/* ── Cards ────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.card-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 14px;
}

/* ── Dashboard ────────────────────────────────────────────────────── */

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.preset-name-display {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.preset-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.preset-controls {
    display: flex;
    gap: 8px;
}

/* ── Status Row ───────────────────────────────────────────────────── */

.status-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.status-card {
    text-align: center;
}

/* ── Tuner Display ──────────────────────────────────────────── */

.tuner-display {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
}

.tuner-note {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    font-family: 'Courier New', monospace;
    line-height: 1;
    letter-spacing: 2px;
}

.tuner-cents-bar {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
    position: relative;
}

.tuner-cents-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: var(--text-muted);
    z-index: 1;
}

.tuner-cents-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--success);
    transition: width 0.1s ease;
}

.tuner-cents-text {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.tuner-string {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 4px;
    background: var(--bg-card);
}

.tuner-string-active {
    color: var(--accent) !important;
    border: 1px solid var(--accent-dark);
}

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

.status-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.btn:active {
    transform: scale(0.97);
}

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

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

.btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border);
}

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

.btn-danger:hover {
    background: #c62828;
}

.toggle-btn {
    min-width: 90px;
    font-weight: 600;
    padding: 6px 12px;
    font-size: 0.8rem;
}

.toggle-btn.active {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

/* ── Sliders ──────────────────────────────────────────────────────── */

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-card);
}

.slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-card);
}

.volume-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

/* ── FX Chain ────────────────────────────────────────────────────── */

.fx-chain {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fx-block {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    user-select: none;
    touch-action: manipulation;
}

.fx-block:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-dark);
}

.fx-block:active {
    transform: scale(0.97);
}

.fx-block.bypassed {
    opacity: 0.5;
    text-decoration: line-through;
}

.fx-block .fx-name {
    color: var(--text-primary);
}

.fx-block .fx-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--accent-dark);
    color: white;
}

.fx-block-chain-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Page layout ──────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.page-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
}

.loading {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 8px 0;
}

.hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 8px;
}

/* ── Bank / Preset List ───────────────────────────────────────────── */

.bank-section {
    margin-bottom: 12px;
}

.bank-header {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.preset-card {
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s;
}

.preset-card:hover {
    border-color: var(--accent-dark);
}

.preset-card.active {
    border-color: var(--accent);
    background: rgba(79, 195, 247, 0.1);
}

.preset-card .preset-card-name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.preset-card .preset-card-slot {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ── Model / IR List ──────────────────────────────────────────────── */

.model-list, .ir-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.model-item, .ir-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.model-item.loaded, .ir-item.loaded {
    border-color: var(--success);
}

.model-item .model-meta, .ir-item .ir-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.file-input {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ── Settings ─────────────────────────────────────────────────────── */

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: none;
}

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

.setting-value {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-value code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

.profile-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.82rem;
    outline: none;
    cursor: pointer;
}

.profile-select:focus {
    border-color: var(--accent);
}

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

.jack-check {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.about-info p {
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.about-info a {
    color: var(--accent);
}

/* ── Modal ─────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 12px;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 0.95rem;
}

.modal-body {
    padding: 14px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}

/* ── Param sliders in modal ────────────────────────────────────────── */

.param-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.param-row .param-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.param-row .param-value {
    font-size: 0.78rem;
    color: var(--text-muted);
    min-width: 36px;
    text-align: right;
}

.param-row .slider {
    flex: 1;
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    :root {
        --max-width: 82%;
    }

    .status-row {
        grid-template-columns: 1fr;
    }

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

    .header-nav {
        gap: 2px;
    }

    .nav-link {
        padding: 6px 6px;
        font-size: 0.75rem;
    }
}

@media (min-width: 768px) {
    :root {
        --max-width: 600px;
    }
}

@media (min-width: 1024px) {
    :root {
        --max-width: 720px;
    }
}

/* ── Utilities ─────────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }

/* ── Routing / 4CM ────────────────────────────────────────────────── */

.routing-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.routing-indicator {
    display: inline-flex;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-4cm {
    background: var(--warning);
    color: #1a1a1a;
}

.badge-mono {
    background: var(--text-muted);
    color: var(--text-primary);
}

.routing-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.routing-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Settings tabs ────────────────────────────────────────────────── */

.settings-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

.settings-tab {
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    touch-action: manipulation;
}

.settings-tab:hover {
    color: var(--text-primary);
}

.settings-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

/* ── Network UI ──────────────────────────────────────────────────── */

.network-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.network-status-icon {
    font-size: 1.8rem;
    width: 48px;
    text-align: center;
}

.network-status-info {
    flex: 1;
}

.network-ssid {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.network-ip {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.network-signal {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

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

.network-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.network-item-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}

.network-item-info {
    flex: 1;
    min-width: 0;
}

.network-item-ssid {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.network-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
}

.enc-open {
    color: var(--success);
}

.enc-secure {
    color: var(--warning);
}

.network-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.85rem;
    width: 100%;
    max-width: 240px;
    outline: none;
}

.network-input:focus {
    border-color: var(--accent);
}

.network-error {
    color: var(--danger);
    font-size: 0.82rem;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* ── Hotspot ──────────────────────────────────────────────────────── */

.hotspot-controls .setting-row:last-child {
    border-bottom: 1px solid var(--border);
}

.hotspot-indicator {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.hotspot-off {
    background: var(--text-muted);
    color: var(--bg-primary);
}

.hotspot-on {
    background: var(--warning);
    color: #1a1a1a;
}

.hotspot-actions {
    display: flex;
    gap: 8px;
    padding-top: 10px;
}

/* ── Bluetooth UI ────────────────────────────────────────────────── */

.bt-device-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bt-device-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.bt-device-item.bt-paired {
    border-left: 3px solid var(--text-muted);
}

.bt-device-item.bt-paired.connected {
    border-left-color: var(--success);
}

.bt-device-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.bt-device-info {
    flex: 1;
    min-width: 0;
}

.bt-device-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.bt-device-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
}

.bt-device-meta code {
    font-size: 0.68rem;
    background: var(--bg-card);
    padding: 1px 4px;
    border-radius: 3px;
}

.bt-device-actions {
    display: flex;
    gap: 4px;
}

.bt-status-connected {
    color: var(--success);
    font-weight: 500;
}

.bt-status-disconnected {
    color: var(--text-muted);
}

.signal-strong { color: var(--success); }
.signal-medium { color: var(--warning); }
.signal-weak { color: var(--text-muted); }

.bt-midi-indicator {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.bt-midi-on {
    background: var(--success);
    color: white;
}

.bt-midi-warn {
    background: var(--warning);
    color: #1a1a1a;
}

.bt-midi-off {
    background: var(--text-muted);
    color: var(--bg-primary);
}

.bt-midi-actions {
    display: flex;
    gap: 8px;
    padding: 8px 0;
}

.bt-midi-device {
    font-size: 0.82rem;
    padding: 2px 0;
}

.bt-midi-device code {
    font-size: 0.72rem;
}

/* ── Tone3000 Downloader ──────────────────────────────────────────── */

.badge-tone3000 {
    background: linear-gradient(135deg, #0000FF, #FF0000);
    color: white;
    font-size: 0.65rem;
    vertical-align: middle;
    margin-left: 6px;
}

.tonedownload-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.tonedownload-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.tonedownload-input::placeholder {
    color: var(--text-muted);
}

.tonedownload-offline {
    padding: 10px;
    background: rgba(255, 167, 38, 0.1);
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    color: var(--warning);
    font-size: 0.82rem;
    margin-bottom: 10px;
}

.tonedownload-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tonedownload-card {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    align-items: center;
}

.tonedownload-card.installed {
    border-color: var(--success);
    opacity: 0.8;
}

.tonedownload-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
}

.tonedownload-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.tonedownload-card-body {
    flex: 1;
    min-width: 0;
}

.tonedownload-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tonedownload-card-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.tonedownload-card-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tonedownload-card-actions {
    flex-shrink: 0;
}

.tonedownload-install-btn {
    padding: 4px 12px;
    font-size: 0.78rem;
}

.tonedownload-installed-badge {
    display: inline-block;
    color: var(--success);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}