/* Minecraft Manager - Dark theme UI */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --primary: #3fb950;
  --primary-dim: #2d8c3e;
  --danger: #f85149;
  --warning: #e3b341;
  --info: #58a6ff;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --text-muted: #8b949e;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #e3b341;
  --radius: 6px;
  --radius-lg: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Demo banner --- */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: #2a1f00;
  border-bottom: 1px solid #6b4f00;
  color: #e3b341;
  font-size: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 200;
}
.demo-banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.demo-banner span:nth-child(2) {
  flex: 1;
}
.demo-banner-close {
  background: none;
  border: none;
  color: #e3b341;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
  opacity: 0.7;
  flex-shrink: 0;
}
.demo-banner-close:hover {
  opacity: 1;
}

/* --- Login --- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #1a2a1a 0%, var(--bg) 70%);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-logo {
  text-align: center;
  margin-bottom: 0.5rem;
}
.login-logo h1 {
  font-size: 1.4rem;
  color: var(--text);
}
.login-logo p {
  color: var(--text-dim);
  font-size: 0.85rem;
}
.logo-icon {
  color: var(--primary);
  font-size: 1.5rem;
}
.demo-hint {
  background: #2a1f00;
  border: 1px solid #6b4f00;
  border-radius: var(--radius);
  color: #e3b341;
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  text-align: center;
}
.btn-oidc {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  display: block;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.btn-oidc:hover {
  background: var(--border);
  color: var(--text);
}
.login-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
}
.site-name {
  display: none;
}
@media (min-width: 640px) {
  .site-name {
    display: inline;
  }
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tab-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar {
  display: none;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  white-space: nowrap;
  transition:
    color 0.15s,
    background 0.15s;
}
.tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.tab-btn.active {
  background: var(--surface2);
  color: var(--primary);
  font-weight: 600;
}

/* --- Tab content --- */
.tab-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}
.hidden {
  display: none !important;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.page-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}
.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Stat cards --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}

/* --- Crash alert --- */
.crash-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #3a0a0a;
  border: 2px solid #e74c3c;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: #ff6b6b;
  font-weight: 700;
  font-size: 0.95rem;
  animation: crash-pulse 1.5s ease-in-out infinite;
}
@keyframes crash-pulse {
  0%,
  100% {
    border-color: #e74c3c;
    background: #3a0a0a;
  }
  50% {
    border-color: #ff6b6b;
    background: #4a1010;
  }
}
.crash-alert .btn {
  color: #ff6b6b;
  flex-shrink: 0;
}

/* --- Lag spike alert --- */
.lag-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #2a1a1a;
  border: 1px solid #c0392b;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  color: #e74c3c;
  font-weight: 600;
  font-size: 0.9rem;
  animation: lag-pulse 2s ease-in-out infinite;
}
@keyframes lag-pulse {
  0%,
  100% {
    border-color: #c0392b;
  }
  50% {
    border-color: #e74c3c;
  }
}
.lag-alert .btn {
  color: #e74c3c;
  flex-shrink: 0;
}

