@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@200..800&display=swap');

:root {
    --bg-primary: #222222;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --accent: #ffae00;
    --border-light: #333333;
    --border-dark: #111111;
    --ui-control-font-size: 16px;
    --ui-control-font-weight: 700;
    --sidebar-width: 320px;
    --sidebar-peek-width: 0px;
    --top-header-height: 74px;
    --sidebar-top-offset: 8px;
}

* {
    box-sizing: border-box;
    font-family: "Oxanium", sans-serif;
    font-optical-sizing: auto;
    font-style: normal;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    touch-action: pan-x pan-y;
    overscroll-behavior: none;
    min-height: 100dvh;
    overflow-x: hidden;
    padding-top: var(--top-header-height);
}

html {
    touch-action: pan-x pan-y;
}

.container {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
}

.app-top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-header-height);
    background: linear-gradient(180deg, #101010 0%, #161616 100%);
    border-bottom: 2px solid var(--border-dark);
    z-index: 980;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    padding: 0.3rem 0.7rem;
}

.service-chip-row {
    display: flex;
    align-items: stretch;
    gap: 0.34rem;
    flex-wrap: nowrap;
}

.service-status-row {
    width: max-content;
    max-width: 100%;
}

.service-status-btn {
    width: 3.2rem;
    min-width: 3.2rem;
    height: 3.2rem;
    padding: 0.22rem 0.2rem;
    border-radius: 0.58rem;
    border: 2px solid var(--border-light);
    background: var(--bg-secondary);
    color: #ff5f5f;
    display: grid;
    grid-template-rows: 1fr auto auto;
    align-items: center;
    justify-items: center;
    gap: 0.05rem;
    cursor: default;
    user-select: none;
    touch-action: none;
}

.service-status-btn:hover,
.service-status-btn:focus-visible {
    background: var(--bg-secondary);
    color: inherit;
    border-color: currentColor;
    outline: none;
}

.service-status-btn.connected {
    color: #ffae00;
    border-color: #ffae00;
    box-shadow: inset 0 0 0 1px rgba(255, 174, 0, 0.2);
}

.service-status-btn.disconnected {
    color: #ff5f5f;
    border-color: #a13a3a;
}

