/* ─── RESET & BASE ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #7aa2ff;
  --accent-glow: rgba(122,162,255,0.35);
  --panel-bg: rgba(12,12,16,0.82);
  --panel-border: rgba(255,255,255,0.07);
  --text: rgba(255,255,255,0.92);
  --text-muted: rgba(255,255,255,0.38);
  --radius: 14px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-ui: 'Inter', system-ui, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--text);
  background: #0a0a0a;
}

/* ─── LAYERS ────────────────────────────────────────── */
#wallpaper {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  background-size: cover;
  background-position: center;
  transition: background-image 0.6s ease, background 0.6s ease;
  z-index: 0;
}

#overlay {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  background: rgba(0,0,0,0.28);
  z-index: 1;
  transition: backdrop-filter 0.4s ease, background 0.4s ease;
}

/* subtle film-grain noise */
#noise {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* ─── CLOCK ─────────────────────────────────────────── */
#top-left {
  position: absolute;
  top: 44px;
  left: 48px;
  z-index: 10;
  user-select: none;
}

#clock {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 400;
  letter-spacing: -1px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 32px rgba(0,0,0,0.5);
  transition: font-size 0.3s ease;
}

#date-line {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 4px;
}

#greeting {
  font-size: 15px;
  color: rgba(255,255,255,0.55);
  font-weight: 300;
}

/* ─── SEARCH ────────────────────────────────────────── */
#center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

#search-icon {
  position: absolute;
  left: 18px;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  transition: color 0.2s;
  z-index: 3;
}

#search {
  width: 480px;
  padding: 17px 20px 17px 50px;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.1);
  outline: none;
  font-size: 16px;
  font-family: var(--font-ui);
  font-weight: 400;
  background: rgba(255,255,255,0.07);
  color: white;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  caret-color: var(--accent);
  position: relative;
  z-index: 2;
}

#search::placeholder { color: transparent; }

#search:focus {
  transform: scale(1.02);
  background: rgba(255,255,255,0.12);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow), 0 20px 60px rgba(0,0,0,0.35);
}

#search:focus ~ #search-icon,
#search-wrap:focus-within #search-icon {
  color: var(--accent);
}

/* animated placeholder */
#placeholder-text {
  position: absolute;
  left: 50px;
  font-size: 16px;
  color: rgba(255,255,255,0.32);
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
  font-family: var(--font-ui);
  font-weight: 400;
  transition: opacity 0.2s;
}

#search-wrap:focus-within #placeholder-text,
#search-wrap.has-value #placeholder-text { opacity: 0; }

.typed-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: rgba(255,255,255,0.5);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 0.9s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ─── ENGINE PILLS ──────────────────────────────────── */
#engine-pills {
  display: flex;
  gap: 6px;
}

/* ADD — before or after the engine pills section */
#suggestions {
  position: absolute;
  top: calc(100% - 26px);
  left: 0;
  width: 100%;
  padding-top: 26px;
  background: rgba(12,12,20,0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0 0 24px 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  overflow-y: auto;
  display: none;
  z-index: 0;
  opacity: 0;
  max-height: 0;
  transform: translateY(-4px) scaleY(0.92);
  transform-origin: top center;
  transition: opacity 0.28s ease,
              transform 0.32s cubic-bezier(0.34,1.56,0.64,1),
              max-height 0.32s ease;
}

#suggestions.visible {
  opacity: 1;
  max-height: 360px;
  transform: translateY(0) scaleY(1);
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: background 0.15s;
  opacity: 0;
  transform: translateY(-6px);
  animation: suggestionSlideIn 0.3s ease forwards;
}

@keyframes suggestionSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.suggestion-item svg {
  flex-shrink: 0;
  color: rgba(255,255,255,0.25);
}

.suggestion-match {
  color: var(--accent);
  font-weight: 500;
}

.pill {
  padding: 5px 13px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pill:hover { color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.22); }

.pill.active {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ─── FAVOURITES ────────────────────────────────────── */

#favourites {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  max-width: 480px;
  width: 100%;
  min-height: 38px;
  flex-wrap: wrap;
}

#favourites-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}

.favourite {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;

  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.09);

  color: rgba(255,255,255,0.7);
  font-family: var(--font-ui);
  font-size: 12px;

  cursor: pointer;

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    color 0.2s ease;
}

.favourite:hover {
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.18);
  color: #fff;
  transform: translateY(-2px);
}

.favourite-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.favourite-fallback {
  width: 16px;
  height: 16px;
  border-radius: 4px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);

  font-size: 9px;
  font-weight: 600;
  flex-shrink: 0;
}

.favourite-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Delete button appears when hovering */

.favourite-remove {
  position: absolute;
  top: -6px;
  right: -6px;

  width: 17px;
  height: 17px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;

  background: rgba(15,15,20,0.95);
  color: rgba(255,255,255,0.55);

  font-size: 12px;
  line-height: 1;

  cursor: pointer;

  opacity: 0;
  transform: scale(0.7);

  transition:
    opacity 0.15s ease,
    transform 0.15s ease,
    color 0.15s ease;
}

.favourite:hover .favourite-remove {
  opacity: 1;
  transform: scale(1);
}

.favourite-remove:hover {
  color: #fff;
  background: rgba(255,70,70,0.8);
  border-color: rgba(255,100,100,0.8);
}

