:root {
  --bg: #1c1f24;
  --bar: #2a2f36;
  --bar2: #232730;
  --text: #e9edf2;
  --muted: #b7c0cc;
  --accent: #4c86ff;
  --shadow: 0 18px 45px rgba(0, 0, 0, .45);
}

/* Base */
html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% 0%, rgba(76, 134, 255, .18), transparent 60%),
    radial-gradient(900px 500px at 10% 25%, rgba(255, 88, 88, .12), transparent 55%),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, var(--bar), var(--bar2));
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}

.topbar .inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.tab {
  position: relative;
  background: transparent;
  border: 0;
  color: rgba(233, 237, 242, .9);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 2px;
  cursor: pointer;
  opacity: .85;
}

.tab:hover {
  opacity: 1;
}

.tab.active {
  opacity: 1;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(76, 134, 255, .15);
}

.tabPlus {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  color: rgba(233, 237, 242, .92);
  font-weight: 900;
  cursor: pointer;
}

.tabPlus:hover {
  filter: brightness(1.08);
}

/* Icon buttons */
.iconbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  color: rgba(233, 237, 242, .92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.iconbtn:hover {
  filter: brightness(1.08);
}

.iconbtn svg {
  width: 18px;
  height: 18px;
  opacity: .9
}

/* Main */
.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 18px 42px;
}

/* Search pill */
.searchWrap {
  display: flex;
  justify-content: center;
  margin: 18px 0 28px;
}

.searchPill {
  width: min(900px, calc(100vw - 36px));
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 999px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  backdrop-filter: blur(10px);
}

.searchPill .lens {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 9px;
  flex: 0 0 auto;
}

.searchPill input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 14px;
}

.searchPill input::placeholder {
  color: rgba(233, 237, 242, .62);
}

/* Tiles grid */
.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 1280px) {
  .grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tile {
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .40);
  cursor: grab;
  user-select: none;
  transform: translateZ(0);
  transition: transform .06s ease, filter .06s ease;
}

.tile:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.tile:active {
  cursor: grabbing;
  transform: translateY(-1px);
}

.thumb {
  aspect-ratio: 16 / 11;
  background: linear-gradient(135deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .favicon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  backdrop-filter: blur(6px);
}

.thumb .favicon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .35));
}

/* Hover actions (Edit/Delete) */
.thumb .actions {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .12s ease, transform .12s ease;
  pointer-events: none;
}

.tile:hover .thumb .actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.actbtn {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  cursor: pointer;
  padding: 0;
}

.actbtn:hover {
  filter: brightness(1.12);
}

.actbtn svg {
  width: 16px;
  height: 16px;
  opacity: .92;
}

.labelBar {
  padding: 10px 12px;
  background: rgba(0, 0, 0, .35);
  border-top: 1px solid rgba(255, 255, 255, .10);
  display: flex;
  align-items: center;
  gap: 8px;
}

.labelBar .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .14);
  flex: 0 0 auto;
}

.labelBar .title {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .2px;
  color: rgba(233, 237, 242, .92);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

/* DnD hints */
.drop-hint {
  outline: 2px dashed rgba(76, 134, 255, .75);
  outline-offset: 4px;
}

.tab-drop-active {
  outline: 2px solid rgba(76, 134, 255, .85);
  outline-offset: 2px;
  border-radius: 14px;
}

/* Bootstrap dark modals */
.modal-content {
  background: rgba(35, 39, 48, .98);
  border: 1px solid rgba(255, 255, 255, .10);
  color: var(--text);
  box-shadow: var(--shadow);
  border-radius: 18px;
}

.modal-header,
.modal-footer {
  border-color: rgba(255, 255, 255, .10) !important;
}

.form-control,
.form-select {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--text);
}

.form-control::placeholder {
  color: rgba(233, 237, 242, .55);
}

.form-control:focus,
.form-select:focus {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(76, 134, 255, .5);
  box-shadow: 0 0 0 .25rem rgba(76, 134, 255, .15);
  color: var(--text);
}