.service-status-icon {
    width: 1.02rem;
    height: 1.02rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.service-status-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.service-status-label {
    font-size: 0.54rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.service-status-value {
    font-size: 0.5rem;
    line-height: 1;
    letter-spacing: 0.04em;
    opacity: 0.92;
}

.sidebar-swipe-zone {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(52vw, 360px);
    height: 100%;
    pointer-events: auto;
    touch-action: pan-y;
}

.app-shell {
    min-height: calc(100dvh - var(--top-header-height));
}

.app-sidebar {
    position: fixed;
    inset: calc(var(--top-header-height) + var(--sidebar-top-offset)) auto 0 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #171717 0%, #121212 100%);
    border-right: 2px solid var(--border-dark);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.26s ease;
    will-change: transform;
}

.sidebar-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    min-height: 2.4rem;
    padding: 0.35rem;
    border-bottom: 2px solid var(--border-dark);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    aspect-ratio: 1 / 1;
    height: 100%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-radius: unset;
    border: unset;
    background: unset!important;
}

.sidebar-toggle-icon {
    width: 1rem;
    height: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-content {
    padding: 0.7rem;
    display: flex;
    flex-flow: column;
    gap: 0.65rem;
    overflow-y: auto;
    transition: opacity 0.16s ease, visibility 0.16s ease;
}

.sidebar-section {
    border: 2px solid var(--border-light);
    border-radius: 0.6rem;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.sidebar-section > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    padding: 0.6rem 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid transparent;
}

.sidebar-section > summary::-webkit-details-marker {
    display: none;
}

.sidebar-section[open] > summary {
    color: var(--accent);
    border-bottom-color: var(--border-light);
}

.sidebar-section > :not(summary) {
    padding: 0.65rem;
}

.sidebar-action-stack {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.app-sidebar .metrics-bar {
    flex-direction: column;
    margin: 0;
    border: 0;
    background: transparent;
    gap: 0.45rem;
    align-items: stretch;
}

.app-sidebar .metric {
    min-width: 0;
    width: 100%;
}

.app-sidebar .metric-meta {
    white-space: normal;
}

.app-sidebar nav {
    width: 100%;
    gap: 0;
}

.app-sidebar .nav-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
}

.app-sidebar .nav-link,
.app-sidebar .nav-button {
    width: 100%;
    text-align: left;  
    flex-flow: row-reverse;
  justify-content: space-between;
}

.app-sidebar .controls-menu-panel {
    padding: 0.5rem;
}

.app-sidebar .controls-menu-stack {
    flex-direction: column;
    gap: 0.4rem;
}

.app-sidebar .controls-menu-option {
    min-width: 0;
    width: 100%;
    text-align: left;
}

.app-main {
    margin-left: var(--sidebar-width);
    min-height: calc(100dvh - var(--top-header-height));
    transition: margin-left 0.26s ease;
}

body.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .sidebar-header {
    justify-content: flex-end;
    padding: 0.35rem 0.35rem;
}

body.sidebar-collapsed .sidebar-content {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

body.sidebar-collapsed .app-main {
    margin-left: 0;
}

.sidebar-scrim {
    position: fixed;
    inset: calc(var(--top-header-height) + var(--sidebar-top-offset)) 0 0 0;
    z-index: 850;
    background: rgba(0, 0, 0, 0.38);
    display: none;
}

/* SPA views */
.view {
    display: none;
}

.view.active {
    display: block;
    background: linear-gradient(180deg, rgba(255, 174, 0, 0.05) 0%, rgba(0, 0, 0, 0.1) 100%);
    border: 2px solid var(--border-dark);
    border-radius: 0.6rem;
    padding: 0.9rem;
}

.hybrid-tabs,
.debug-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.hybrid-tab,
.debug-tab {
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.42rem 0.75rem;
    border-radius: 0.45rem;
    font-weight: 700;
    cursor: pointer;
}

.hybrid-tab.active,
.debug-tab.active {
    border-color: var(--accent);
    background: rgba(255, 174, 0, 0.16);
    color: var(--accent);
}

.hybrid-tab-panel,
.debug-control-panel {
    display: none;
}

.hybrid-tab-panel.active,
.debug-control-panel.active {
    display: block;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    position: relative;
}

.modal-header {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.modal-close-btn {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    padding: 0;
    border-radius: 999px;
    line-height: 1;
    text-transform: uppercase;
}

.modal-section {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-dark);
    border-radius: 0.5rem;
    display:flex;
    flex-flow:column;
    gap:0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.service-auth-modal {
    z-index: 1250;
}

.service-auth-modal-content {
    max-width: 420px;
    padding: 1.5rem;
}

.service-auth-title {
    margin: 0;
    font-weight: 700;
    line-height: 1.35;
}

.service-auth-endpoint {
    display: block;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border-radius: 0.4rem;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    font-size: 0.76rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.service-auth-queue {
    margin: 0;
    font-size: 0.78rem;
    opacity: 0.78;
}

.service-auth-error {
    min-height: 1.1rem;
    margin: 0;
    color: #ff6666;
    font-size: 0.8rem;
}

.nkn-identity-grid {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.65rem;
}

.nkn-identity-meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nkn-meta-label {
    font-size: 0.68rem;
    opacity: 0.72;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nkn-meta-value {
    font-size: 0.86rem;
    color: var(--accent);
}

.nkn-code {
    display: block;
    font-size: 0.74rem;
    line-height: 1.35;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 0.4rem;
    padding: 0.4rem 0.5rem;
    word-break: break-all;
    white-space: pre-wrap;
}

.nkn-qr {
    width: 120px;
    height: 120px;
    padding: 0.25rem;
    border: 1px solid var(--border-light);
    border-radius: 0.4rem;
    background: #fff;
    justify-self: end;
}

.nkn-qr img,
.nkn-qr canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.nkn-scan-panel {
    margin-top: 0.4rem;
    padding: 0.55rem;
    border: 1px solid var(--border-light);
    border-radius: 0.45rem;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.nkn-scan-video {
    width: 100%;
    max-height: 260px;
    border: 1px solid var(--border-light);
    border-radius: 0.35rem;
    background: #000;
    object-fit: cover;
}

.nkn-scan-status {
    font-size: 0.82rem;
    opacity: 0.86;
}

/* Metrics Display */
.metrics-bar {
    display: flex;
    gap: 0.6rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-dark);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 170px;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border-light);
    border-radius: 0.45rem;
    background: var(--bg-secondary);
}

.metric-label {
    font-size: 0.68rem;
    opacity: 0.72;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    font-weight: bold;
    color: var(--accent);
    line-height: 1.1;
}

.metric-meta {
    font-size: 0.72rem;
    opacity: 0.78;
    white-space: nowrap;
}

.metric-value.good {
    color: #00ff88;
}

.metric-value.warning {
    color: #ffae00;
}

.metric-value.error {
    color: #ff4444;
}

/* Navigation styling */
nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
}

.nav-container {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    border: 2px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: var(--ui-control-font-size);
    font-weight: var(--ui-control-font-weight);
}

.nav-link:hover,
.nav-link.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.controls-nav {
    width: 100%;
    align-items: center;
}

.controls-menu-toggle {
    background: var(--bg-secondary);
}

.controls-menu-toggle.open {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.controls-current-ghost {
    border-style: dashed;
    color: var(--accent);
    background: transparent;
    opacity: 0.85;
    cursor: default;
    pointer-events: none;
}

.controls-current-ghost.active-control {
    border-style: solid;
    opacity: 1;
}

.controls-menu-panel {
    width: 100%;
    flex-basis: 100%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 0.6rem;
}

.controls-menu-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.controls-menu-option {
    border: 2px solid var(--border-light);
    border-radius: 0.45rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.45rem 0.75rem;
    min-width: 140px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    font-size: var(--ui-control-font-size);
    font-weight: var(--ui-control-font-weight);
}

.controls-menu-option:hover,
.controls-menu-option:focus-visible,
.controls-menu-option.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    outline: none;
}

.nav-button {
    background: var(--accent);
    border: 2px solid var(--accent);
    color: var(--bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: var(--ui-control-font-weight);
    font-size: var(--ui-control-font-size);
    transition: all 0.2s;
}

.nav-button:hover {
    background: #ffcc00;
    border-color: #ffcc00;
}

.row {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
}

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

.control-section {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-dark);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    display:flex;
    flex-flow:column;
    gap:0.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.section-header h3 {
    margin: 0;
}

.streams-panel {
    border: 2px solid var(--border-dark);
    border-radius: 0.6rem;
    background: var(--bg-tertiary);
    margin-bottom: 0.55rem;
    overflow: hidden;
}

.streams-panel > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    padding: 0.75rem 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid transparent;
    background: rgba(255, 255, 255, 0.02);
}

.streams-panel > summary::-webkit-details-marker {
    display: none;
}

.streams-panel[open] > summary {
    color: var(--accent);
    border-bottom-color: var(--border-light);
    background: rgba(255, 174, 0, 0.06);
}

.streams-panel-body {
    padding: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

#audioRemotePlayer {
    width: 100%;
    border-radius: 0.45rem;
    border: 1px solid var(--border-light);
    background: #111;
}

button {
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--ui-control-font-size);
    font-weight: var(--ui-control-font-weight);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button:hover {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
    font-weight: bold;
}

button.primary:hover {
    background: #ffcc00;
    border-color: #ffcc00;
}

button:disabled {
    background: #2b2b2b;
    border-color: #4a4a4a;
    color: #9a9a9a;
    opacity: 0.55;
    cursor: not-allowed;
}

button:disabled:hover {
    background: #2b2b2b;
    border-color: #4a4a4a;
    color: #9a9a9a;
}

.toggle-checkbox-btn {
    min-width: auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--ui-control-font-size);
    font-weight: var(--ui-control-font-weight);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.toggle-checkbox-btn:hover {
    border-color: var(--accent);
}

.toggle-checkbox-btn:focus-within {
    outline: 2px solid rgba(255, 174, 0, 0.5);
    outline-offset: 2px;
}

.toggle-checkbox-btn input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toggle-checkbox-btn.is-on {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 174, 0, 0.13);
}

.toggle-checkbox-btn.is-off {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.toggle-checkbox-btn-text {
    line-height: 1;
}

button.has-ui-icon,
.nav-link.has-ui-icon,
.controls-menu-option.has-ui-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
}

.controls-menu-option.has-ui-icon {
    display: flex;
}

.modal-close-btn.has-ui-icon,
.pinned-stream-close.has-ui-icon {
    justify-content: center;
}

.ui-btn-icon {
    width: 1rem;
    height: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.ui-btn-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ui-btn-label {
    line-height: 1;
}

input[type="number"],
input[type="text"],
input[type="password"],
input[type="range"],
select {
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 16px;
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="range"] {
    flex: 1;
}

label {
}

footer {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto 1rem auto;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-dark);
    padding: 0.5rem;
    font-size: 0.8rem;
    overflow-y: auto;
    max-height: 150px;
    border-radius: 0.5rem;
}

h1,
h2,
h3 {
    color: var(--accent);
}

.view h1,
.view h2 {
    margin: 0 0 0.65rem 0;
}

.current-command {
    color: var(--accent);
}

/* Headstream extras */
#morphCanvasWrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    pointer-events: none;
}

#morphCanvasWrap canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent !important;
}

.stream-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.stream-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
}

