/* ─────────────────────────────────────────────
   CSS Custom Properties — default dark chrome
   ───────────────────────────────────────────── */
:root {
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-elevated:   #21262d;
  --bg-hover:      #2d333b;
  --bg-active:     #373e47;

  --border:        #30363d;
  --border-subtle: #21262d;

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;

  --accent:        #58a6ff;
  --accent-dim:    #1f6feb;
  --green:         #3fb950;
  --green-dim:     #238636;
  --red:           #f85149;
  --yellow:        #d29922;

  --toolbar-h:     42px;
  --tile-header-h: 36px;
  --esc-panel-h:   136px;
  --tab-h:         36px;
  --border-r:      6px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.4;
}

/* ─── App shell ─── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Toolbar ─── */
#toolbar {
  height: var(--toolbar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

#tabs-bar {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#toolbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border-left:  1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.app-title {
  font-size: 14px;
  font-weight: 300;
  letter-spacing: .4px;
  color: var(--text-secondary);
  pointer-events: none;
}
.app-title-com {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1.5px;
}

.btn-connect-port {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  background: var(--green-dim);
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, box-shadow .12s;
}
.btn-connect-port:hover {
  background: #2ea043;
  box-shadow: 0 0 0 2px rgba(63,185,80,.25);
}
#tabs-bar::-webkit-scrollbar { height: 3px; }
#tabs-bar::-webkit-scrollbar-track { background: transparent; }
#tabs-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#tabs-list {
  display: flex;
  align-items: stretch;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 0 12px;
  min-width: 120px;
  max-width: 200px;
  cursor: pointer;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: background .12s, color .12s;
  position: relative;
  flex-shrink: 0;
}
.tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab.active {
  background: var(--bg-base);
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--bg-base);
}

.tab-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .2s;
}
.tab-dot.connected    { background: var(--green); box-shadow: 0 0 4px var(--green); }
.tab-dot.connecting   { background: var(--yellow); animation: pulse 1s infinite; }
.tab-dot.error        { background: var(--red); }
.tab-dot.disconnected { background: var(--text-muted); }

.tab-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: background .1s, color .1s;
}
.tab-close:hover { background: var(--bg-active); color: var(--text-primary); }

/* ─── Toolbar right ─── */
#toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 10px;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-select {
  height: 26px;
  padding: 0 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.toolbar-select:hover { border-color: var(--accent); }
.toolbar-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.15); }

/* ─── Icon button ─── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 5px;
  cursor: pointer;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.btn-icon:hover  { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.active { background: var(--bg-active); color: var(--accent); }
.btn-icon.hidden { display: none; }

.btn-pwa-install { color: var(--accent); }
.btn-pwa-install:hover { color: var(--text-primary); }

#btn-add-tab {
  margin: auto 4px;
  width: 26px; height: 26px;
}

/* ─── Terminals container ─── */
#terminals-container {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  overflow: hidden;
  background: var(--bg-base);
  position: relative;
}

/* ── Resize overlay & handles ── */
.mosaic-resize-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
.resize-handle {
  position: absolute;
  pointer-events: all;
  z-index: 11;
}
.resize-handle-col {
  top: 0; bottom: 0;
  width: 8px;
  transform: translateX(-50%);
  cursor: col-resize;
}
.resize-handle-row {
  left: 0; right: 0;
  height: 8px;
  transform: translateY(-50%);
  cursor: row-resize;
}
.resize-handle::after {
  content: '';
  position: absolute;
  background: var(--accent);
  opacity: 0;
  transition: opacity .15s;
  border-radius: 2px;
}
.resize-handle-col::after  { top: 0; bottom: 0; left: 3px; right: 3px; }
.resize-handle-row::after  { left: 0; right: 0; top: 3px; bottom: 3px; }
.resize-handle:hover::after,
.resize-handle.dragging::after { opacity: .45; }
.resize-handle.dragging::after { opacity: .7; }

