/* OpenUU Web (Experimental) — neutral obsidian desktop utility + PWA Window Controls Overlay */

:root {
  --bg: #09090b;
  --bg-bar: #0e0e10;
  --bg-tabs: #0c0c0e;
  --bg-canvas: #070708;
  --surface: #111113;
  --elevated: #18181b;
  --hover: #202024;
  --inset: #0b0b0d;
  --keycap: #1c1c20;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --line-faint: rgba(255, 255, 255, 0.05);
  --text: #f5f5f7;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --cta: #f4f4f5;
  --cta-text: #09090b;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --focus: rgba(255, 255, 255, 0.28);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 5px;
  --bar-h: max(44px, env(titlebar-area-height, 44px));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(255, 255, 255, 0.18);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Inline stroke icons: 1.5px rendered stroke regardless of size */
.ico {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: block;
  stroke-width: 1.5;
}

.ico * {
  vector-effect: non-scaling-stroke;
}

.ico-xs {
  width: 12px;
  height: 12px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* ==========================================================================
   Topbar (supports PWA Window Controls Overlay cleanly)
   ========================================================================== */
.topbar {
  height: var(--bar-h);
  padding-left: max(14px, env(titlebar-area-x, 14px));
  padding-right: max(10px, calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 10px));
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--line);
  user-select: none;
  app-region: drag;
  -webkit-app-region: drag;
  position: relative;
  z-index: 40;
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.topbar-left {
  flex-shrink: 0;
  gap: 10px;
}

.topbar-center {
  flex: 1 1 auto;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}

.topbar > .topbar-right {
  flex-shrink: 0;
  margin-left: auto;
}

.topbar button,
.topbar a,
.topbar select,
.topbar input {
  app-region: no-drag;
  -webkit-app-region: no-drag;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.brand-link img {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.12);
}

.ver-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ver-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.beta-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
  padding: 2px 5px 2px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.08);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.26);
  text-transform: uppercase;
}

.tb-sep {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--line);
  flex-shrink: 0;
}

/* ==========================================================================
   Buttons & Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--line-strong);
}

.btn:active:not(:disabled) {
  background: #26262b;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: transparent;
  color: var(--text);
}

.btn-ghost:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
}

.btn-secondary {
  background: var(--elevated);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-primary {
  height: 38px;
  background: var(--cta);
  border-color: #ffffff;
  color: var(--cta-text);
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: #ffffff;
  border-color: #ffffff;
}

.btn-primary:active:not(:disabled) {
  background: #e4e4e7;
}

.btn-primary:focus-visible {
  outline-offset: 2px;
}

.btn-danger {
  color: #f87171;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 6px;
  gap: 5px;
}

.btn-xs .ico {
  width: 14px;
  height: 14px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.icon-btn .ico {
  width: 14px;
  height: 14px;
}

/* Topbar buttons */
.tb-btn {
  height: 28px;
  padding: 0 8px;
}

.tb-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stateful toolbar toggles swap their glyph via `.is-on` */
.state-btn .ico-on {
  display: none;
}

.state-btn.is-on .ico-on {
  display: block;
}

.state-btn.is-on .ico-off {
  display: none;
}

.state-btn.is-on {
  color: var(--text);
}

/* Compact icon-only toolbar while a session is live */
.topbar:has(#session-top-actions:not([hidden])) .tb-compact .tb-label,
.topbar:has(#session-top-actions:not([hidden])) #btn-install-pwa .tb-label {
  display: none;
}

.topbar:has(#session-top-actions:not([hidden])) .tb-compact,
.topbar:has(#session-top-actions:not([hidden])) #btn-install-pwa {
  width: 28px;
  padding: 0;
}

#btn-install-pwa {
  color: var(--text);
  max-width: 300px;
}

.select-pill {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 28px;
  line-height: 26px;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 10l4-4 4 4M8 14l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 24px 0 9px;
  font-size: 12px;
  color: var(--text-2);
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.select-pill::picker-icon {
  display: none;
}

.select-pill:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.03);
}

.select-pill:focus-visible {
  border-color: var(--focus);
}

.select-pill option {
  background: var(--elevated);
  color: var(--text);
}

/* ==========================================================================
   Connect Hub View
   ========================================================================== */
.connect-screen {
  height: calc(100% - var(--bar-h));
  overflow-y: auto;
  padding: 48px 20px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.connect-shell {
  width: 100%;
  max-width: 840px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pwa-tip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}

.pwa-tip-text {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.pwa-tip-text .ico {
  color: var(--text);
}

.hero-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 0 2px;
}

.hero-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--elevated);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.hero-mark .ico {
  width: 18px;
  height: 18px;
}