/* --- Preflight checks panel --- */
.preflight-panel {
  border-color: var(--warning, #f39c12);
}
.preflight-panel h3 {
  color: var(--warning, #f39c12);
}
.preflight-summary {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--text-dim);
}
.preflight-checks {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.preflight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.85rem;
  line-height: 1.4;
}
.preflight-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.4;
}
.preflight-item.preflight-error {
  border-left: 3px solid #e74c3c;
}
.preflight-item.preflight-error .preflight-icon {
  color: #e74c3c;
}
.preflight-item.preflight-warn {
  border-left: 3px solid #f39c12;
}
.preflight-item.preflight-warn .preflight-icon {
  color: #f39c12;
}
.preflight-item.preflight-ok {
  border-left: 3px solid #27ae60;
}
.preflight-item.preflight-ok .preflight-icon {
  color: #27ae60;
}
.preflight-title {
  font-weight: 600;
}
.preflight-detail {
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* --- Control sections --- */
.control-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.control-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.input-row {
  display: flex;
  gap: 0.5rem;
}
.input-row input {
  flex: 1;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  transition:
    background 0.15s,
    opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #0d1117;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: #5fd66a;
}
.btn-success {
  background: #196c2e;
  color: var(--green);
  border-color: #2da44e;
}
.btn-success:hover:not(:disabled) {
  background: #2da44e;
  color: #fff;
}
.btn-danger {
  background: #5a1a1a;
  color: var(--danger);
  border-color: #8a2020;
}
.btn-danger:hover:not(:disabled) {
  background: #8a2020;
  color: #fff;
}
.btn-warning {
  background: #4a3500;
  color: var(--warning);
  border-color: #7a5a00;
}
.btn-warning:hover:not(:disabled) {
  background: #7a5a00;
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
}
.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}
.btn-full {
  width: 100%;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-running {
  background: #196c2e;
  color: var(--green);
  border: 1px solid #2da44e;
}
.badge-stopped {
  background: #3d1212;
  color: var(--danger);
  border: 1px solid #6b2020;
}

.side-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-weight: 600;
}
.side-both {
  background: #1c3a5e;
  color: #79c0ff;
}
.side-server {
  background: #2a1f5e;
  color: #d2a8ff;
}
.side-client {
  background: #1c3a2a;
  color: #56d364;
}
.side-unknown {
  background: var(--surface2);
  color: var(--text-dim);
}
.mod-off-badge {
  background: #3d3000;
  color: var(--warning);
}
.installed-badge {
  background: #1a2e1a;
  color: #3fb950;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid #2a6a2a;
}
.badge-important {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  background: #3d2800;
  color: var(--warning);
  font-weight: 600;
}

.level-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
}
.level-4 {
  background: #3d1212;
  color: var(--danger);
}
.level-3 {
  background: #3d2800;
  color: var(--warning);
}
.level-2 {
  background: #1c3a5e;
  color: var(--info);
}
.level-1 {
  background: var(--surface2);
  color: var(--text-dim);
}

/* --- Forms --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='email'],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.45rem 0.7rem;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
}
.hint {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.settings-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.prop-important {
  border-left: 3px solid var(--warning);
  padding-left: 0.75rem;
}

/* --- Quick Actions --- */
.quick-actions-details summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.quick-actions-details summary::-webkit-details-marker {
  display: none;
}
.quick-actions-details summary h3 {
  display: inline;
}
.quick-actions-details summary::before {
  content: '▸ ';
  font-size: 0.85rem;
  color: var(--text-dim);
}
.quick-actions-details[open] summary::before {
  content: '▾ ';
}
.quick-actions-details[open] .action-categories {
  margin-top: 0.75rem;
}
.action-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}
.action-category {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.action-category h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.action-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* --- Console --- */
.console-wrap {
  background: #020408;
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  height: calc(100vh - 280px);
  min-height: 300px;
  overflow: hidden;
}
.console-output {
  height: 100%;
  overflow-y: auto;
  padding: 0.75rem;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.console-line {
  white-space: pre-wrap;
  word-break: break-all;
}
.console-info {
  color: var(--info);
}
.console-warn {
  color: var(--warning);
}
.console-error {
  color: var(--danger);
}
.console-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 0.5rem 0.75rem;
}
.console-prompt {
  color: var(--primary);
  font-family: monospace;
  font-weight: 700;
}
.console-input-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: monospace;
  font-size: 0.875rem;
}
.console-input-bar input:focus {
  outline: none;
}
.console-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* --- Subtabs --- */
.subtab-nav {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.subtab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  margin-bottom: -1px;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.subtab-btn:hover {
  color: var(--text);
}
.subtab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* --- Mods --- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar input:not([type='checkbox']) {
  flex: 1;
  min-width: 160px;
}
.filter-bar select {
  min-width: 130px;
  width: auto;
}

.mods-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.browse-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mod-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  transition: border-color 0.15s;
}
.mod-card:hover {
  border-color: #4a4f56;
}
.mod-card.mod-disabled {
  opacity: 0.6;
}

