:root {
  --bg-deep: #06141d;
  --bg: #0a1e2a;
  --glass: rgba(15, 35, 49, 0.55);
  --glass-strong: rgba(20, 45, 60, 0.75);
  --border: rgba(127, 219, 188, 0.12);
  --border-strong: rgba(127, 219, 188, 0.22);
  --text: #e6f0ee;
  --text-dim: #b3c6c3;
  --muted: #6b8a90;
  --mint: #3fd584;
  --mint-2: #2bb56a;
  --teal: #2dd4bf;
  --yellow: #f2c14e;
  --red: #ef5a5a;
  --blue: #5aa9ef;
  /* Apple-style easing curves */
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; min-height: 100vh; min-height: 100dvh; }
body {
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
button { -webkit-appearance: none; appearance: none; font-family: inherit; }
input, select, textarea { -webkit-appearance: none; appearance: none; font-family: inherit; }
input[type=password], input[type=text], input[type=email], input[type=number], textarea, select {
  /* iOS Safari zooms inputs whose font-size is below 16px on focus. Keep at 16px on mobile. */
  font-size: 16px;
}
[data-mobile-only] { display: none; }

/* Geometric background */
.bg-pattern {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1;
  pointer-events: none;
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,.04);
  border-radius: 18px;
}

/* === LOGIN === */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; padding: 36px;
  text-align: center;
}
.logo-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--mint), var(--teal));
  color: var(--bg-deep); margin-bottom: 16px;
}
.login-card h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.login-card h1 span { color: var(--mint); }
.login-card .sub { color: var(--text-dim); margin: 6px 0 28px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card input[type=password] {
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: rgba(0,0,0,.25);
  color: var(--text); font-size: 15px; outline: none;
}
.login-card input[type=password]:focus { border-color: var(--mint); }
.login-card .check {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
}
.login-card .check input { accent-color: var(--mint); }
.login-card button {
  padding: 14px; background: linear-gradient(135deg, var(--mint), var(--mint-2));
  color: var(--bg-deep); border: 0; border-radius: 12px;
  font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform .12s, filter .12s;
}
.login-card button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.err { color: var(--red); font-size: 13px; min-height: 1em; }

/* === DASH SHELL === */
.dash-shell {
  display: grid;
  grid-template-columns: 72px 1fr 320px;
  gap: 16px; padding: 16px; min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; gap: 8px;
  position: sticky; top: 16px; align-self: start; height: calc(100vh - 32px);
}
.sb-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--mint), var(--teal));
  color: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.sb-btn {
  width: 40px; height: 40px; border-radius: 10px;
  background: transparent; border: 0; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.sb-btn:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sb-btn.active { background: rgba(63, 213, 132, .12); color: var(--mint); }
.sb-spacer { flex: 1; }

/* MAIN CARD */
.main-card { padding: 24px; }

.main-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.title-row { display: flex; align-items: center; gap: 14px; }
.server-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: rgba(255,255,255,.04);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.main-header h1 {
  margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.5px;
}
.brand-accent { color: var(--mint); }
.pill {
  padding: 4px 12px; border-radius: 999px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.pill.on { background: rgba(63,213,132,.15); color: var(--mint); }
.pill.off { background: rgba(239,90,90,.15); color: var(--red); }
.pill.starting { background: rgba(242,193,78,.15); color: var(--yellow); }

.header-actions { display: flex; gap: 8px; align-items: center; }
.btn-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; border: 0;
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: transform .12s, filter .12s, background .12s;
  white-space: nowrap;
}
.btn-pill.small { padding: 6px 12px; font-size: 12px; }
.btn-pill.green { background: linear-gradient(135deg, var(--mint), var(--mint-2)); color: var(--bg-deep); }
.btn-pill.mint  { background: var(--mint); color: var(--bg-deep); }
.btn-pill.yellow { background: var(--yellow); color: #2a1e08; }
.btn-pill.blue   { background: var(--blue); color: #06141d; }
.btn-pill.ghost  { background: rgba(255,255,255,.05); color: var(--text); border: 1px solid var(--border-strong); }
.btn-pill { transition: transform .18s var(--ease-out), filter .18s var(--ease-out), background .18s var(--ease-out); }
.btn-pill:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-pill:active { transform: scale(0.96); transition: transform .08s var(--ease-out); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.icon-btn { transition: background .18s var(--ease-out), transform .18s var(--ease-out), color .18s var(--ease-out); }
.icon-btn:hover { background: rgba(255,255,255,.1); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }

/* LIFECYCLE BANNER */
.phase-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(63,213,132,.08), rgba(45,212,191,.05));
  border: 1px solid rgba(63,213,132,.25); border-radius: 12px;
  transition: opacity .4s, transform .4s;
}
.phase-banner.ready {
  background: linear-gradient(135deg, rgba(63,213,132,.18), rgba(45,212,191,.12));
  border-color: var(--mint);
}
.phase-banner.fading { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.phase-banner.error {
  background: linear-gradient(135deg, rgba(239,90,90,.12), rgba(242,193,78,.05));
  border-color: rgba(239,90,90,.5);
}
.phase-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.phase-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(63,213,132,.2); border-top-color: var(--mint);
  animation: phase-spin 1s linear infinite;
  flex-shrink: 0;
}
.phase-banner.ready .phase-spinner {
  animation: none;
  border-color: var(--mint);
  background: var(--mint);
  position: relative;
}
.phase-banner.ready .phase-spinner::after {
  content: ''; position: absolute; inset: 6px;
  border-bottom: 2.5px solid var(--bg-deep); border-right: 2.5px solid var(--bg-deep);
  transform: rotate(45deg) translate(-2px, -2px); width: 8px; height: 14px;
}
@keyframes phase-spin { to { transform: rotate(360deg); } }
.phase-text { min-width: 0; flex: 1; }
.phase-label { font-size: 14px; font-weight: 600; color: var(--text); }
.phase-detail { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.phase-progress { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.phase-progress-bar {
  width: 160px; height: 6px; background: rgba(0,0,0,.3); border-radius: 3px; overflow: hidden;
}
.phase-progress-bar > div {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--mint), var(--teal));
  transition: width .5s ease;
}
.phase-elapsed { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 36px; }

@media (max-width: 720px) {
  .phase-progress { min-width: 0; }
  .phase-progress-bar { width: 80px; }
}

/* TABS */
.tabs {
  display: flex; gap: 6px; margin-bottom: 20px;
  background: rgba(0,0,0,.2); padding: 6px; border-radius: 12px;
  width: fit-content; max-width: 100%; overflow-x: auto;
}
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 0;
  background: transparent; color: var(--text-dim);
  font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab { transition: background .25s var(--ease-out), color .25s var(--ease-out), transform .15s var(--ease-out); }
.tab:active { transform: scale(0.96); }
.tab.active {
  background: linear-gradient(135deg, var(--mint), var(--mint-2));
  color: var(--bg-deep); font-weight: 700;
  box-shadow: 0 2px 10px rgba(63, 213, 132, 0.25);
}

/* TAB PANEL — Apple-style cross-fade on switch */
.tab-panel { animation: none; }
.tab-panel.panel-enter {
  animation: panel-enter .42s var(--ease-out) both;
}
@keyframes panel-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* SERVER ADDRESS CARD — hero */
.address-card {
  position: relative;
  background: linear-gradient(135deg, rgba(63,213,132,.12), rgba(45,212,191,.05));
  border: 1px solid rgba(63,213,132,.28);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
  overflow: hidden;
  transition: opacity .35s var(--ease-out), border-color .35s var(--ease-out);
}
.address-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 0% 0%, rgba(63,213,132,.18), transparent 60%);
  pointer-events: none;
}
.address-card.is-offline {
  background: rgba(0,0,0,.25);
  border-color: var(--border);
}
.address-card.is-offline::before { display: none; }
.address-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  position: relative;
}
.address-label {
  font-size: 11px; font-weight: 600; color: var(--mint);
  text-transform: uppercase; letter-spacing: .8px;
}
.address-card.is-offline .address-label { color: var(--text-dim); }
.address-source { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.address-body {
  display: flex; align-items: center; gap: 12px;
  position: relative;
}
.address-value {
  flex: 1; min-width: 0;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 18px; font-weight: 600;
  color: var(--text);
  word-break: break-all;
  user-select: all;
  letter-spacing: -.2px;
}
.address-card.is-offline .address-value { color: var(--text-dim); font-size: 14px; }
.address-copy {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px;
  background: rgba(63,213,132,.18); border: 1px solid rgba(63,213,132,.35);
  color: var(--mint); font-size: 12px; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
  transition: background .18s var(--ease-out), transform .15s var(--ease-out), color .18s var(--ease-out);
}
.address-copy:hover { background: rgba(63,213,132,.28); }
.address-copy:active { transform: scale(0.94); }
.address-copy.copied {
  background: var(--mint); color: var(--bg-deep); border-color: var(--mint);
}
.address-card.is-offline .address-copy { display: none; }

@media (max-width: 720px) {
  .address-value { font-size: 16px; }
  .address-card { padding: 14px 16px; }
}

/* TUNNEL CARD */
.tunnel-card {
  background: rgba(0,0,0,.25); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 14px;
  transition: border-color .4s var(--ease-out);
}
.tunnel-card.is-on { border-color: rgba(63,213,132,.4); }
.tunnel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tunnel-title { display: flex; align-items: center; gap: 10px; }
.tunnel-title span:not(.pill) { font-size: 13px; font-weight: 600; color: var(--text); }
.tunnel-ico { color: var(--text-dim); }
.tunnel-card.is-on .tunnel-ico { color: var(--mint); }
.pill.small { padding: 3px 9px; font-size: 10px; }
.pill.warn { background: rgba(242,193,78,.18); color: var(--yellow); }
.tunnel-body { margin-top: 10px; }
.tunnel-empty { padding: 4px 0; }
.tunnel-addr-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tunnel-addr-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 10px;
}
.tunnel-addr-list li.is-java { background: rgba(63,213,132,.06); border-color: rgba(63,213,132,.25); }
.tunnel-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tunnel-meta { font-size: 10px; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.tunnel-warning {
  margin-top: 10px; padding: 9px 12px;
  background: rgba(242,193,78,.08); border: 1px solid rgba(242,193,78,.25);
  border-radius: 10px; color: var(--text-dim); line-height: 1.5;
}
.tunnel-warning a { color: var(--mint); text-decoration: none; }
.tunnel-warning a:hover { text-decoration: underline; }
.tunnel-addr {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--mint); user-select: all; word-break: break-all;
}
.tunnel-copy {
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  color: var(--text-dim); padding: 5px 10px; border-radius: 6px; font-size: 11px;
  cursor: pointer; transition: background .18s var(--ease-out), color .18s var(--ease-out), transform .15s var(--ease-out);
  flex-shrink: 0;
}
.tunnel-copy:hover { background: rgba(255,255,255,.08); color: var(--text); }
.tunnel-copy:active { transform: scale(0.94); }
.tunnel-copy.copied { background: var(--mint); color: var(--bg-deep); border-color: var(--mint); }