.hero-text {
  min-width: 0;
}

.hero-head h1 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.hero-head p {
  margin: 0;
  max-width: 640px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-3);
}

.connect-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.connect-card {
  padding: 22px 22px 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 24px 48px -24px rgba(0, 0, 0, 0.7);
}

/* macOS segmented control */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  background: var(--inset);
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 20px;
}

.tab-btn {
  min-width: 0;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  padding: 0 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.tab-btn:hover:not(.active) {
  color: var(--text-2);
}

.tab-btn.active {
  background: #232327;
  border-color: rgba(255, 255, 255, 0.09);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.field input,
.field textarea {
  width: 100%;
  height: 36px;
  background: var(--inset);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.field textarea {
  height: auto;
  min-height: 76px;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  word-break: break-all;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-3);
  opacity: 1;
}

.field textarea::placeholder {
  font-family: var(--font);
  font-size: 13px;
}

.field input:hover,
.field textarea:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(255, 255, 255, 0.32);
  background: #0d0d0f;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.field input.code-input {
  height: 52px;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0 12px;
}

.field input.code-input::placeholder {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
}

.field-hint {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
}

.connect-submit {
  width: 100%;
  margin-top: 4px;
  font-size: 13.5px;
}

.status-banner {
  position: relative;
  margin-top: 12px;
  padding: 9px 12px 9px 32px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  background: var(--inset);
  border: 1px solid var(--line);
  color: var(--text-2);
}

.status-banner::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 11px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--text);
  animation: ou-spin 0.8s linear infinite;
}

.status-banner.error {
  background: rgba(239, 68, 68, 0.07);
  border-color: rgba(239, 68, 68, 0.26);
  color: #fca5a5;
}

.status-banner.error::before {
  top: 14px;
  left: 14px;
  width: 6px;
  height: 6px;
  border: none;
  background: var(--red);
  animation: none;
}

@keyframes ou-spin {
  to {
    transform: rotate(360deg);
  }
}

.advanced-box {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.advanced-box summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  user-select: none;
  list-style: none;
  border-radius: 5px;
  width: fit-content;
  max-width: 100%;
  transition: color 0.12s ease;
}

.advanced-box summary::-webkit-details-marker {
  display: none;
}

.advanced-box summary:hover {
  color: var(--text-2);
}

.summary-chevron {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.advanced-box[open] .summary-chevron {
  transform: rotate(90deg);
}

.advanced-box[open] summary {
  color: var(--text-2);
  margin-bottom: 14px;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  padding: 14px 14px 0;
  border: 1px solid var(--line-faint);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
}

.advanced-grid .full {
  grid-column: 1 / -1;
}

.advanced-grid input {
  font-family: var(--mono);
  font-size: 12px;
}

.advanced-grid input::placeholder {
  font-family: var(--mono);
}

/* Side column */
.side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.side-card {
  padding: 14px;
}

.card-title {
  margin: 0 0 10px;
  padding: 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-list .hint-box {
  margin: 0;
  padding: 14px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 12px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 6px 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.recent-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.recent-glyph {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text-2);
}

.recent-glyph .ico {
  width: 14px;
  height: 14px;
}

.recent-meta {
  flex: 1;
  min-width: 0;
}

.recent-name {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-sub {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-3);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-remove {
  opacity: 0;
}

.recent-item:hover .recent-remove,
.recent-remove:focus-visible {
  opacity: 1;
}

.recent-remove:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

.hint-box {
  margin: 0;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}

.cap-pill {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-2);
  background: var(--inset);
  border: 1px solid var(--line);
}

.cap-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.cap-pill.warn {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.22);
}

.cap-pill.warn::before {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

/* ==========================================================================
   Connected Workbench View
   ========================================================================== */
.workbench {
  height: calc(100% - var(--bar-h));
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.sidebar-head {
  height: 36px;
  flex-shrink: 0;
  padding: 0 8px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-3);
}

.app-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.app-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 4px 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.1s ease, color 0.1s ease;
}

.app-row:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.app-row.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.app-row.active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--text);
}

/* First row = Full Remote Desktop; separate it from apps with a hairline */
.app-list > .app-row:first-child {
  margin-bottom: 5px;
}

.app-list > .app-row:first-child::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -3px;
  height: 1px;
  background: var(--line);
}

.app-row.opened .app-name::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 7px;
  vertical-align: 1px;
}

.app-row.detached .app-name::after {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--green);
}

.app-row.detached .app-icon-wrap {
  opacity: 0.72;
}

.app-icon-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.app-icon-wrap img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: contain;
}