.stream-label {
    font-size: 0.75rem;
    opacity: 0.75;
    margin-bottom: 0.35rem;
}

.stream-value {
    color: var(--accent);
    word-break: break-word;
}

.tuneables-note {
    opacity: 0.75;
    margin-top: 0;
}

.orientation-embed-wrap {
    position: relative;
    width: min(100%, 760px);
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    overflow: hidden;
    background: #050505;
    margin: 0 auto;
}

.orientation-embed-wrap iframe,
#orientationSceneHost {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
}

#orientationSceneHost canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
}

.stream-preview-wrap {
    position: relative;
    width: 100%;
    min-height: 280px;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    background: #0f0f0f;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stream-pin-btn {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    z-index: 3;
    width: 2rem;
    height: 2rem;
    padding: 0.25rem;
    border-radius: 999px;
    border: 2px solid var(--border-light);
    background: rgba(0, 0, 0, 0.72);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.stream-pin-btn svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.stream-pin-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.stream-preview-wrap img,
.stream-preview-wrap video {
    width: 100%;
    height: auto;
    max-height: 65vh;
    object-fit: contain;
    background: #000;
}

.stream-feed-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.stream-feed-row {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: 0.35rem;
    background: var(--bg-secondary);
}

.hybrid-feed-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: thin;
}