/* Tab mode: only active tile visible */
#terminals-container .terminal-tile { display: none; }
#terminals-container .terminal-tile.active { display: flex; }

/* Mosaic mode: show all tiles */
#terminals-container.mosaic .terminal-tile { display: flex; }

/* ── 2-tab layouts ── */
#terminals-container[data-layout="h2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
#terminals-container[data-layout="v2"] { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }

/* ── 3-tab layouts ── */
#terminals-container[data-layout="h3"] { grid-template-columns: repeat(3,1fr); grid-template-rows: 1fr; }
#terminals-container[data-layout="v3"] { grid-template-columns: 1fr; grid-template-rows: repeat(3,1fr); }
#terminals-container[data-layout="1v2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
#terminals-container[data-layout="1v2"] .terminal-tile:nth-child(1) { grid-row: 1 / 3; }
#terminals-container[data-layout="1h2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
#terminals-container[data-layout="1h2"] .terminal-tile:nth-child(1) { grid-column: 1 / 3; }

/* ── 4-tab layouts ── */
#terminals-container[data-layout="2x2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
#terminals-container[data-layout="h4"]  { grid-template-columns: repeat(4,1fr); grid-template-rows: 1fr; }
#terminals-container[data-layout="v4"]  { grid-template-columns: 1fr; grid-template-rows: repeat(4,1fr); }

/* ── Mosaic layout picker popup ── */
.mosaic-picker {
  position: fixed;
  z-index: 300;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--border-r);
  padding: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.7), 0 0 0 1px var(--bg-elevated);
}
.mosaic-picker.hidden { display: none; }

/* speech-bubble arrow */
.mosaic-picker::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--bg-surface);
  border-top: 2px solid var(--border);
  border-left: 2px solid var(--border);
  transform: rotate(45deg);
}

.mosaic-picker-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}

.mosaic-picker-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mosaic-card {
  background: var(--bg-base);
  border: 1.5px solid var(--border);
  border-radius: 4px;
  padding: 5px 5px 3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
  transition: border-color .12s, background .12s, color .12s;
}
.mosaic-card:hover,
.mosaic-card:focus-visible {
  border-color: var(--accent);
  background: var(--bg-elevated);
  color: var(--accent);
  outline: none;
}
.mosaic-card svg { display: block; width: 54px; height: 36px; }
.mosaic-card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  color: inherit;
  white-space: nowrap;
}
.mosaic-card.active {
  border-color: var(--accent);
  color: var(--accent);
}
.mosaic-picker-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.mosaic-card-reset {
  width: 100%;
  flex-direction: row;
  gap: 8px;
  padding: 4px 8px;
  justify-content: flex-start;
  color: var(--text-muted);
}
.mosaic-card-reset svg { width: 28px; height: 18px; flex-shrink: 0; }
.mosaic-card-reset:hover,
.mosaic-card-reset:focus-visible { color: var(--red); border-color: var(--red); }

/* ─── Terminal tile ─── */
.terminal-tile {
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.tile-header {
  height: var(--tile-header-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tile-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .25s;
}
.tile-status-dot.connected  { background: var(--green); box-shadow: 0 0 5px var(--green); }
.tile-status-dot.connecting { background: var(--yellow); animation: pulse 1s infinite; }
.tile-status-dot.error      { background: var(--red); }

.tile-port-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: background .12s, color .12s;
  white-space: nowrap;
}

.tile-btn-connect {
  background: var(--green-dim);
  color: #fff;
}
.tile-btn-connect:hover { background: var(--green); }

.tile-btn-disconnect {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(248,81,73,.4);
}
.tile-btn-disconnect:hover { background: rgba(248,81,73,.15); }

.tile-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  transition: background .12s, color .12s;
}
.tile-btn-icon:hover  { background: var(--bg-hover); color: var(--text-primary); }
.tile-btn-icon.active { background: var(--bg-active); color: var(--accent); }

/* ─── Terminal body ─── */
.tile-terminal-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 4px;
}