.app-icon-glyph {
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text-2);
}

.app-icon-glyph .ico {
  width: 14px;
  height: 14px;
}

.app-row.active .app-icon-glyph,
.app-row:hover .app-icon-glyph {
  color: var(--text);
}

.app-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  border: 1.5px solid var(--surface);
  color: #fff;
  font-size: 9.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: content-box;
}

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

.app-name {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sub {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.app-sub .ico {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
}

.app-row.detached .app-sub {
  color: var(--text-2);
}

.app-popout-btn {
  opacity: 0;
}

.app-row:hover .app-popout-btn,
.app-popout-btn:focus-visible,
.app-row.detached .app-popout-btn {
  opacity: 1;
}

.app-row.detached .app-popout-btn {
  color: var(--text-2);
}

@media (hover: none) {
  .app-popout-btn,
  .recent-remove {
    opacity: 1;
  }
}

/* Stage Area */
.stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-canvas);
}

.win-tabs-bar {
  height: 36px;
  flex-shrink: 0;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-tabs);
  border-bottom: 1px solid var(--line);
}

.win-tabs-list {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.win-tabs-list::-webkit-scrollbar {
  display: none;
}

.win-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 4px 0 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  max-width: 220px;
  flex-shrink: 0;
  transition: background 0.1s ease, color 0.1s ease;
}

.win-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-2);
}

.win-tab.active {
  background: var(--elevated);
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.win-tab-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-tab-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.win-tab-icon-glyph {
  display: inline-flex;
  color: inherit;
  flex-shrink: 0;
}

.win-tab-icon-glyph .ico {
  width: 14px;
  height: 14px;
}

.win-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  padding: 0;
  opacity: 0;
  flex-shrink: 0;
  transition: background 0.1s ease, color 0.1s ease;
}

.win-tab-close .ico {
  width: 11px;
  height: 11px;
}

.win-tab:hover .win-tab-close,
.win-tab.active .win-tab-close,
.win-tab-close:focus-visible {
  opacity: 1;
}

.win-tab-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

@media (hover: none) {
  .win-tab-close {
    opacity: 1;
  }
}

.win-stage-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.viewport-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-canvas);
}

.canvas-host {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.remote-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  outline: none;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--line), 0 24px 64px -12px rgba(0, 0, 0, 0.8);
  background: #000;
}

.subwindow-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.subwindow-canvas {
  position: absolute;
  pointer-events: auto;
  border-radius: 5px;
  box-shadow: 0 0 0 1px var(--line-strong), 0 12px 32px rgba(0, 0, 0, 0.6);
  background: var(--surface);
}

.empty-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px;
  max-width: 420px;
  color: var(--text-3);
}

.empty-glyph {
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--text-2);
}

.empty-glyph .ico {
  width: 20px;
  height: 20px;
}

.empty-stage h2 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.empty-stage p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
}

/* Telemetry */
.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 24px;
  padding: 0 10px 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
  flex-shrink: 0;
}

.link-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-3);
  animation: ou-pulse 1.4s ease-in-out infinite;
}

.link-pill.p2p .link-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
  animation: none;
}

.link-pill.relay .link-dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
  animation: none;
}

.link-pill.p2p,
.link-pill.relay {
  color: var(--text);
}

@keyframes ou-pulse {
  50% {
    opacity: 0.35;
  }
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  padding: 0 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#video-hud-pill {
  display: block;
  line-height: 24px;
}

.host-pill {
  display: block;
  line-height: 24px;
  max-width: 180px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  padding-left: 22px;
  position: relative;
}

.host-pill::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 5px;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='12.5' rx='2'/%3E%3Cpath d='M8.5 20h7M12 16.5V20'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='12.5' rx='2'/%3E%3Cpath d='M8.5 20h7M12 16.5V20'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* Bottom shortcut & IME bar */
.shortcut-bar {
  height: 32px;
  flex-shrink: 0;
  padding: 0 8px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-tabs);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-3);
  overflow-x: auto;
  scrollbar-width: none;
}

.shortcut-bar::-webkit-scrollbar {
  display: none;
}

.shortcut-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.shortcut-tip {
  margin-right: 4px;
  white-space: nowrap;
}

.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 20px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-2);
  background: var(--keycap);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-bottom-color: rgba(0, 0, 0, 0.6);
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 0 rgba(0, 0, 0, 0.5);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.08s ease, color 0.08s ease, transform 0.06s ease;
}

.keycap:hover {
  background: #26262b;
  color: var(--text);
}

.keycap:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  background: #1a1a1e;
}