.btn-outline-light {
  border-color: rgba(255, 255, 255, .18);
  color: rgba(233, 237, 242, .92);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, .10);
  border-color: rgba(255, 255, 255, .22);
}

.hint {
  color: rgba(233, 237, 242, .65);
  font-size: .85rem;
}

.storageLine {
  margin-top: 18px;
  text-align: center;
  color: rgba(233, 237, 242, .55);
  font-size: .85rem;
}

/* Greeting + Weather row */
.greetingRow {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  margin: 6px auto 10px;
  max-width: 1100px;
}

.greetingText {
  font-size: 28px;
  font-weight: 850;
  letter-spacing: .2px;
  line-height: 1.15;
  color: rgba(233, 237, 242, .92);
  flex: 1 1 auto;
  padding: 10px 6px 0;
}

.weatherCard {
  min-width: 240px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .30);
  backdrop-filter: blur(10px);
}

.weatherTop {
  display: flex;
  gap: 12px;
  align-items: center;
}

.weatherIcon {
  font-size: 28px;
}

.weatherTemp {
  font-size: 22px;
  font-weight: 850;
}

.weatherMeta {
  color: rgba(233, 237, 242, .65);
  font-size: .85rem;
  margin-top: -2px;
}

@media (max-width: 820px) {
  .greetingRow {
    flex-direction: column;
  }

  .weatherCard {
    min-width: unset;
  }

  .greetingText {
    font-size: 24px;
  }
}

/* Favorites star button styling */
.actbtn.starred {
  border-color: rgba(255, 215, 0, .45);
}

.actbtn.starred svg path,
.actbtn.starred svg polygon {
  fill: rgba(255, 215, 0, .9);
  stroke: rgba(255, 215, 0, .9);
}

/* Theme: Day mode overrides */
.theme-day {
  --bg: #eef2f7;
  --bar: #ffffff;
  --bar2: #f3f5f8;
  --text: #111827;
  --muted: #4b5563;
  --accent: #2563eb;
}

.theme-day body {
  background: radial-gradient(1200px 600px at 50% 0%, rgba(37, 99, 235, .12), transparent 60%),
    radial-gradient(900px 500px at 10% 25%, rgba(255, 88, 88, .08), transparent 55%),
    var(--bg);
  color: var(--text);
}

.theme-day .topbar {
  border-bottom: 1px solid rgba(0, 0, 0, .08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
}

.theme-day .tab {
  color: rgba(17, 24, 39, .85);
}

.theme-day .iconbtn {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .08);
  color: rgba(17, 24, 39, .85);
}

.theme-day .searchPill {
  background: rgba(255, 255, 255, .82);
  border-color: rgba(0, 0, 0, .08);
}

.theme-day .searchPill input {
  color: rgba(17, 24, 39, .92);
}

.theme-day .greetingText {
  color: rgba(17, 24, 39, .92);
}

.theme-day .weatherCard {
  background: rgba(255, 255, 255, .85);
  border-color: rgba(0, 0, 0, .08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .10);
}

.theme-day .weatherMeta,
.theme-day .hint,
.theme-day .storageLine {
  color: rgba(17, 24, 39, .60);
}

.theme-day .tile {
  background: rgba(255, 255, 255, .75);
  border-color: rgba(0, 0, 0, .08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .12);
}

.theme-day .labelBar {
  background: rgba(255, 255, 255, .72);
  border-top-color: rgba(0, 0, 0, .08);
}

.theme-day .labelBar .title {
  color: rgba(17, 24, 39, .90);
}

.theme-day .thumb .favicon,
.theme-day .actbtn {
  background: rgba(255, 255, 255, .72);
  border-color: rgba(0, 0, 0, .12);
}

/* Favorites tab section headers */
.favSection {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px 2px;
  margin-top: 2px;
}