.tile-terminal-wrap .xterm {
  height: 100%;
}
.tile-terminal-wrap .xterm-viewport {
  scrollbar-width: thin;
}

/* ─── ESC panel ─── */
.tile-esc-panel {
  height: var(--esc-panel-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
}
.tile-esc-panel.hidden { display: none; }

.esc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}

.esc-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-right: 2px;
  flex-shrink: 0;
}

.esc-btn {
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  font-size: 10.5px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  white-space: nowrap;
  transition: background .1s, color .1s, border-color .1s;
}
.esc-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.esc-btn:active { background: var(--bg-active); }

.esc-custom-row {
  display: flex;
  gap: 4px;
}

.esc-custom-input {
  flex: 1;
  height: 24px;
  padding: 0 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  outline: none;
  transition: border-color .15s;
}
.esc-custom-input:focus { border-color: var(--accent); }
.esc-custom-input::placeholder { color: var(--text-muted); }

.esc-send-btn {
  height: 24px;
  padding: 0 10px;
  background: var(--accent-dim);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s;
}
.esc-send-btn:hover { background: var(--accent); }

/* ─── Modal ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 9, .72);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
  animation: modal-in .15s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

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

.btn-close-modal {
  width: 24px; height: 24px;
  color: var(--text-muted);
}
.btn-close-modal:hover { color: var(--text-primary); }

.modal-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.form-row label {
  width: 160px;
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.form-select {
  flex: 1;
  height: 28px;
  padding: 0 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.form-select:hover { border-color: var(--text-muted); }
.form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.15); }

.form-sep {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1px 0;
}

.form-input {
  flex: 1;
  height: 28px;
  padding: 0 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  outline: none;
  transition: border-color .15s;
}
.form-input:hover { border-color: var(--text-muted); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.15); }
.form-input::placeholder { color: var(--text-muted); font-family: inherit; }

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 2px;
  margin-top: -4px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 14px;
  background: var(--green-dim);
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s;
}
.btn-primary:hover { background: #2ea043; }

.btn-secondary {
  height: 30px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s;
}
.btn-secondary:hover { background: var(--bg-hover); }

/* ─── Prefs (Settings) modal ─── */
.prefs-box {
  width: 480px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.prefs-body {
  overflow-y: auto;
  padding: 4px 0 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.prefs-body::-webkit-scrollbar { width: 5px; }
.prefs-body::-webkit-scrollbar-track { background: transparent; }
.prefs-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.prefs-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.prefs-section-last { border-bottom: none; }

.prefs-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 11px;
}

.prefs-section-subtitle {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 12px 0 8px;
}

.prefs-section .form-row { margin-bottom: 8px; }
.prefs-section .form-row:last-child { margin-bottom: 0; }

/* Rows that contain a toggle: text label takes remaining space */
.prefs-section .form-row:has(.toggle-switch) > label:not(.toggle-switch) {
  width: auto;
  flex: 1;
}
.prefs-section .form-row:has(.toggle-switch) > .prefs-label-stack {
  flex: 1;
  width: auto;
}

.prefs-label-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.prefs-label-stack > span:first-child {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Toggle switch — must override .form-row label width */
.toggle-switch,
.form-row .toggle-switch,
.form-row label.toggle-switch {
  position: relative;
  display: inline-flex !important;
  flex-shrink: 0 !important;
  width: 36px !important;
  height: 20px !important;
  cursor: pointer;
}
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background .18s, border-color .18s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform .18s, background .18s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #fff;
}
.toggle-switch:hover .toggle-slider { border-color: var(--accent); }

/* Cookie notice & data buttons */
.prefs-cookie-notice {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}
.prefs-data-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.prefs-import-label {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s;
}
.prefs-import-label:hover { background: var(--bg-hover); }

.prefs-lang-select {
  height: 36px;
  padding: 0 10px;
  font-size: 13.5px;
}

/* ─── About modal ─── */
.about-box {
  width: 380px;
}
.about-body {
  padding: 20px 20px 24px;
}
.about-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.about-logo-icon {
  width: 40px;
  height: 40px;
  color: var(--text-accent, #4fc3f7);
  flex-shrink: 0;
}
.about-logo-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-primary);
}
.about-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: -8px 0 18px;
}
.about-table {
  width: 100%;
  border-collapse: collapse;
}
.about-table tr + tr td {
  border-top: 1px solid var(--border-subtle);
}
.about-table td {
  padding: 8px 4px;
  font-size: 12.5px;
  vertical-align: middle;
}
.about-label {
  color: var(--text-muted);
  white-space: nowrap;
  padding-right: 16px !important;
  width: 1%;
}
.about-link {
  color: var(--text-accent, #4fc3f7);
  text-decoration: none;
}
.about-link:hover { text-decoration: underline; }
.about-version {
  font-family: monospace;
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-secondary);
}