/* STAT CARDS */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  position: relative; overflow: hidden;
  background: rgba(0,0,0,.25); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px;
  min-height: 110px;
}
.stat-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.stat-label { color: var(--text-dim); font-size: 13px; font-weight: 500; }
.stat-ico {
  width: 26px; height: 26px; border-radius: 6px;
  background: rgba(255,255,255,.04); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
}
.stat-value {
  font-size: 26px; font-weight: 700; letter-spacing: -.5px;
  position: relative; z-index: 1;
}
.stat-wave {
  position: absolute; left: 0; right: 0; bottom: 0; height: 38px;
  background: linear-gradient(180deg, transparent 0%, rgba(63,213,132,.0) 0%, rgba(63,213,132,.55) 100%);
  clip-path: path('M 0 38 Q 30 22 60 28 T 120 24 T 180 30 T 240 22 T 300 26 T 360 24 L 360 38 Z');
  transition: opacity .3s;
  opacity: 0;
}
.stat-wave[data-pct]:not([data-pct="0"]) { opacity: 1; }

/* CONSOLE */
.console-block {
  background: rgba(0,0,0,.3); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-top: 4px;
}
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.console-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.console-body {
  background: #02080c; border: 1px solid rgba(63,213,132,.08); border-radius: 8px;
  padding: 12px; height: 360px; overflow-y: auto;
  font-family: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
  font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.console-body::-webkit-scrollbar { width: 8px; }
.console-body::-webkit-scrollbar-thumb { background: rgba(63,213,132,.15); border-radius: 4px; }
.console-body .ln-info { color: #9fd9c9; }
.console-body .ln-warn { color: var(--yellow); }
.console-body .ln-error { color: var(--red); }
.console-body .ln-dashboard { color: var(--blue); font-style: italic; }

.cmd-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  background: #02080c; border: 1px solid rgba(63,213,132,.08); border-radius: 8px;
  padding: 8px 12px;
}
.cmd-row .prompt { color: var(--mint); font-family: monospace; font-weight: 700; }
.cmd-row input {
  flex: 1; background: transparent; border: 0; color: var(--text); outline: none;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
}

/* PLAYERS */
.players-block { background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.players-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.players-head h3 { margin: 0; font-size: 14px; }
.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li {
  padding: 8px 12px; background: rgba(255,255,255,.03); border-radius: 8px;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.player-list li::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 8px var(--mint);
}
.player-list li.empty { color: var(--muted); }
.player-list li.empty::before { background: var(--muted); box-shadow: none; }
.player-list.mini li { padding: 6px 10px; font-size: 12px; }

/* RIGHT PANEL */
.right-panel {
  padding: 20px; position: sticky; top: 16px; align-self: start;
  height: calc(100vh - 32px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.rp-head {
  display: flex; align-items: center; justify-content: space-between;
}
.rp-head h3 {
  margin: 0; font-size: 12px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px;
}
.rp-divider { height: 1px; background: var(--border); margin: 6px 0; }
.activity-feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.activity-feed li {
  padding: 8px 10px; background: rgba(255,255,255,.03); border-radius: 8px;
  font-size: 12px; color: var(--text-dim); line-height: 1.4;
}
.activity-feed li b { color: var(--text); font-weight: 600; }
.activity-feed li.muted { background: transparent; color: var(--muted); font-style: italic; }

/* FILES TAB */
.files-block { background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-height: 500px; }
.files-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.breadcrumb { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text-dim); flex: 1; min-width: 0; word-break: break-all; }
.breadcrumb a { color: var(--mint); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--muted); margin: 0 4px; }
.files-body { display: grid; grid-template-columns: 1fr; gap: 12px; }
.file-list { list-style: none; padding: 0; margin: 0; max-height: 65vh; overflow-y: auto; }
.file-list li {
  display: grid; grid-template-columns: 28px 1fr auto auto 14px;
  align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  cursor: pointer; user-select: none; font-size: 13px;
  transition: background .18s var(--ease-out), transform .15s var(--ease-out);
}
.file-list li:hover { background: rgba(255,255,255,.04); }
.file-list li:active { background: rgba(255,255,255,.08); transform: scale(0.995); }
.file-list .ico {
  color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(255,255,255,.04);
}
.file-list .ico.dir { color: var(--mint); background: rgba(63,213,132,.08); }
.file-list .ico.back { color: var(--text-dim); }
.file-list .chev { color: var(--muted); display: inline-flex; }
.file-list .name { font-family: 'JetBrains Mono', monospace; }
.file-list .size, .file-list .date { color: var(--muted); font-size: 11px; white-space: nowrap; }
.file-list .hidden-entry .name { color: var(--muted); font-style: italic; }
.file-editor {
  background: #02080c; border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column;
}
.editor-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.editor-path { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text); }
.editor-actions { display: flex; gap: 6px; }
#editor-textarea {
  width: 100%; min-height: 50vh; padding: 14px;
  background: transparent; border: 0; resize: vertical;
  color: var(--text); font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 12px; line-height: 1.6; outline: none;
}