.favSection .left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badgePill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
  color: rgba(233, 237, 242, .86);
  font-weight: 800;
  font-size: 12px;
}

.theme-day .badgePill {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .08);
  color: rgba(17, 24, 39, .82);
}

.favSection .count {
  color: rgba(233, 237, 242, .55);
  font-size: .85rem;
  font-weight: 700;
}

.theme-day .favSection .count {
  color: rgba(17, 24, 39, .55);
}

/* Engines manager list */
.engineRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .10);
  margin-bottom: 8px;
}

.engineRow .meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.engineBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
}

.engineName {
  font-weight: 800;
}

.engineUrl {
  color: rgba(233, 237, 242, .55);
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.theme-day .engineRow {
  background: rgba(0, 0, 0, .03);
  border-color: rgba(0, 0, 0, .08);
}

.theme-day .engineBadge {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .08);
}

.theme-day .engineUrl {
  color: rgba(17, 24, 39, .55);
}

/* Theme-day: make modals light */
.theme-day .modal-content {
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(0, 0, 0, .10);
  color: rgba(17, 24, 39, .92);
  box-shadow: 0 18px 45px rgba(0, 0, 0, .14);
}

.theme-day .modal-header,
.theme-day .modal-footer {
  border-color: rgba(0, 0, 0, .10) !important;
}

.theme-day .btn-close.btn-close-white {
  filter: invert(1) grayscale(1);
}

.theme-day .form-control,
.theme-day .form-select {
  background: rgba(0, 0, 0, .02);
  border: 1px solid rgba(0, 0, 0, .14);
  color: rgba(17, 24, 39, .92);
}

.theme-day .form-control::placeholder {
  color: rgba(17, 24, 39, .45);
}

.theme-day .btn-outline-light {
  border-color: rgba(0, 0, 0, .16);
  color: rgba(17, 24, 39, .86);
}

.theme-day .btn-outline-light:hover {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .20);
}

.theme-day .hint {
  color: rgba(17, 24, 39, .60);
}

.theme-day .searchPill .lens {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .10);
}

.theme-day .iconbtn svg,
.theme-day .tabPlus {
  color: rgba(17, 24, 39, .86);
}

.theme-day .topbar .inner {
  color: rgba(17, 24, 39, .92);
}

.theme-day .tab.active::after {
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, .18);
}

.theme-day .thumb .favicon img {
  filter: none;
}

/* --- Contrast fixes (Day mode) --- */

/* Search input text & placeholder */
.theme-day .searchPill input {
  color: rgba(17, 24, 39, .92) !important;
}

.theme-day .searchPill input::placeholder {
  color: rgba(17, 24, 39, .55) !important;
}

.theme-day .searchPill .lens {
  color: rgba(17, 24, 39, .65);
}

/* Tile hover action buttons (icons + background) */
.theme-day .thumb .actions .actbtn {
  background: rgba(255, 255, 255, .85);
  border-color: rgba(0, 0, 0, .18);
}

.theme-day .thumb .actions .actbtn svg {
  stroke: rgba(17, 24, 39, .85);
}

.theme-day .thumb .actions .actbtn:hover {
  background: rgba(255, 255, 255, .95);
}

/* Favorite star (active) */
.theme-day .actbtn.starred {
  background: rgba(255, 215, 0, .25);
  border-color: rgba(255, 215, 0, .45);
}

.theme-day .actbtn.starred svg {
  stroke: rgba(120, 90, 0, .95);
}

/* Tile label text */
.theme-day .labelBar .title {
  color: rgba(17, 24, 39, .92);
}

/* Day mode: strong contrast for tile action icons */
.theme-day .thumb .actions .actbtn {
  background: rgba(255, 255, 255, .95) !important;
  border-color: rgba(0, 0, 0, .28) !important;
}

.theme-day .thumb .actions .actbtn svg path {
  stroke: rgba(0, 0, 0, .95) !important;
}

/* Add-tile card */
.add-tile .thumb {
  background: rgba(255, 255, 255, .08);
  border: 2px dashed rgba(255, 255, 255, .25);
}