/* ─── Browser not supported overlay ─── */
.overlay-message {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

.overlay-box {
  text-align: center;
  max-width: 440px;
  padding: 40px;
}

.overlay-icon {
  width: 52px; height: 52px;
  color: var(--yellow);
  margin: 0 auto 20px;
  display: block;
}

.overlay-box h2 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.overlay-box p {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 10px;
}
.compat-browsers {
  color: var(--text-primary) !important;
  font-size: 15px !important;
  margin-top: 18px !important;
}
.compat-note {
  font-size: 12px !important;
  color: var(--text-muted) !important;
}

/* ─── Empty state in tile ─── */
.tile-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  user-select: none;
}
.tile-empty svg {
  opacity: .35;
}
.tile-empty p {
  font-size: 12px;
}

/* ─── Animations ─── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ─── Scrollbar customization ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* ─── Selection ─── */
::selection { background: rgba(88, 166, 255, .25); }

/* ─── Language switcher ─── */
.lang-switcher {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-lang-current {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: background .12s;
}
.btn-lang-current:hover { background: var(--bg-hover); }
.btn-lang-current.open  { background: var(--bg-active); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  z-index: 200;
  min-width: 148px;
  overflow: hidden;
  animation: dropdown-in .13s ease-out;
}
.lang-dropdown.hidden { display: none; }

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-5px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: left;
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.lang-option:hover  { background: var(--bg-hover);  color: var(--text-primary); }
.lang-option.active { background: var(--bg-active); color: var(--accent); }

.lang-flag {
  display: inline-block;
  width: 22px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 2px;
  overflow: hidden;
}
.btn-lang-current .lang-flag {
  width: 24px;
  height: 18px;
}

/* ─── Linux dialout notice ─── */
.linux-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px 9px 12px;
  background: rgba(210, 153, 34, .09);
  border-bottom: 1px solid rgba(210, 153, 34, .3);
  flex-shrink: 0;
}
.linux-notice.hidden { display: none; }

.linux-notice-icon {
  color: var(--yellow);
  flex-shrink: 0;
  margin-top: 2px;
}

.linux-notice-body {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.linux-notice-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
  font-size: 12.5px;
}

.linux-notice-body p { margin: 0 0 3px; }
.linux-notice-body strong { color: var(--text-primary); }
.linux-notice-body a { color: var(--accent); text-decoration: none; }
.linux-notice-body a:hover { text-decoration: underline; }

.linux-notice-cmd {
  display: inline-block;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  padding: 1px 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  margin: 3px 0 4px;
  user-select: all;
}

.linux-notice-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  margin-top: 1px;
  transition: background .1s, color .1s;
}
.linux-notice-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── Command Panel ─── */
.cmd-panel {
  position: relative;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 33vh;
  min-height: 80px;
}
.cmd-panel.hidden { display: none; }

.cmd-resize-handle {
  height: 5px;
  background: transparent;
  cursor: ns-resize;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  transition: background .15s;
}
.cmd-resize-handle:hover,
.cmd-resize-handle.dragging { background: var(--accent-dim); }

