/* =========================================================
   PERFORMANCE LAYER
   Loaded last to keep the UI smooth on large lists.
========================================================= */

* {
  transition-duration: 120ms !important;
}

.navbar,
.sidebar,
.panel,
.zone,
.feat,
.char,
.stat-card,
.hero,
.management-panel,
.summary-card,
.hero-metrics div,
.focus-item {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.zone,
.feat,
.char,
.stat-card,
.management-panel,
.summary-card,
.hero-metrics div,
.focus-item {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18) !important;
}

body.light-mode .zone,
body.light-mode .feat,
body.light-mode .char,
body.light-mode .stat-card,
body.light-mode .management-panel,
body.light-mode .summary-card,
body.light-mode .hero-metrics div,
body.light-mode .focus-item {
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.07) !important;
}

.zone::before,
.zone::after,
.feat::before,
.stat-card::before,
.sidebar::before {
  display: none !important;
}

.zone,
.feat,
.char {
  content-visibility: auto;
  contain-intrinsic-size: 260px;
}

.zone:hover,
.feat:hover,
.char:hover,
.stat-card:hover,
.quick-btn:hover,
.hero-btn:hover,
.panel button:hover,
.delete-btn:hover,
.nav-btn:hover {
  transform: none !important;
}

.theme-toggle:hover {
  transform: scale(1.04) !important;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.34);
  background: rgba(96, 165, 250, 0.1);
  color: #93c5fd;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip.is-connected {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.footer-links,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 13px;
}

.footer-links {
  margin-top: 10px;
}

.footer-links a,
.app-footer a {
  color: #22c55e;
  text-decoration: none;
}

.discord-link {
  border: 1px solid rgba(88, 101, 242, 0.42);
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.14);
  color: #a5b4fc !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  padding: 7px 12px;
}

.hero-btn.discord-link {
  border-radius: 10px;
  min-height: 44px;
  padding: 12px 18px;
}