.theme-day .add-tile .thumb {
  background: rgba(0, 0, 0, .03);
  border-color: rgba(0, 0, 0, .25);
}

.add-tile svg {
  opacity: .9;
}

/* Day mode: action icon contrast (hover buttons) */
.theme-day .thumb .actions .actbtn {
  color: rgba(17, 24, 39, .88);
}

.theme-day .thumb .actions .actbtn svg * {
  stroke: currentColor !important;
  fill: none !important;
}

.theme-day .thumb .actions .actbtn.starred svg * {
  fill: rgba(255, 215, 0, .95) !important;
  stroke: rgba(255, 215, 0, .95) !important;
}

/* Plus tile */
.addTileTile .addThumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .05);
}

.addTileTile .addIconWrap {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .06);
  border: 1px dashed rgba(255, 255, 255, .18);
}

.addTileTile svg {
  width: 30px;
  height: 30px;
  color: rgba(233, 237, 242, .78);
}

.addTileTile:hover .addIconWrap {
  background: rgba(255, 255, 255, .09);
  border-color: rgba(255, 255, 255, .28);
}

.theme-day .addTileTile .addThumb {
  background: rgba(0, 0, 0, .02);
}

.theme-day .addTileTile .addIconWrap {
  background: rgba(255, 255, 255, .92);
  border-color: rgba(0, 0, 0, .16);
}

.theme-day .addTileTile svg {
  color: rgba(17, 24, 39, .82);
}

/* Fix settings icon alignment */
.iconbtn svg {
  display: block;
  margin: auto;
}

/* Day mode: make hover action icons darker */
.theme-day .thumb .actions .actbtn {
  color: rgba(0, 0, 0, .88);
}

.theme-day .thumb .actions .actbtn svg * {
  stroke: rgba(0, 0, 0, .88) !important;
}

/* Header icon alignment tweaks */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.iconbtn svg {
  display: block;
  width: 20px;
  height: 20px;
}

#btnSettings svg {
  transform: translateY(0.5px);
}

/* Title bar: favicon next to title */
.labelBar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.labelBar .dot {
  display: none;
}

.titleFavicon {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: block;
  flex: 0 0 auto;
  opacity: .95;
}

/* Corner delete button (minus) */
.cornerDel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .16);
  color: rgba(233, 237, 242, .85);
  cursor: pointer;
}

.cornerDel svg {
  width: 18px;
  height: 18px;
}

.tile:hover .cornerDel {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .22);
}

.theme-day .cornerDel {
  background: rgba(255, 255, 255, .98);
  border-color: rgba(0, 0, 0, .16);
  color: rgba(0, 0, 0, .85);
}

.theme-day .tile:hover .cornerDel {
  background: rgba(255, 255, 255, .98);
  border-color: rgba(0, 0, 0, .20);
}

/* Top-left edit + favorite buttons */
.editFavWrap {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  z-index: 3;
}

.editFavWrap .actbtn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

/* Favorite star filled */
.editFavWrap .favBtn.starred svg path {
  fill: gold;
  stroke: gold;
}

