:root {
  color-scheme: dark;
  --bg-glow: #141b2f;
  --bg: #0b101d;
  --bg-deep: #070b14;
  --surface: rgba(15, 20, 34, 0.9);
  --surface-strong: #121826;
  --surface-raised: rgba(22, 28, 45, 0.92);
  --surface-accent: rgba(79, 139, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1ff;
  --muted: #97a2c9;
  --accent: #4f8bff;
  --accent-strong: #2a63ff;
  --accent-contrast: #0a0f1f;
  --shadow: 0 18px 32px rgba(4, 8, 20, 0.35);
  --shadow-soft: 0 10px 20px rgba(5, 10, 24, 0.25);
  --radius: 20px;
  --success: #22c55e;
  --danger: #ef4444;
  --vultr-accent: #a78bfa;
  --vultr-glow: rgba(167, 139, 250, 0.3);
  --mac-accent: #4ade80;
  --mac-glow: rgba(74, 222, 128, 0.3);
  --star-color: #fbbf24;
  --font-title: Fraunces, serif;
  --font-body: Manrope, sans-serif;
  --font-mono: JetBrains Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
}

.theme-light {
  color-scheme: light;
  --bg-glow: #ffffff;
  --bg: #f6f7fa;
  --bg-deep: #edf0f5;
  --surface: #ffffff;
  --surface-strong: #f3f5fa;
  --surface-raised: #ffffff;
  --surface-accent: rgba(47, 101, 255, 0.08);
  --border: rgba(25, 30, 45, 0.12);
  --text: #1a1f2f;
  --muted: #5f677d;
  --accent: #2f65ff;
  --accent-strong: #1f4fd6;
  --accent-contrast: #f8f9ff;
  --shadow: 0 22px 40px rgba(22, 24, 34, 0.12);
  --shadow-soft: 0 12px 24px rgba(24, 28, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(circle at top left, var(--bg-glow) 0%, var(--bg) 45%, var(--bg-deep) 100%);
  display: flex;
  flex-direction: column;
}

body.theme-light {
  color-scheme: light;
}

a {
  color: inherit;
}

.texture {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(rgba(79, 139, 255, 0.12) 1px, transparent 1px);
  background-size: 26px 26px, 64px 64px;
  background-position: 0 0, 16px 12px;
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}

.topbar {
  max-width: 1240px;
  margin: 16px auto 8px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 12px 24px rgba(79, 139, 255, 0.35);
}

.logo__text {
  font-family: var(--font-title);
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.topbar__search {
  flex: 1 1 220px;
  max-width: 320px;
  min-width: 0;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--muted);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
}

.icon-button {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--muted);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-button.active {
  color: var(--success);
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.12);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
}

.layout {
  max-width: 1440px;
  margin: 20px auto 80px;
  padding: 0 16px;
  display: grid;
  gap: 32px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 28px;
  align-items: center;
  padding: 32px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: rise 0.8s ease both;
}

.hero__content {
  display: grid;
  gap: 12px;
}

.hero__eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--muted);
}

.hero h1 {
  font-family: var(--font-title);
  font-size: clamp(28px, 4vw, 40px);
  margin: 0;
}

.hero__lead {
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.hero__card {
  background: var(--surface-strong);
  border-radius: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  display: grid;
  gap: 14px;
}

.hero__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 0;
}

.hero__hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.search-container {
  position: relative;
}

.search-input {
  width: 100%;
  min-width: 0;
  padding: 14px 20px;
  font-size: 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--surface-accent);
}

.section {
  display: grid;
  gap: 16px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-title svg {
  width: 18px;
  height: 18px;
}

.add-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  margin-left: 8px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.add-btn:hover {
  color: var(--success);
  transform: scale(1.08);
}

.add-btn svg {
  width: 20px;
  height: 20px;
}

.app-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

#favoritesList {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.app-card {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 44px 12px 14px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  backdrop-filter: blur(12px);
  gap: 12px;
  position: relative;
}

.app-card.draggable {
  cursor: grab;
}

.app-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.drop-placeholder {
  border: 2px dashed var(--accent);
  background: var(--surface-accent);
  border-radius: 12px;
  height: 100%;
  min-height: 58px;
}

.app-card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 139, 255, 0.45);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

.app-list.drag-active .app-card:hover {
  transform: none;
  box-shadow: none;
}

.app-card.vultr:hover {
  border-color: var(--vultr-accent);
  box-shadow: 0 12px 24px var(--vultr-glow);
}

.app-card.mac:hover {
  border-color: var(--mac-accent);
  box-shadow: 0 12px 24px var(--mac-glow);
}

.tag-badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-accent);
  color: var(--accent);
  border: 1px solid rgba(79, 139, 255, 0.25);
  flex-shrink: 0;
}

.tag-badge.vultr {
  background: rgba(167, 139, 250, 0.14);
  color: var(--vultr-accent);
  border-color: rgba(167, 139, 250, 0.35);
}

.tag-badge.mac {
  background: rgba(74, 222, 128, 0.14);
  color: var(--mac-accent);
  border-color: rgba(74, 222, 128, 0.35);
}

.app-name {
  flex: 1 1 auto;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.app-name:focus {
  outline: 2px solid var(--accent);
  background: rgba(7, 10, 18, 0.5);
  white-space: normal;
  overflow: visible;
}

.action-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 10;
  transition: transform 0.2s ease, color 0.2s ease;
  pointer-events: auto;
}

.action-btn:hover {
  transform: translateY(-50%) scale(1.1);
}

.action-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  fill: transparent;
  stroke: currentColor;
}

.star-btn {
  color: var(--muted);
  display: block;
}

.star-btn:hover {
  color: var(--text);
}

.star-btn.active {
  color: var(--star-color);
}

.star-btn.active svg {
  fill: var(--star-color);
  stroke: var(--star-color);
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
}

.delete-btn {
  color: var(--danger);
  display: none;
}

.delete-btn:hover {
  color: #ff6b6b;
}

body.editing .app-card {
  cursor: default;
  pointer-events: none;
}

body.editing .app-card .app-name {
  pointer-events: auto;
  border-bottom: 1px dashed var(--accent);
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  cursor: text;
}

body.editing .app-card:hover {
  transform: none;
  box-shadow: none;
}

body.editing .star-btn {
  display: none !important;
}

body.editing .delete-btn {
  display: block !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: min(92vw, 420px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.modal h3 {
  font-family: var(--font-title);
  margin: 0;
  font-size: 1.3rem;
}

.modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-family: var(--font-body);
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-cancel {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-confirm {
  background: var(--success);
  color: #04140b;
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 10px 20px rgba(239, 68, 68, 0.25);
}

.btn-confirm:hover,
.btn-danger:hover {
  transform: scale(1.03);
}

.hidden {
  display: none !important;
}

footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: auto;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 3px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .app-list,
  #favoritesList {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-list,
  #favoritesList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar__search {
    flex-basis: 180px;
    max-width: 260px;
  }
}

@media (max-width: 720px) {
  .layout {
    margin-top: 12px;
  }

  .hero {
    padding: 24px;
  }

  .topbar {
    gap: 8px;
  }

  .logo__mark {
    display: none;
  }

  .logo__text {
    font-size: 16px;
  }

  .topbar__actions {
    gap: 8px;
  }

  .topbar__search {
    flex-basis: 140px;
    max-width: 200px;
  }

  .app-list,
  #favoritesList {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero {
    animation: none;
  }

  .app-card,
  .theme-toggle,
  .icon-button,
  .btn {
    transition: none;
  }
}