.cmd-panel-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.cmd-panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.cmd-output {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cmd-prompt {
  color: var(--accent);
  font-family: monospace;
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}

.cmd-input {
  flex: 1;
  height: 26px;
  padding: 0 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  outline: none;
  transition: border-color .15s;
}
.cmd-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.12); }
.cmd-input::placeholder { color: var(--text-muted); font-family: inherit; }

.cmd-run-btn {
  height: 26px;
  padding: 0 10px;
  background: var(--accent-dim);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .1s;
}
.cmd-run-btn:hover { background: var(--accent); }

.cmd-panel-help {
  width: 272px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.cmd-help-header {
  padding: 5px 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cmd-help-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.help-section { margin-bottom: 10px; }

.help-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 4px;
  padding: 0 2px;
}

.help-cmd {
  margin-bottom: 5px;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
}

.help-cmd-name {
  display: block;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 2px;
}

.help-cmd-desc {
  display: block;
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  line-height: 1.4;
}

.help-cmd-ex {
  display: inline-block;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
  height: 18px;
  line-height: 18px;
  cursor: pointer;
  margin: 1px 2px 1px 0;
  transition: background .1s, border-color .1s, color .1s;
}
.help-cmd-ex:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text-primary); }

/* Output lines */
.cmd-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 1px 0;
}

.cmd-line-prompt {
  color: var(--text-muted);
  flex-shrink: 0;
  width: 12px;
  text-align: right;
  font-size: 12px;
}
.cmd-line-input .cmd-line-prompt { color: var(--accent); }

.cmd-line-text {
  flex: 1;
  word-break: break-all;
  white-space: pre-wrap;
  color: var(--text-primary);
}
.cmd-line-info .cmd-line-text  { color: var(--text-secondary); }
.cmd-line-err .cmd-line-text   { color: var(--red); }
.cmd-line-warn .cmd-line-text  { color: var(--yellow); }
.cmd-line-ok .cmd-line-text    { color: var(--green); }
.cmd-line-head .cmd-line-text  { color: var(--accent); font-weight: 600; }
.cmd-line-input .cmd-line-text { color: var(--text-primary); font-weight: 500; }

/* Tables */
.cmd-table {
  border-collapse: collapse;
  font-size: 11.5px;
  margin: 2px 0;
}
.cmd-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 2px 14px 2px 0;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.cmd-table td { padding: 2px 14px 2px 0; color: var(--text-primary); }
.cmd-cell-name  { color: var(--accent)        !important; font-family: monospace; }
.cmd-cell-busy  { color: var(--red)           !important; }
.cmd-cell-free  { color: var(--green)         !important; }
.cmd-cell-muted { color: var(--text-muted)    !important; }

/* Notes */
.cmd-note {
  border-radius: 5px;
  padding: 8px 10px;
  margin: 4px 0;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.cmd-note-warn { border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.08); }
.cmd-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.cmd-note-icon { font-size: 14px; }
.cmd-note-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1; padding: 0;
}
.cmd-note-close:hover { color: var(--text-primary); }
.cmd-note-body p { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 4px; line-height: 1.5; }
.cmd-note-code {
  display: block; font-family: monospace; font-size: 11.5px;
  padding: 4px 8px; background: var(--bg-base); border-radius: 3px;
  margin: 4px 0; color: var(--accent);
}
.cmd-note-link {
  display: block; font-size: 11px; color: var(--accent);
  text-decoration: none; margin-top: 4px;
}
.cmd-note-link:hover { text-decoration: underline; }

/* ─── Theme: Solarized Light overrides for chrome ─── */
body.theme-chrome-light {
  --bg-base:       #fdf6e3;
  --bg-surface:    #eee8d5;
  --bg-elevated:   #e5dece;
  --bg-hover:      #ddd6c4;
  --bg-active:     #d3cab8;
  --border:        #cdc4b0;
  --border-subtle: #d3c9b5;
  --text-primary:  #586e75;
  --text-secondary:#657b83;
  --text-muted:    #93a1a1;
}