/* Tile controls always visible (top-left) */
.thumb .actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.actions.editFavWrap {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.theme-day .editFavWrap .actbtn {
  color: rgba(0, 0, 0, .90);
  border-color: rgba(0, 0, 0, .18);
  background: rgba(255, 255, 255, .88);
}

.theme-day .editFavWrap .actbtn svg * {
  stroke: currentColor !important;
  fill: none !important;
}

/* Tile action icons: only visible on hover */
.thumb .actions {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.tile:hover .thumb .actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Consistent icon style */
.thumb .actions .actbtn svg {
  width: 18px;
  height: 18px;
}

/* Delete button uses same visibility rules as other tile actions */
.thumb .actions .actbtn.delete {
  opacity: inherit;
}

/* Ensure NO action buttons are visible without hover */
.thumb .actions,
.thumb .actions .actbtn {
  opacity: 0;
  pointer-events: none;
}

.tile:hover .thumb .actions,
.tile:hover .thumb .actions .actbtn {
  opacity: 1;
  pointer-events: auto;
}

/* Normalize all action buttons appearance */
.thumb .actions .actbtn {
  background: rgba(255, 255, 255, .75);
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-day .thumb .actions .actbtn {
  background: rgba(255, 255, 255, .9);
}

/* Delete button (top-right) matches other action buttons and only shows on hover */
.thumb .cornerDel {
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.tile:hover .thumb .cornerDel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Ensure delete icon uses same style */
.cornerDel svg {
  width: 18px;
  height: 18px;
  display: block;
}

.cornerDel svg * {
  stroke: currentColor !important;
  fill: none !important;
}

/* Normalize ALL action buttons (star, edit, delete) */
.thumb .actions .actbtn,
.thumb .cornerDel.actbtn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .30);
  border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(6px);
}

/* Hover */
.thumb .actions .actbtn:hover,
.thumb .cornerDel.actbtn:hover {
  background: rgba(255, 255, 255, .45);
}

/* Icons identical */
.thumb .actions .actbtn svg,
.thumb .cornerDel.actbtn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Unified dark action buttons (edit, favorite, delete) in both themes */
.thumb .actions .actbtn,
.thumb .cornerDel.actbtn {
  background: rgba(0, 0, 0, .65) !important;
  border: 1px solid rgba(255, 255, 255, .25) !important;
  color: #fff !important;
}

.thumb .actions .actbtn svg *,
.thumb .cornerDel.actbtn svg * {
  stroke: #fff !important;
  fill: none !important;
}

/* Hover emphasis */
.tile:hover .thumb .actions .actbtn,
.tile:hover .thumb .cornerDel.actbtn {
  background: rgba(0, 0, 0, .8) !important;
}

/* Smaller action buttons: 24x24px, white icons in all modes */
.thumb .actions .actbtn,
.thumb .cornerDel.actbtn {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px;
  min-height: 24px;
  border-radius: 8px !important;
  padding: 0 !important;

  background: rgba(0, 0, 0, .7) !important;
  border: 1px solid rgba(255, 255, 255, .25) !important;
  color: #fff !important;
}

.thumb .actions .actbtn svg,
.thumb .cornerDel.actbtn svg {
  width: 14px;
  height: 14px;
}

.thumb .actions .actbtn svg *,
.thumb .cornerDel.actbtn svg * {
  stroke: #fff !important;
  fill: none !important;
}

/* Hover */
.tile:hover .thumb .actions .actbtn,
.tile:hover .thumb .cornerDel.actbtn {
  background: rgba(0, 0, 0, .85) !important;
}

/* Favorite star: always yellow when active (day + night) */
.thumb .actions .actbtn.starred {
  background: rgba(0, 0, 0, .7) !important;
}

.thumb .actions .actbtn.starred svg *,
.theme-day .thumb .actions .actbtn.starred svg * {
  stroke: #facc15 !important;
  fill: #facc15 !important;
}

/* Force edit + favorite icons to white in day mode */
.theme-day .thumb .actions .actbtn svg *,
.theme-day .thumb .cornerDel.actbtn svg * {
  stroke: #fff !important;
  fill: none !important;
}

/* Action buttons: opacity and hover */
.thumb .actions .actbtn,
.thumb .cornerDel.actbtn {
  opacity: .8 !important;
}

.tile:hover .thumb .actions .actbtn,
.tile:hover .thumb .cornerDel.actbtn {
  opacity: 1 !important;
}

/* FORCE white icons in DAY mode (strong specificity) */
.theme-day .tile .thumb .actions .actbtn,
.theme-day .tile .thumb .cornerDel.actbtn {
  color: #fff !important;
}

.theme-day .tile .thumb .actions .actbtn svg,
.theme-day .tile .thumb .cornerDel.actbtn svg {
  color: #fff !important;
}

.theme-day .tile .thumb .actions .actbtn svg *,
.theme-day .tile .thumb .cornerDel.actbtn svg * {
  stroke: #fff !important;
  fill: none !important;
}

/* Keep starred favorite yellow in both modes (overrides white) */
.theme-day .tile .thumb .actions .actbtn.starred,
.tile .thumb .actions .actbtn.starred {
  color: #ffd54a !important;
}

.theme-day .tile .thumb .actions .actbtn.starred svg *,
.tile .thumb .actions .actbtn.starred svg * {
  stroke: #ffd54a !important;
  fill: #ffd54a !important;
}

/* Action buttons visibility logic */
/* Default: hidden */
.thumb .actions .actbtn,
.thumb .cornerDel.actbtn {
  opacity: 0 !important;
  pointer-events: none;
}

/* Hover tile: show buttons with opacity 0.8 */
.tile:hover .thumb .actions .actbtn,
.tile:hover .thumb .cornerDel.actbtn {
  opacity: .8 !important;
  pointer-events: auto;
}

/* Hover button: full opacity */
.thumb .actions .actbtn:hover,
.thumb .cornerDel.actbtn:hover {
  opacity: 1 !important;
}

/* Modal color scheme (matches v21 look) */
.modal-content {
  background: rgba(17, 24, 39, .96);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(233, 237, 242, .92);
}

.modal-header,
.modal-footer {
  border-color: rgba(255, 255, 255, .10) !important;
}

.modal .form-label {
  color: rgba(233, 237, 242, .75);
}

.modal .form-control,
.modal .form-select {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(233, 237, 242, .92);
}

.modal .form-control::placeholder {
  color: rgba(233, 237, 242, .45);
}

.theme-day .modal-content {
  background: rgba(255, 255, 255, .98);
  border-color: rgba(0, 0, 0, .10);
  color: rgba(17, 24, 39, .92);
}

.theme-day .modal-header,
.theme-day .modal-footer {
  border-color: rgba(0, 0, 0, .10) !important;
}

.theme-day .modal .form-label {
  color: rgba(17, 24, 39, .70);
}

.theme-day .modal .form-control,
.theme-day .modal .form-select {
  background: rgba(0, 0, 0, .02);
  border-color: rgba(0, 0, 0, .14);
  color: rgba(17, 24, 39, .92);
}

.theme-day .modal .form-control::placeholder {
  color: rgba(17, 24, 39, .45);
}

/* Tabs in modal */
.modal .settingsTabs {
  border-bottom: 1px solid rgba(255, 255, 255, .10);
}

.theme-day .modal .settingsTabs {
  border-bottom-color: rgba(0, 0, 0, .10);
}

.modal .settingsTabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  font-weight: 800;
  color: rgba(233, 237, 242, .70);
  background: transparent;
  padding-left: 0;
  padding-right: 0;
  margin-right: 18px;
}

.modal .settingsTabs .nav-link.active {
  color: rgba(233, 237, 242, .95);
  border-bottom-color: var(--accent);
}

.theme-day .modal .settingsTabs .nav-link {
  color: rgba(17, 24, 39, .65);
}

.theme-day .modal .settingsTabs .nav-link.active {
  color: rgba(17, 24, 39, .92);
}

.modal .list-group-item {
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .10);
  color: rgba(233, 237, 242, .90);
}