.hybrid-feed-btn {
    width: 4.25rem;
    min-width: 4.25rem;
    height: 4.25rem;
    padding: 0.28rem 0.22rem;
    border-radius: 0.58rem;
    display: grid;
    grid-template-rows: 1fr auto auto;
    justify-items: center;
    align-items: center;
    gap: 0.06rem;
    text-align: center;
}

.hybrid-feed-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.hybrid-feed-btn.offline {
    color: #ff5f5f;
    border-color: #a13a3a;
    opacity: 0.92;
}

.hybrid-feed-btn-icon {
    width: 1.05rem;
    height: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hybrid-feed-btn-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hybrid-feed-btn-label {
    font-size: 0.58rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hybrid-feed-btn-meta {
    font-size: 0.52rem;
    line-height: 1;
    opacity: 0.86;
    letter-spacing: 0.03em;
}

.hybrid-feed-note {
    padding: 0.42rem 0.55rem;
    border: 1px solid var(--border-light);
    border-radius: 0.45rem;
    background: var(--bg-secondary);
    font-size: 0.8rem;
    line-height: 1.25;
    opacity: 0.86;
}

.hybrid-home-soft-btn {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hybrid-home-soft-btn .ui-btn-icon {
    width: 1.05rem;
    height: 1.05rem;
}

.hybrid-preview-layout {
    --hybrid-preview-max-height: 100dvh;
    width: 100%;
    max-height: var(--hybrid-preview-max-height);
    display: flex;
    align-items: stretch;
    gap: 0.7rem;
}

.hybrid-preview-wrap {
    --hybrid-stream-aspect: 16 / 9;
    position: relative;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    aspect-ratio: var(--hybrid-stream-aspect);
    min-height: 280px;
    max-height: var(--hybrid-preview-max-height);
    border: 2px solid var(--border-light);
    border-radius: 0.6rem;
    overflow: hidden;
    background: #080808;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hybrid-mode-action-mount {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.1rem;
}

.hybrid-mode-toggle {
    display: none;
}

.hybrid-mode-toggle.active {
    display: inline-flex;
}

.hybrid-mode-status {
    margin: 0.4rem 0 0 0;
    min-height: 1.1rem;
    font-size: 0.82rem;
    opacity: 0.85;
}

.hybrid-mode-overlay {
    position: absolute;
    inset: 0;
    display: none;
}

.hybrid-mode-overlay.active {
    display: block;
}

.hybrid-touch-overlay {
    z-index: 4;
}

.hybrid-touch-hud-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.hybrid-touch-hud-layer canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.hybrid-scene-overlay {
    z-index: 2;
    background: transparent;
}

#hybridTabTouch[data-hybrid-mode]:not([data-hybrid-mode="touch"]) .hybrid-touch-control {
    display: none !important;
}

.hybrid-preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.hybrid-preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: rgba(255, 255, 255, 0.82);
    background: radial-gradient(circle at center, rgba(255, 174, 0, 0.08), rgba(0, 0, 0, 0.72));
    padding: 1rem;
    font-size: 0.95rem;
    z-index: 1;
}

.hybrid-drag-surface {
    position: absolute;
    inset: 0;
    border-radius: 0.65rem;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: rgba(8, 8, 8, 0.08);
    cursor: grab;
    user-select: none;
    touch-action: none;
    z-index: 2;
}

.hybrid-drag-surface.dragging {
    cursor: grabbing;
    border-color: rgba(255, 174, 0, 0.85);
    background: rgba(255, 174, 0, 0.08);
}

.hybrid-arrow {
    position: absolute;
    width: 2.65rem;
    height: 2.65rem;
    min-width: 2.65rem;
    padding: 0;
    border-radius: 999px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.38);
    background: rgba(0, 0, 0, 0.33);
    color: rgba(255, 255, 255, 0.95);
    opacity: 0.42;
    backdrop-filter: blur(2px);
}