.mod-icon {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}
.mod-icon-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: var(--surface2);
  flex-shrink: 0;
}
.mod-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mod-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-weight: 600;
}
.mod-desc {
  color: var(--text-dim);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mod-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
}
.mod-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.progress-bar {
  background: var(--surface2);
  border-radius: 20px;
  height: 6px;
  margin-bottom: 0.5rem;
}
.progress-fill {
  background: var(--primary);
  border-radius: 20px;
  height: 100%;
  transition: width 0.3s;
  width: 0;
}

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}
.browse-heading {
  font-size: 0.82rem;
  margin-bottom: 0.6rem;
}
.cat-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  text-transform: capitalize;
}

/* --- Players --- */
.player-table-wrap {
  overflow-x: auto;
}
.player-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.player-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.player-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.player-table tr:last-child td {
  border-bottom: none;
}
.player-table tr:hover td {
  background: var(--surface2);
}

.add-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.add-row input {
  flex: 1;
  min-width: 140px;
}

.legend-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  line-height: 1.7;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.6rem 0.2rem 0.7rem;
  font-size: 0.85rem;
}
.chip-kick {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.chip-kick:hover {
  color: var(--danger);
}

/* --- Version modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-body {
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.version-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.version-row:last-child {
  border-bottom: none;
}
.version-row > div:first-child {
  flex: 1;
}

/* --- Schedule picker --- */
.schedule-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.schedule-picker select {
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.schedule-label {
  color: var(--text-dim);
  font-size: 0.9rem;
  white-space: nowrap;
}
.cron-details {
  margin-top: 0.5rem;
}
.cron-details summary {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.cron-details[open] summary {
  margin-bottom: 0.25rem;
}

/* --- Directory browser --- */
.dir-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  min-height: 1.6rem;
}
.dir-crumb {
  color: var(--accent);
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  border-radius: var(--radius);
  white-space: nowrap;
}
.dir-crumb:hover {
  background: var(--bg-hover);
  text-decoration: underline;
}
.dir-crumb-sep {
  color: var(--text-dim);
  user-select: none;
}
.dir-crumb-current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}
.dir-crumb-current:hover {
  background: none;
  text-decoration: none;
}
.dir-browser-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
}
.dir-browser-list:empty::after {
  content: 'No subdirectories';
  display: block;
  padding: 1rem;
  color: var(--text-dim);
  text-align: center;
}
.dir-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.dir-entry:last-child {
  border-bottom: none;
}
.dir-entry:hover {
  background: var(--bg-hover);
}
.dir-entry-icon {
  opacity: 0.6;
}

/* --- Helpers --- */
.dim {
  color: var(--text-dim);
}
.small {
  font-size: 0.78rem;
}
.text-green {
  color: var(--green);
}
.text-red {
  color: var(--red);
}
.text-yellow {
  color: var(--yellow);
}
/* ---- Spacing & layout utilities ---- */
.mt-xs {
  margin-top: 0.35rem;
}
.mt-sm {
  margin-top: 0.5rem;
}
.mt-md {
  margin-top: 0.75rem;
}
.mt-lg {
  margin-top: 1rem;
}
.mb-md {
  margin-bottom: 0.75rem;
}
.mb-sm {
  margin-bottom: 0.5rem;
}
.p-md {
  padding: 0.75rem;
}
.text-base {
  font-size: 1rem;
}
.cursor-pointer {
  cursor: pointer;
}
.hr-subtle {
  border-color: var(--border);
  margin: 0.5rem 0;
}

.control-msg {
  min-height: 1.4rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.launch-preview {
  display: block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text-dim);
  min-height: 1.5rem;
}
.ok-msg {
  color: var(--green);
}
.error-msg {
  color: var(--danger);
}

/* --- Scrollbar --- */
::-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: #4a4f56;
}

/* --- Responsive --- */

/* Tablet */
@media (max-width: 768px) {
  .mod-detail-hero {
    flex-direction: column;
  }
  .mod-detail-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .gallery-img {
    height: 140px;
  }
  .backup-card {
    flex-wrap: wrap;
  }
  .backup-actions {
    width: 100%;
  }
}