.ime-btn {
  height: 22px;
  color: var(--text-3);
  font-size: 11.5px;
}

.ime-proxy {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  border-radius: 12px;
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  background: rgba(9, 9, 11, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  pointer-events: none;
  z-index: 30;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 44px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--elevated);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  max-width: 360px;
  animation: ou-toast-in 0.18s ease-out;
}

@keyframes ou-toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1360px) {
  .host-pill {
    max-width: 130px;
  }
}

@media (max-width: 1180px) {
  .host-pill {
    display: none;
  }
}

@media (max-width: 1040px) {
  #video-hud-pill {
    display: none;
  }
  .topbar:has(#session-top-actions:not([hidden])) .state-btn .tb-label,
  .topbar:has(#session-top-actions:not([hidden])) #btn-disconnect .tb-label {
    display: none;
  }
  .topbar:has(#session-top-actions:not([hidden])) .state-btn,
  .topbar:has(#session-top-actions:not([hidden])) #btn-disconnect {
    width: 28px;
    padding: 0;
  }
}

@media (max-width: 900px) {
  .ver-num {
    display: none;
  }
  .connect-screen {
    padding: 28px 16px 40px;
  }
  .connect-grid {
    grid-template-columns: 1fr;
  }
  .workbench {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .shortcut-tip {
    display: none;
  }
  .win-stage-actions .btn span {
    display: none;
  }
  .win-stage-actions .btn {
    width: 26px;
    padding: 0;
  }
  #btn-install-pwa .tb-label {
    display: none;
  }
  #btn-install-pwa {
    width: 28px;
    padding: 0;
  }
}

@media (max-width: 760px) {
  .topbar:has(#session-top-actions:not([hidden])) .brand-link span,
  .topbar:has(#session-top-actions:not([hidden])) .ver-badge-group {
    display: none;
  }
  .topbar .tb-compact .tb-label {
    display: none;
  }
  .topbar .tb-compact {
    width: 28px;
    padding: 0;
  }
  .select-pill {
    max-width: 104px;
  }
  /* Workbench: sidebar collapses into a horizontal app strip */
  .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-head {
    height: 48px;
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 0 6px;
  }
  .sidebar-head > span {
    display: none;
  }
  .app-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 2px;
  }
  .app-row {
    flex: 0 0 auto;
    max-width: 180px;
    min-height: 36px;
  }
  .app-row.active::before {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: -6px;
    width: auto;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }
  .app-list > .app-row:first-child {
    margin-bottom: 0;
    margin-right: 5px;
  }
  .app-list > .app-row:first-child::after {
    left: auto;
    right: -3px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    height: auto;
  }
  .app-sub {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar-center .link-pill #link-mode-text {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hero-mark {
    display: none;
  }
  .card,
  .connect-card {
    padding: 16px;
  }
  .advanced-grid {
    grid-template-columns: 1fr;
  }
  .pwa-tip-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .ime-btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  #link-mode-text {
    display: none;
  }
  .topbar-center .link-pill {
    padding: 0 8px;
  }
  .topbar .tb-sep {
    display: none;
  }
  .select-pill {
    max-width: 92px;
  }
}

/* ==========================================================================
   Independent Pop-Out Window (`popup.html`)
   ========================================================================== */
body.popup-mode {
  background: #000;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.popup-bar {
  height: max(32px, env(titlebar-area-height, 32px));
  flex-shrink: 0;
  padding-left: max(10px, env(titlebar-area-x, 10px));
  padding-right: max(6px, calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 6px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  user-select: none;
  app-region: drag;
  -webkit-app-region: drag;
}

.popup-bar button {
  app-region: no-drag;
  -webkit-app-region: no-drag;
}

.popup-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.popup-title-wrap img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}

.popup-title-text {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.popup-bar .link-pill {
  height: 18px;
  padding: 0 7px 0 6px;
  gap: 5px;
  font-size: 10.5px;
  background: transparent;
  border-color: var(--line);
}

.popup-bar .link-dot {
  width: 5px;
  height: 5px;
}

.popup-bar .link-pill.p2p .link-dot,
.popup-bar .link-pill.relay .link-dot {
  box-shadow: none;
}

.popup-bar .shortcut-group {
  gap: 3px;
}

.popup-bar .keycap {
  height: 19px;
  min-width: 24px;
  font-size: 10px;
  padding: 0 5px;
}

.popup-bar .tb-sep {
  height: 14px;
  margin: 0 3px;
}

.popup-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.popup-stage .remote-canvas {
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 420px) {
  .popup-bar .keycap {
    display: none;
  }
  .popup-bar .tb-sep {
    display: none;
  }
}