.theme-day .modal .list-group-item {
  background: rgba(0, 0, 0, .02);
  border-color: rgba(0, 0, 0, .10);
  color: rgba(17, 24, 39, .92);
}

/* Settings Tabs */
.modal .settingsTabs {
  border-bottom: 1px solid rgba(255, 255, 255, .10);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.theme-day .modal .settingsTabs {
  border-bottom-color: rgba(0, 0, 0, .10);
}

.modal .settingsTabs .nav-link {
  border: 0 !important;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent !important;
  font-weight: 800;
  color: rgba(233, 237, 242, .70);
  padding: 8px 0;
}

.modal .settingsTabs .nav-link.active {
  color: rgba(233, 237, 242, .95);
  border-bottom-color: var(--accent);
}

.theme-day .modal .settingsTabs .nav-link {
  color: rgba(17, 24, 39, .65);
}

.theme-day .modal .settingsTabs .nav-link.active {
  color: rgba(17, 24, 39, .92);
}

/* Groups inline manager */
#groupsListInline .grp-handle {
  cursor: grab;
  user-select: none;
  opacity: .85;
}

#groupsListInline .list-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#groupsListInline .grp-name {
  font-weight: 800;
}

/* v50 Settings split view */
.settingsSplit {
  display: flex;
  min-height: 520px;
}