/* Phone */
@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .mod-desc {
    display: none;
  }
  .tab-content {
    padding: 0.75rem;
  }

  /* Login box */
  .login-box {
    width: auto;
    max-width: 340px;
    margin: 0 0.75rem;
  }

  /* Topbar */
  .topbar {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }
  .tab-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }

  /* Console */
  .console-wrap {
    height: 50vh;
    min-height: 200px;
  }
  .console-input-bar {
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
  }

  /* Filter bars */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar input:not([type='checkbox']) {
    min-width: 0;
  }
  .filter-bar select {
    min-width: 0;
    width: 100%;
  }

  /* Cards & actions */
  .mod-card {
    flex-wrap: wrap;
  }
  .mod-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .backup-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .backup-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Quick actions grid */
  .action-categories {
    grid-template-columns: 1fr;
  }
  .action-btn-grid .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  /* Mod detail */
  .mod-detail-hero {
    flex-direction: column;
  }
  .mod-detail-icon {
    width: 56px;
    height: 56px;
  }
  .mod-detail-title {
    font-size: 1.15rem;
  }
  .mod-detail-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .gallery-img {
    height: 120px;
  }

  /* Tables — hide UUID column on mobile */
  .player-table {
    font-size: 0.8rem;
  }
  .player-table th,
  .player-table td {
    padding: 0.4rem 0.5rem;
  }
  .player-table .small {
    display: none;
  }

  /* Modals */
  .modal {
    max-width: calc(100vw - 1rem);
  }
  .cmd-help-modal-wide {
    max-width: calc(100vw - 1rem);
  }
  .modpack-modal-wide {
    max-width: calc(100vw - 1rem);
  }

  /* Page headers */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
  }

  /* Schedule picker */
  .schedule-picker {
    flex-direction: column;
    align-items: flex-start;
  }
  .schedule-picker select {
    width: 100%;
  }

  /* Input rows */
  .input-row {
    flex-direction: column;
  }
  .add-row {
    flex-direction: column;
  }
  .add-row input {
    min-width: 0;
  }
}

/* ── Mod detail panel ─────────────────────────────────────────── */
#btn-mod-detail-back {
  margin-bottom: 1rem;
}

.mod-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.mod-detail-hero {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.mod-detail-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}

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

.mod-detail-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  line-height: 1.2;
}

.mod-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0;
}

.mod-detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.mod-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.mod-detail-summary {
  margin: 1rem 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.mod-detail-section {
  margin-bottom: 1.5rem;
}

.mod-detail-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Gallery */
.mod-gallery {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.gallery-img {
  height: 180px;
  width: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.gallery-img:hover {
  opacity: 0.85;
}

/* Rendered markdown body */
.mod-detail-body {
  line-height: 1.7;
  font-size: 0.93rem;
  color: var(--text);
}

.mod-detail-body h1,
.mod-detail-body h2,
.mod-detail-body h3 {
  margin: 1.25rem 0 0.5rem;
  font-weight: 600;
}

.mod-detail-body h1 {
  font-size: 1.3rem;
}
.mod-detail-body h2 {
  font-size: 1.1rem;
}
.mod-detail-body h3 {
  font-size: 1rem;
}

.mod-detail-body p {
  margin: 0.6rem 0;
}

.mod-detail-body a {
  color: var(--info);
  text-decoration: none;
}
.mod-detail-body a:hover {
  text-decoration: underline;
}

.mod-detail-body img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 0.5rem 0;
}

.mod-detail-body code {
  background: var(--surface2);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.88em;
  font-family: 'Consolas', 'Monaco', monospace;
}

.mod-detail-body pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}

.mod-detail-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

.mod-detail-body ul,
.mod-detail-body ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.mod-detail-body blockquote {
  border-left: 3px solid var(--border);
  margin: 0.5rem 0;
  padding: 0.25rem 0.75rem;
  color: var(--text-muted);
}

.mod-detail-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  margin: 0.75rem 0;
}

.mod-detail-body th,
.mod-detail-body td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.mod-detail-body th {
  background: var(--surface2);
  font-weight: 600;
}