.discord-redirect {
  align-items: center;
  background: linear-gradient(135deg, #020617, #111827);
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.discord-card {
  width: min(560px, 100%);
  border: 1px solid rgba(88, 101, 242, 0.34);
  border-radius: 12px;
  background: rgba(10, 16, 30, 0.92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  color: #e5e7eb;
  margin: 0 auto;
  padding: 30px;
}

.discord-kicker {
  color: #a5b4fc;
  font-weight: 900;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.discord-card h1 {
  color: #f8fafc;
  font-size: 36px;
  margin-bottom: 12px;
}

.discord-card p {
  color: #cbd5e1;
  line-height: 1.6;
}

.discord-big-button {
  display: inline-flex;
  border: 1px solid rgba(88, 101, 242, 0.42);
  border-radius: 10px;
  background: rgba(88, 101, 242, 0.16);
  color: #c7d2fe;
  font-weight: 900;
  margin-top: 18px;
  padding: 11px 14px;
  text-decoration: none;
}

.app-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 28px;
  padding: 18px 8px 4px;
}

.page-footer {
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 18px 28px;
}

body.light-mode .app-footer {
  border-top-color: rgba(15, 23, 42, 0.1);
}

body.light-mode .account-chip {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}

body.light-mode .account-chip.is-connected {
  color: #15803d;
  background: rgba(22, 163, 74, 0.1);
}

.maintenance-lock {
  min-height: 100vh;
}

.maintenance-screen {
  align-items: center;
  background: linear-gradient(135deg, #020617, #0f172a);
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.maintenance-card {
  width: min(560px, 100%);
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 12px;
  background: rgba(10, 16, 30, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  color: #e5e7eb;
  margin: 0 auto;
  padding: 30px;
}

.maintenance-kicker {
  color: #22c55e;
  font-weight: 900;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.maintenance-card h1 {
  color: #f8fafc;
  font-size: 36px;
  margin-bottom: 12px;
}

.maintenance-card p {
  color: #cbd5e1;
  line-height: 1.6;
}

.maintenance-card a {
  display: inline-flex;
  border: 1px solid rgba(34, 197, 94, 0.32);
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  font-weight: 800;
  margin-top: 18px;
  padding: 11px 14px;
  text-decoration: none;
}

.create-panel {
  padding: 0 !important;
  overflow: hidden;
}

.create-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 15px 18px;
  color: #22c55e;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.create-panel summary::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
  font-size: 18px;
  line-height: 1;
}

.create-panel[open] summary {
  border-bottom: 1px solid rgba(34, 197, 94, 0.16);
}

.create-panel[open] summary::after {
  content: "-";
}

.create-content {
  padding: 12px 18px 18px;
}

.create-content > :first-child {
  margin-top: 0 !important;
}

.toolbar-split {
  justify-content: space-between;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.reset-actions {
  margin-left: auto;
}

.reset-actions button {
  border-color: rgba(96, 165, 250, 0.35) !important;
  background: rgba(96, 165, 250, 0.1) !important;
  color: #93c5fd !important;
}

body.light-mode .create-panel summary::after {
  color: #15803d;
  background: rgba(22, 163, 74, 0.1);
}

body.light-mode .reset-actions button {
  color: #2563eb !important;
  background: rgba(37, 99, 235, 0.08) !important;
}

@media (max-width: 760px) {
  html,
  body {
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body {
    font-size: 15px;
  }

  .navbar {
    position: sticky !important;
    top: 0;
    padding: 10px 12px !important;
  }

  .nav-container {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 10px;
  }

  .nav-brand {
    font-size: 20px !important;
    text-align: center;
  }

  .nav-links {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100%;
  }

  .nav-btn {
    min-height: 42px;
    padding: 9px 10px !important;
    border-radius: 9px !important;
    font-size: 12px !important;
    text-align: center;
    white-space: normal;
  }

  .nav-theme-toggle {
    justify-content: center;
    flex-wrap: wrap;
  }

  .account-chip {
    max-width: 100%;
  }

  .home-btn {
    width: auto !important;
    min-width: 92px;
  }

  .theme-toggle {
    width: 42px !important;
    height: 42px !important;
  }

  .app {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-height: none !important;
    padding: 16px !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(34, 197, 94, 0.18);
    box-shadow: none !important;
  }

  .sidebar h2 {
    font-size: 20px !important;
  }

  .sidebar input,
  .panel input,
  .panel select,
  .note-field,
  .task-edit-row input,
  .task-edit-row select,
  .account-panel input {
    min-height: 44px;
    font-size: 16px !important;
  }

  .menu {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
  }

  .menu button {
    min-height: 42px;
    padding: 9px 10px !important;
    text-align: center !important;
    font-size: 12px !important;
  }

  .hint {
    margin-top: 0 !important;
  }

  .main,
  .hub-container,
  .settings-shell,
  .account-shell {
    padding: 16px !important;
    overflow: visible !important;
  }

  .hero {
    padding: 26px 16px !important;
    margin-bottom: 24px !important;
    border-radius: 12px !important;
  }

  .hero-content h1,
  .settings-hero h1,
  .account-hero h1 {
    font-size: 30px !important;
    line-height: 1.1;
  }

  .hero-content p,
  .settings-hero p,
  .account-hero p {
    font-size: 15px !important;
  }

  .hero-metrics,
  .stats-grid,
  .summary-grid,
  .settings-grid,
  .account-grid,
  .management-grid,
  .list {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .hero-buttons {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .hero-btn {
    width: 100%;
    min-height: 46px;
    padding: 12px 16px !important;
  }

  .stat-card {
    align-items: flex-start !important;
    gap: 14px !important;
    padding: 16px !important;
    border-radius: 12px !important;
  }

  .stat-icon {
    width: 48px !important;
    height: 48px !important;
    font-size: 20px !important;
  }

  .stat-number {
    font-size: 30px !important;
  }

  .panel,
  .zone,
  .feat,
  .char,
  .settings-panel,
  .account-panel,
  .management-panel,
  .summary-card {
    border-radius: 12px !important;
    padding: 16px !important;
  }

  .create-panel {
    padding: 0 !important;
  }

  .create-panel summary {
    min-height: 50px;
    padding: 14px 16px;
  }

  .create-content {
    padding: 12px 16px 16px;
  }

  .toggles,
  .mini-progress,
  .split-actions,
  .counter-row,
  .task-edit-row {
    grid-template-columns: 1fr !important;
  }

  .toggles {
    display: grid !important;
  }

  .row {
    gap: 12px;
    min-height: 44px;
    align-items: center;
  }

  .task-row span:first-child {
    align-items: flex-start !important;
  }

  .card-head {
    align-items: flex-start !important;
    flex-direction: column;
  }

  .pill,
  .priority {
    max-width: 100%;
  }

  .toolbar-split,
  .toolbar,
  .toolbar-group,
  .panel-actions,
  .data-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .reset-actions {
    margin-left: 0;
  }

  .toolbar button,
  .toolbar-group button,
  .panel-actions button,
  .data-actions button,
  .import-btn,
  .account-panel button,
  .settings-panel button,
  .delete-btn {
    width: 100%;
    min-height: 44px;
  }

  .focus-item {
    align-items: flex-start !important;
    flex-direction: column;
  }

  #remote-output {
    max-width: 100%;
    overflow-x: auto;
  }

  .app-footer,
  .footer-links {
    align-items: center;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .nav-links,
  .menu {
    grid-template-columns: 1fr !important;
  }

  .main,
  .hub-container,
  .settings-shell,
  .account-shell {
    padding: 12px !important;
  }

  .stat-card {
    flex-direction: column;
  }
}

input[type="checkbox"]:checked + label::after {
  animation: none !important;
}

.row input[type="checkbox"],
input[type="checkbox"] + label::before,
input[type="checkbox"].toggle + label::before,
input[type="checkbox"].toggle + label::after {
  box-shadow: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