.settingsSide {
  width: 190px;
  flex: 0 0 190px;
  padding: 14px 12px;
  border-right: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .03);
}

.theme-day .settingsSide {
  border-right-color: rgba(0, 0, 0, .10);
  background: rgba(0, 0, 0, .02);
}

.settingsNavBtn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-weight: 850;
  color: rgba(233, 237, 242, .78);
}

.settingsNavBtn:hover {
  background: rgba(255, 255, 255, .06);
}

.settingsNavBtn.active {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .12);
  color: rgba(233, 237, 242, .95);
}

.theme-day .settingsNavBtn {
  color: rgba(17, 24, 39, .78);
}

.theme-day .settingsNavBtn:hover {
  background: rgba(0, 0, 0, .04);
}

.theme-day .settingsNavBtn.active {
  background: rgba(0, 0, 0, .03);
  border-color: rgba(0, 0, 0, .10);
  color: rgba(17, 24, 39, .92);
}

.settingsMain {
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px 18px;
}

.settingsPaneTitle {
  font-weight: 900;
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  .settingsSplit {
    flex-direction: column;
    min-height: auto;
  }

  .settingsSide {
    width: 100%;
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
  }

  .theme-day .settingsSide {
    border-bottom-color: rgba(0, 0, 0, .10);
  }
}

/* v54 wider settings modal */
#settingsModal .modal-dialog {
  max-width: 1200px;
}

/* inline group edit */
.grp-edit-input {
  width: 100%;
  max-width: 360px;
}

/* v57: make inline lists visible in settings modal */
#settingsModal #groupsListInline .list-group-item,
#settingsModal #enginesList .list-group-item {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .10);
  color: rgba(233, 237, 242, .92);
  border-radius: 14px;
  margin-bottom: 10px;
  padding: 10px;
}

.theme-day #settingsModal #groupsListInline .list-group-item,
.theme-day #settingsModal #enginesList .list-group-item {
  background: rgba(0, 0, 0, .03);
  border-color: rgba(0, 0, 0, .10);
  color: rgba(17, 24, 39, .92);
}

#settingsModal #groupsListInline .grp-name {
  color: inherit;
}

/* v60: ensure groups list has spacing even when empty */
#settingsModal #groupsListInline {
  margin-top: 12px;
}

/* Inline engine edit */
.eng-edit-input {
  width: 100%;
}

#settingsModal #enginesList .list-group-item {
  border-radius: 14px;
  margin-bottom: 10px;
}

/* v67: semantic helpers for settings panes */
.settingsHint {
  opacity: .78;
  font-size: .92rem;
  margin-bottom: .75rem;
}

.settingsSubTitle {
  font-weight: 800;
  margin-top: 1rem;
  margin-bottom: .5rem;
}

.settingsActions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}

.settingsRow {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.settingsRow.align-items-end {
  align-items: flex-end;
  margin-bottom: 10px;
}


/* Tile fallback (initials + color) */
.tile-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  border-radius: 12px;
  text-transform: uppercase;
  user-select: none;
}

/* Tile fallback badge (when no thumbnail) */
.thumbFallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  border-radius: 16px;
  user-select: none;
}