.favourite-add {
  height: 34px;
  padding: 0 12px;

  display: flex;
  align-items: center;
  gap: 6px;

  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,0.15);

  background: rgba(255,255,255,0.025);

  color: rgba(255,255,255,0.38);

  font-family: var(--font-ui);
  font-size: 12px;

  cursor: pointer;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  transition: all 0.2s ease;
}

.favourite-add:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 14px var(--accent-glow);
}

/* ─── FAVOURITE MODAL ───────────────────────────────── */

.favourite-modal {
  position: fixed;
  inset: 0;

  display: none;
  align-items: center;
  justify-content: center;

  z-index: 100;

  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.favourite-modal.visible {
  display: flex;
}

.favourite-modal-inner {
  width: 330px;

  padding: 18px;

  background: rgba(14,14,20,0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;

  box-shadow:
    0 30px 80px rgba(0,0,0,0.65),
    0 0 0 1px rgba(255,255,255,0.03);

  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);

  animation: favouriteModalIn 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes favouriteModalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.favourite-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin-bottom: 18px;

  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 500;
}

#close-favourite-modal {
  border: none;
  background: none;

  color: rgba(255,255,255,0.4);

  font-size: 20px;
  line-height: 1;

  cursor: pointer;

  transition: color 0.2s;
}

#close-favourite-modal:hover {
  color: #fff;
}

.favourite-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.favourite-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;

  color: rgba(255,255,255,0.45);

  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.favourite-form input {
  width: 100%;

  padding: 10px 11px;

  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.1);

  outline: none;

  background: rgba(255,255,255,0.06);
  color: #fff;

  font-family: var(--font-ui);
  font-size: 12px;

  transition: border-color 0.2s, background 0.2s;
}

.favourite-form input:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.09);
}

.favourite-form-buttons {
  display: flex;
  gap: 7px;
  margin-top: 4px;
}

.favourite-form-buttons .ghost-btn {
  flex: 1;
  margin: 0;
}

.favourite-save {
  flex: 1;

  padding: 9px;

  border: none;
  border-radius: 9px;

  background: var(--accent);
  color: #fff;

  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.favourite-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px var(--accent-glow);
}

/* ─── SETTINGS BUTTON ───────────────────────────────── */

@keyframes fadeToast {
  0%   { opacity:0; transform:translateX(-50%) translateY(6px); }
  15%  { opacity:1; transform:translateX(-50%) translateY(0); }
  75%  { opacity:1; }
  100% { opacity:0; }
}

#settings-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 20;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: all 0.25s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#settings-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.2);
  transform: rotate(45deg);
}

/* ─── GITHUB BUTTON ─────────────────────────────────── */
#github-btn {
  position: absolute;
  bottom: 24px;
  right: 76px; /* sits to the left of #settings-btn */
  z-index: 20;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: all 0.25s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#github-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

/* ─── SETTINGS PANEL ────────────────────────────────── */
#settings-panel {
  position: absolute;
  right: 24px;
  bottom: 80px;
  width: 290px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  display: none;
  z-index: 20;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
  animation: slideUp 0.22s cubic-bezier(0.34,1.56,0.64,1);
}

#settings-panel::-webkit-scrollbar { width: 3px; }
#settings-panel::-webkit-scrollbar-track { background: transparent; }
#settings-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--panel-border);
}

#close-settings {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s;
}
#close-settings:hover { color: #fff; }

.settings-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
}

.settings-section:last-child { border-bottom: none; }

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
  gap: 10px;
}

.setting-row:last-child { margin-bottom: 0; }

.setting-row > label:first-child {
  font-size: 13px;
  color: rgba(255,255,255,0.72);
  flex-shrink: 0;
}

.setting-row select,
.setting-row .text-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 5px 8px;
  width: 120px;
  outline: none;
  transition: border-color 0.2s;
}

.setting-row select:focus,
.setting-row .text-input:focus {
  border-color: var(--accent);
}

.setting-row select option { background: #1a1a2e; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: none;
  width: 32px;
  height: 28px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  outline: none;
}

/* ─── TOGGLE ────────────────────────────────────────── */
.toggle { position: relative; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: rgba(255,255,255,0.12);
  border-radius: 99px;
  transition: background 0.25s;
  position: relative;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), background 0.25s;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: #fff;
}

/* ─── PRESET GRID ───────────────────────────────────── */
#preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}

.preset {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.preset:hover { transform: scale(1.08); }

.preset.selected {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.preset-inner {
  width: 100%;
  height: 100%;
}

/* ─── UPLOAD / GHOST BUTTONS ────────────────────────── */
.upload-btn, .ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 9px;
  color: rgba(255,255,255,0.65);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 7px;
  text-align: center;
}

.upload-btn:hover, .ghost-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}

.ghost-btn { margin-bottom: 0; }

/* ─── CONFIG TEXTAREA ───────────────────────────────── */
.btn-row {
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
}

.btn-row .ghost-btn { margin-bottom: 0; }

textarea#importBox {
  width: 100%;
  height: 80px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 9px;
  color: rgba(255,255,255,0.65);
  font-family: monospace;
  font-size: 11px;
  padding: 8px;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea#importBox:focus { border-color: var(--accent); }

/* ─── SCROLLBAR GLOBAL ──────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }

.tutorial-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 5px 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.45);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover { color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.2); }

.tab-btn.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.tutorial-steps {
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial-steps li {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  line-height: 1.5;
}

.tutorial-steps strong {
  color: rgba(255,255,255,0.85);
}

.tutorial-steps code {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 7px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  font-size: 10px;
  color: var(--accent);
  word-break: break-all;
}