/* Clickable mod title */
.mod-title-link {
  cursor: pointer;
  color: inherit;
  transition: color 0.15s;
}
.mod-title-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* --- Backups --- */
.backup-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
}
.backup-card:hover {
  border-color: #4a4f56;
}
.backup-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.backup-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-weight: 600;
  font-size: 0.9rem;
}
.backup-date {
  color: var(--text);
}
.backup-note {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
}
.backup-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.backup-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.backup-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-weight: 600;
}
.backup-scheduled {
  background: #1c3a5e;
  color: #79c0ff;
}
.backup-manual {
  background: #2a1f5e;
  color: #d2a8ff;
}
.backup-db {
  background: #1a2e1a;
  color: #3fb950;
}
.backup-quiesced {
  background: #1a2a2e;
  color: #58d1c9;
}

.restore-manifest {
  width: 100%;
  font-size: 0.85rem;
  margin: 0.75rem 0;
  border-collapse: collapse;
}
.restore-manifest td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.restore-manifest td:first-child {
  color: var(--muted);
  white-space: nowrap;
  width: 110px;
}

.restore-integrity {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  margin-top: 0.5rem;
}
.restore-ok {
  background: #1a2e1a;
  color: #3fb950;
}
.restore-fail {
  background: #3d1212;
  color: var(--danger);
}
.restore-warn {
  background: #2e2a1a;
  color: #d29922;
}

.restore-warning {
  background: #3d1212;
  border: 1px solid #6b2020;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--danger);
  font-size: 0.88rem;
}

/* --- Modpack import/export --- */
.modpack-modal-wide {
  max-width: 720px;
}

.modpack-summary {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.modpack-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.modpack-stat {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}
.modpack-stat-new {
  background: #1a2e1a;
  color: #3fb950;
}
.modpack-stat-conflict {
  background: #3d2800;
  color: var(--warning);
}
.modpack-stat-skip {
  background: #1c3a5e;
  color: #79c0ff;
}
.modpack-stat-client {
  background: var(--surface2);
  color: var(--text-dim);
}

.modpack-section {
  margin-top: 0.75rem;
}
.modpack-section h4 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-dim);
}

.modpack-conflict-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.modpack-conflict-row:last-child {
  border-bottom: none;
}

.modpack-mod-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.modpack-mod-chip {
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  background: #1a2e1a;
  color: #3fb950;
  border: 1px solid #2a6a2a;
}
.modpack-chip-skip {
  background: #1c3a5e;
  color: #79c0ff;
  border-color: #2a4a7a;
}
.modpack-chip-client {
  background: var(--surface2);
  color: var(--text-dim);
  border-color: var(--border);
}
.modpack-chip-fail {
  background: #3d1212;
  color: var(--danger);
  border-color: #6b2020;
}

/* --- Command Reference help modal --- */
.cmd-help-modal-wide {
  max-width: 760px;
  max-height: 85vh;
}
.cmd-help-search-bar {
  padding: 0.75rem 1.25rem 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.cmd-help-search-bar input {
  width: 100%;
}
.cmd-help-body {
  padding-top: 0.75rem;
  gap: 0;
}

.cmd-help-category {
  margin-bottom: 1rem;
}
.cmd-help-category-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.cmd-help-entry {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.cmd-help-entry-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.cmd-help-entry-header:hover {
  background: var(--surface2);
}
.cmd-help-entry-toggle {
  color: var(--text-dim);
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: transform 0.15s;
  width: 0.75rem;
  text-align: center;
}
.cmd-help-entry.open .cmd-help-entry-toggle {
  transform: rotate(90deg);
}
.cmd-help-cmd {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85rem;
  color: var(--info);
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.cmd-help-entry-run {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}
.cmd-help-entry-run:hover {
  background: var(--primary);
  color: #0d1117;
  border-color: var(--primary);
}
.cmd-help-detail {
  display: none;
  padding: 0.6rem 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.6;
}
.cmd-help-entry.open .cmd-help-detail {
  display: block;
}
.cmd-help-detail p {
  margin: 0.3rem 0;
}
.cmd-help-detail .cmd-syntax {
  background: var(--surface2);
  font-family: 'Consolas', 'Monaco', monospace;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  display: inline-block;
  margin: 0.25rem 0;
}
.cmd-help-detail .cmd-example {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}
.cmd-help-detail .cmd-tip {
  background: #1c2a1c;
  border: 1px solid #2a4a2a;
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #7dd87d;
}
.cmd-help-no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
}
.cmd-help-intro {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.6;
}