.hybrid-arrow-icon {
    width: 1rem;
    height: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: rotate(0deg);
}

.hybrid-arrow-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hybrid-arrow-icon path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.35;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hybrid-tuneables-dock {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.6rem;
}

.hybrid-tuneables-panel {
    display: none;
    border: 2px solid var(--border-dark);
    border-radius: 0.55rem;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.hybrid-tuneables-panel.active {
    display: block;
}

.hybrid-tuneables-panel > summary {
    cursor: pointer;
    padding: 0.55rem 0.7rem;
    font-weight: 700;
    color: var(--accent);
    list-style: none;
    background: rgba(255, 174, 0, 0.07);
    border-bottom: 1px solid transparent;
}

.hybrid-tuneables-panel > summary::-webkit-details-marker {
    display: none;
}

.hybrid-tuneables-panel[open] > summary {
    border-bottom-color: var(--border-dark);
}

.hybrid-tuneables-body {
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.hybrid-tuneables-body .control-section {
    margin: 0;
    background: transparent;
    border: 0;
    padding: 0;
    border-radius: 0;
}

.hybrid-tuneables-body .control-section h3 {
    margin-top: 0;
}

.hybrid-arrow:hover,
.hybrid-arrow:focus-visible,
.hybrid-arrow.active {
    opacity: 1;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.86);
    color: var(--accent);
}

.hybrid-arrow-up {
    top: 0.6rem;
    left: 50%;
    transform: translateX(-50%);
}

.hybrid-arrow-up .hybrid-arrow-icon {
    transform: rotate(-90deg);
}

.hybrid-arrow-right {
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
}

.hybrid-arrow-right .hybrid-arrow-icon {
    transform: rotate(0deg);
}

.hybrid-arrow-down {
    bottom: 0.6rem;
    left: 50%;
    transform: translateX(-50%);
}

.hybrid-arrow-down .hybrid-arrow-icon {
    transform: rotate(90deg);
}

.hybrid-arrow-left {
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
}

.hybrid-arrow-left .hybrid-arrow-icon {
    transform: rotate(180deg);
}

.hybrid-height-control {
    width: clamp(2.5rem, 4.4vw, 3.1rem);
    border: 2px solid var(--border-light);
    border-radius: 0.6rem;
    background: var(--bg-secondary);
    padding: 0.35rem 0.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
}

.hybrid-height-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.82;
}