/* BACKUPS TAB */
.backup-block { background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.backup-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.backup-header h3 { margin: 0; font-size: 14px; }
.backup-header code { background: rgba(0,0,0,.4); padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.backup-actions { display: flex; gap: 8px; align-items: center; }
.backup-actions input {
  padding: 8px 10px; background: rgba(0,0,0,.3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; outline: none; min-width: 180px;
  font-family: 'JetBrains Mono', monospace;
}
.backup-list { list-style: none; padding: 0; margin: 0; }
.backup-list li {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 12px; align-items: center; padding: 10px 14px;
  background: rgba(255,255,255,.03); border-radius: 8px; margin-bottom: 6px;
}
.backup-list .bk-name { font-family: 'JetBrains Mono', monospace; font-size: 13px; word-break: break-all; }
.backup-list .bk-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.backup-list .empty { background: transparent; color: var(--muted); font-style: italic; text-align: center; padding: 24px; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.65); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: backdrop-in .3s ease-out;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  max-width: 480px; width: 100%; max-height: 80vh; overflow-y: auto;
  padding: 24px;
  animation: modal-in .45s var(--ease-spring);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.settings-section { margin-bottom: 24px; }
.settings-section h4 { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.settings-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.settings-form input[type=password] {
  flex: 1; min-width: 140px; padding: 9px 12px;
  background: rgba(0,0,0,.3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; outline: none;
}
.device-list { list-style: none; padding: 0; margin: 0; }
.device-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 12px; background: rgba(255,255,255,.03); border-radius: 8px; margin-bottom: 6px;
}
.device-list .dv-name { font-size: 12px; color: var(--text); word-break: break-all; flex: 1; min-width: 0; }
.device-list .dv-name small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.device-list .dv-current { color: var(--mint); font-size: 11px; font-weight: 600; }

/* CLICKABLE PLAYERS */
.player-list li[data-player] { cursor: pointer; transition: background .12s; user-select: none; }
.player-list li[data-player]:hover { background: rgba(63,213,132,.1); }

/* POPOVER */
.popover {
  position: fixed; z-index: 100;
  background: var(--glass-strong); backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
  padding: 14px; min-width: 280px; max-width: 320px;
  animation: popover-in .32s var(--ease-spring);
}
@keyframes popover-in {
  from { opacity: 0; transform: scale(0.93) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.popover-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.popover-title { font-size: 14px; font-weight: 700; color: var(--mint); }
.popover-title::before {
  content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 8px var(--mint); margin-right: 8px; vertical-align: middle;
}
.popover-close {
  background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 16px;
  width: 24px; height: 24px; border-radius: 4px;
}
.popover-close:hover { background: rgba(255,255,255,.08); color: var(--text); }
.popover-section { margin-bottom: 10px; }
.popover-section:last-child { margin-bottom: 0; }
.popover-label {
  display: block; font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.popover-row { display: flex; flex-wrap: wrap; gap: 6px; }
.popover-btn {
  flex: 1; min-width: 60px; padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; cursor: pointer;
  transition: background .18s var(--ease-out), transform .15s var(--ease-out);
  white-space: nowrap;
}
.popover-btn:hover { background: rgba(255,255,255,.1); }
.popover-btn:active { transform: scale(0.94); background: rgba(255,255,255,.14); }
.popover-btn.small { padding: 6px 8px; font-size: 11px; }
.popover-btn.mint { background: var(--mint); color: var(--bg-deep); border-color: var(--mint); font-weight: 600; }
.popover-btn.mint:hover { filter: brightness(1.1); }
.popover-btn.warn { color: var(--red); }
.popover-btn.warn:hover { background: rgba(239,90,90,.15); }
.popover-coords {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px;
}
.popover-coords input, .popover-coords select {
  padding: 6px 8px; background: rgba(0,0,0,.3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px; outline: none;
  font-family: 'JetBrains Mono', monospace;
}
.popover-coords select { grid-column: 1 / 4; }

/* ===== TOASTS (iOS-style) ===== */
#toast-tray {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: 14px;
  background: rgba(20, 45, 60, 0.92);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  color: var(--text); font-size: 13px;
  opacity: 0; transform: translateY(-12px) scale(0.95);
  transition: opacity .35s var(--ease-out), transform .45s var(--ease-spring);
  min-width: 200px; max-width: 360px;
}
.toast-show { opacity: 1; transform: translateY(0) scale(1); }
.toast-hide { opacity: 0; transform: translateY(-8px) scale(0.96); transition: opacity .3s ease-out, transform .3s ease-out; }
.toast-ico { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-success { border-color: rgba(63,213,132,.4); }
.toast-success .toast-ico { color: var(--mint); }
.toast-error { border-color: rgba(239,90,90,.4); }
.toast-error .toast-ico { color: var(--red); }
.toast-info .toast-ico { color: var(--blue); }
.toast-msg { flex: 1; line-height: 1.4; }

/* Spinner utility */
.spin { animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Status pill — pulse when starting */
.pill.starting {
  animation: pill-pulse 1.4s var(--ease-ios) infinite;
}
@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Pill state-change transition */
.pill { transition: background .35s var(--ease-out), color .35s var(--ease-out); }

/* MISC */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-dim);
}
.empty-state svg { color: var(--mint); margin-bottom: 16px; }
.empty-state h3 { margin: 0 0 8px; font-size: 18px; color: var(--text); }
.empty-state p { margin: 0; font-size: 13px; }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .dash-shell { grid-template-columns: 72px 1fr; }
  .right-panel { display: none; }
}

/* ===== MOBILE / iOS (≤ 720px) ===== */
@media (max-width: 720px) {
  html, body {
    width: 100%; max-width: 100vw; overflow-x: hidden;
  }
  body { padding-bottom: env(safe-area-inset-bottom); }

  /* Single column with bottom tab bar layout (only when dash is visible) */
  .dash-shell:not([hidden]) {
    display: block;
    grid-template-columns: none;
    width: 100%; max-width: 100vw;
    padding: 0; gap: 0;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    min-height: 100dvh;
  }

  /* SIDEBAR → BOTTOM TAB BAR */
  .sidebar {
    position: fixed;
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; height: auto;
    align-self: auto;
    flex-direction: row;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    gap: 4px; border-radius: 0;
    border: 0; border-top: 1px solid var(--border-strong);
    background: rgba(10,30,42,.92);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    z-index: 90;
    justify-content: space-around;
  }
  .sb-logo { display: none; }
  .sb-spacer { display: none; }
  .sb-btn {
    width: 48px; height: 48px;
    border-radius: 12px;
    flex-shrink: 0;
  }
  .sb-btn[data-mobile-only], [data-mobile-only] { display: inline-flex; }
  .sb-btn:active { background: rgba(255,255,255,.08); transform: scale(0.94); }
  .sb-btn.active { background: linear-gradient(135deg, rgba(63,213,132,.18), rgba(45,212,191,.1)); }

  /* MAIN CARD — flat full-width */
  .main-card {
    width: 100% !important; max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: 0 !important; border-right: 0 !important; border-top: 0 !important;
    padding: calc(16px + env(safe-area-inset-top)) 14px 16px !important;
    min-height: calc(100dvh - 80px - env(safe-area-inset-bottom));
  }
  /* Right panel completely hidden + zeroed */
  .right-panel { display: none !important; width: 0 !important; }

  /* HEADER — stack and reflow */
  .main-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .title-row { justify-content: flex-start; }
  .main-header h1 { font-size: 22px; }
  .server-icon { width: 40px; height: 40px; }
  .header-actions {
    flex-wrap: wrap; gap: 6px;
    width: 100%;
  }
  .header-actions .btn-pill { flex: 1; justify-content: center; min-height: 44px; padding: 0 12px; }
  .header-actions .icon-btn { min-width: 44px; min-height: 44px; }

  /* TABS — horizontal scroll if needed */
  .tabs {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { min-height: 40px; padding: 8px 14px; }

  /* STATS — 2-column compact */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; min-height: 96px; }
  .stat-value { font-size: 22px; }

  /* CONSOLE — make it the focus, taller; force wrap so no horizontal scroll */
  .console-body {
    height: 50dvh;
    font-size: 11px; padding: 10px;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-all !important;
  }
  .cmd-row input { font-size: 16px; /* prevent zoom */ }
  .console-block { padding: 12px; }

  /* PHASE BANNER — stack */
  .phase-banner { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .phase-progress { min-width: 0; justify-content: space-between; }
  .phase-progress-bar { width: 100%; flex: 1; }

  /* PLAYER POPOVER → BOTTOM SHEET */
  .popover {
    position: fixed !important;
    left: 0 !important; right: 0 !important; top: auto !important;
    bottom: 0 !important;
    width: 100%; max-width: 100%; min-width: 0;
    border-radius: 18px 18px 0 0;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 80dvh; overflow-y: auto;
    box-shadow: 0 -16px 48px rgba(0,0,0,.6);
    animation: sheet-up .25s ease;
  }
  .popover::before {
    content: ''; display: block; width: 40px; height: 4px;
    background: var(--border-strong); border-radius: 2px;
    margin: -8px auto 14px;
  }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .popover-btn { min-height: 40px; font-size: 14px; }
  .popover-btn.small { min-height: 36px; font-size: 13px; }
  .popover-coords input { padding: 10px; font-size: 16px; }

  /* SETTINGS MODAL — full screen sheet */
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal {
    border-radius: 0; max-width: 100%; max-height: 100dvh; height: 100dvh;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    padding-top: calc(20px + env(safe-area-inset-top));
  }
  .settings-form input[type=password] { padding: 12px; }

  /* FILES */
  .files-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .file-list li { grid-template-columns: 24px 1fr auto; padding: 12px; min-height: 48px; }
  .file-list .date { display: none; }
  .file-list .ico { font-size: 18px; }
  #editor-textarea { min-height: 60dvh; font-size: 14px; padding: 12px; }
  .editor-header { flex-wrap: wrap; gap: 6px; }
  .editor-path { font-size: 11px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  /* BACKUPS */
  .backup-header { flex-direction: column; }
  .backup-actions { width: 100%; }
  .backup-actions input { flex: 1; padding: 12px; }
  .backup-list li {
    grid-template-columns: 1fr;
    gap: 6px; padding: 14px;
  }
  .backup-list li > span:nth-child(4) {
    display: flex; gap: 6px; margin-top: 4px;
  }
  .backup-list li > span:nth-child(4) button { flex: 1; padding: 10px; }

  /* LOGIN screen */
  .login-shell { min-height: 100dvh; padding: 24px; }
  .login-card { padding: 28px 22px; }
  .login-card input[type=password] { padding: 14px; font-size: 16px; }
  .login-card button { min-height: 50px; }
}

  /* Defensive: kill any stray inline grid widths */
  .grid { grid-template-columns: 1fr !important; max-width: 100% !important; }
  .tab-panel, .panel, .files-block, .backup-block, .console-block, .players-block {
    width: 100% !important; max-width: 100% !important; box-sizing: border-box;
  }
  /* Any element should not exceed viewport */
  .stat-card, .file-list li, .backup-list li, .console-body, #editor-textarea {
    max-width: 100%; box-sizing: border-box;
  }
  /* Background SVG pattern: keep it covering the viewport */
  .bg-pattern { width: 100vw !important; height: 100dvh !important; }
}

/* ===== EVEN SMALLER (≤ 400px) ===== */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .header-actions .btn-pill { font-size: 12px; padding: 0 10px; }
  .main-header h1 { font-size: 20px; }
}

/* Hover only on devices that actually have a pointer (skip touch states on iOS) */
@media (hover: none) {
  .btn-pill:hover, .icon-btn:hover, .sb-btn:hover, .tab:hover,
  .file-list li:hover, .popover-btn:hover, .player-list li[data-player]:hover {
    background: inherit; filter: none; transform: none;
  }
  .btn-pill:active { filter: brightness(1.12); transform: scale(0.97); }
  .file-list li:active, .player-list li[data-player]:active { background: rgba(63,213,132,.12); }
  .popover-btn:active { background: rgba(255,255,255,.1); }
}