.hybrid-height-slider {
    -webkit-appearance: slider-vertical;
    appearance: auto;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 1rem;
    min-height: 220px;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    flex: 1 1 auto;
}

.hybrid-height-value {
    min-height: 1rem;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--accent);
}

.hybrid-control-readout {
    margin: 0.45rem 0 0 0;
    color: var(--accent);
    font-size: 0.9rem;
    word-break: break-word;
}

.hybrid-control-hint {
    margin: 0;
    font-size: 0.82rem;
    opacity: 0.8;
    line-height: 1.35;
}

.imu-readout-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.imu-readout-item {
    border: 1px solid var(--border-light);
    border-radius: 0.45rem;
    background: var(--bg-secondary);
    padding: 0.5rem;
    min-height: 58px;
}

.imu-readout-label {
    font-size: 0.7rem;
    opacity: 0.72;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.imu-readout-value {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.78rem;
    line-height: 1.2;
    color: var(--accent);
    word-break: break-word;
}

.imu-readout-meta {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.82;
}

.pinned-stream-pane {
    position: fixed;
    left: 1rem;
    top: 5rem;
    width: 300px;
    height: 168px;
    display: none;
    z-index: 1300;
    border: 2px solid var(--border-light);
    border-radius: 0.6rem;
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.5);
    background: #000;
    overflow: visible;
    cursor: move;
    touch-action: none;
}

.pinned-stream-pane.active {
    display: block;
}

.pinned-stream-pane img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: calc(0.6rem - 2px);
    pointer-events: none;
}

.pinned-stream-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid #666;
    background: rgba(10, 10, 10, 0.8);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
}

.pinned-stream-pane:hover .pinned-stream-close,
.pinned-stream-close:focus-visible {
    opacity: 1;
    pointer-events: auto;
}

.pinned-stream-resize {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 22px;
    height: 22px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    border-bottom-right-radius: 14px;
    cursor: nwse-resize;
}

@media (max-width: 900px) {
    :root {
        --top-header-height: 78px;
        --sidebar-top-offset: 10px;
    }

    .app-sidebar {
        width: min(86vw, 340px);
        transform: translateX(0);
        box-shadow: 12px 0 24px rgba(0, 0, 0, 0.5);
    }

    body.sidebar-collapsed .app-sidebar {
        transform: translateX(-100%);
    }

    .app-main,
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    body.sidebar-collapsed .sidebar-header {
        justify-content: flex-end;
        padding: 0.35rem 0.35rem;
    }

    body.sidebar-mobile-open .sidebar-scrim {
        display: block;
    }

    .container {
        width: calc(100% - 1rem);
        padding: 0.5rem 0;
    }

    footer {
        width: calc(100% - 1rem);
    }

    .metrics-bar {
        flex-wrap: wrap;
    }

    .row {
        flex-wrap: wrap;
    }

    label {
        min-width: 100%;
    }

    #morphCanvasWrap {
        height: 100%;
    }

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

    .stream-preview-wrap {
        min-height: 220px;
    }

    .hybrid-preview-wrap {
        min-height: 220px;
    }

    .hybrid-preview-layout {
        gap: 0.5rem;
    }

    .hybrid-height-control {
        width: 2.35rem;
    }

    .hybrid-height-slider {
        min-height: 180px;
    }

    .hybrid-drag-surface {
        inset: 0;
    }

    .hybrid-arrow {
        width: 2.25rem;
        height: 2.25rem;
        min-width: 2.25rem;
    }

    .hybrid-arrow-icon {
        width: 0.9rem;
        height: 0.9rem;
    }

    .imu-readout-grid {
        grid-template-columns: 1fr;
    }

    .pinned-stream-pane {
        width: 220px;
        height: 132px;
    }

    .nkn-identity-grid {
        grid-template-columns: 1fr;
    }

    .nkn-qr {
        justify-self: start;
    }

    .nkn-scan-video {
        max-height: 200px;
    }

    .controls-menu-option {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
    }
}
