/* ============ CORSER Search Engine — Professional Styles ============ */
:root {
  --navy-dark: #050B18;
  --navy: #0A1533;
  --card: #0F1E3D;
  --card-light: #162B52;
  --cyan: #22D3EE;
  --cyan-bright: #00E5FF;
  --purple: #6366F1;
  --white: #F8FAFC;
  --grey: #94A3B8;
  --grey-dim: rgba(148,163,184,.55);
  --danger: #EF4444;
  --radius: 30px;
  --trans: .22s cubic-bezier(.4,0,.2,1);
}
[data-theme="light"] {
  --navy-dark: #Eef4fb;
  --navy: #ffffff;
  --card: #ffffff;
  --card-light: #dbe7f5;
  --white: #0B1B33;
  --grey: #5A6B85;
  --grey-dim: rgba(90,107,133,.55);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* CRITICAL: ensure the hidden attribute always wins over display rules
   (fixes settings modal & other panels being stuck visible) */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', 'Cairo', Tahoma, Arial, sans-serif;
  background: var(--navy-dark);
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background .35s;
}

/* ============ Background ============ */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 130%); }
.glow { position: absolute; border-radius: 50%; filter: blur(120px); opacity: .2; }
.glow-1 { width: 380px; height: 380px; background: var(--cyan); top: -120px; right: -100px; animation: drift1 12s ease-in-out infinite; }
.glow-2 { width: 420px; height: 420px; background: var(--purple); bottom: -160px; left: -120px; animation: drift2 14s ease-in-out infinite; }
.glow-3 { width: 240px; height: 240px; background: #0EA5E9; top: 40%; left: 55%; opacity: .1; animation: drift1 16s ease-in-out infinite reverse; }
@keyframes drift1 { 0%,100% { transform: translate(0,0);} 50% { transform: translate(-60px,50px);} }
@keyframes drift2 { 0%,100% { transform: translate(0,0);} 50% { transform: translate(55px,-45px);} }
.stars { position: absolute; inset: 0; }
.star { position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: rgba(255,255,255,.5); animation: twinkle 3.5s ease-in-out infinite; }
[data-theme="light"] .star { background: rgba(11,27,51,.25); }
@keyframes twinkle { 0%,100% { opacity: .15;} 50% { opacity: .7;} }

/* ============ Header ============ */
.header {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
}
.header-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: 3px; font-size: 15px;
  background: linear-gradient(90deg, var(--cyan-bright), var(--purple));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  opacity: 0; transform: translateY(-8px); transition: all .4s .1s; }
.header-brand.show { opacity: 1; transform: none; }
.mini-orb { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 32% 28%, var(--cyan-bright), var(--purple) 75%);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900; color: #050B18; -webkit-text-fill-color: #050B18;
  box-shadow: 0 0 14px rgba(34,211,238,.4); }
.header-nav { display: flex; gap: 8px; }
.hbtn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--card-light);
  background: var(--card); color: var(--grey); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: var(--trans); }
.hbtn:hover { color: var(--cyan-bright); border-color: var(--cyan); box-shadow: 0 0 12px rgba(34,211,238,.25); }

/* ============ Main / Hero ============ */
.main { position: relative; z-index: 2; flex: 1; width: 100%; max-width: 680px;
  margin: 0 auto; padding: 4vh 20px 40px; display: flex; flex-direction: column; align-items: center; }
.hero { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; }
.logo-orb {
  width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--cyan-bright), var(--purple) 75%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 46px rgba(34,211,238,.45), inset 0 0 26px rgba(255,255,255,.18);
  animation: pulse 3.4s ease-in-out infinite;
  cursor: pointer; transition: transform .2s;
}
.logo-orb:active { transform: scale(.94); }
.logo-orb span { font-size: 46px; font-weight: 900; color: #050B18; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 34px rgba(34,211,238,.35), inset 0 0 26px rgba(255,255,255,.18); }
  50%     { box-shadow: 0 0 64px rgba(34,211,238,.62), inset 0 0 26px rgba(255,255,255,.24); }
}
.brand { margin-top: 16px; font-size: clamp(34px, 8vw, 44px); font-weight: 900; letter-spacing: clamp(6px, 2vw, 10px);
  background: linear-gradient(90deg, var(--cyan-bright), var(--purple));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  padding-right: clamp(6px, 2vw, 10px); }
.tagline { margin-top: 7px; font-size: 13px; color: var(--grey); letter-spacing: 1.5px; }

/* ============ Search ============ */
.search-area { width: 100%; display: flex; flex-direction: column; align-items: center; }
.search-wrap { width: 100%; position: relative; z-index: 20; }
.search-box {
  display: flex; align-items: center; width: 100%;
  background: var(--card);
  border: 1.5px solid rgba(34,211,238,.35);
  border-radius: var(--radius);
  padding: 4px 6px 4px 4px;
  box-shadow: 0 4px 26px rgba(0,0,0,.28), 0 0 20px rgba(34,211,238,.1);
  transition: var(--trans);
}
.search-box:focus-within { border-color: var(--cyan-bright); box-shadow: 0 4px 26px rgba(0,0,0,.3), 0 0 32px rgba(0,229,255,.3); }
.search-box.has-suggestions { border-radius: 24px 24px 0 0; }
.s-icon { flex-shrink: 0; margin: 0 14px 0 6px; color: var(--cyan); }
#q { flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--white); font-size: 16.5px; padding: 14px 2px; font-family: inherit; }
#q::placeholder { color: var(--grey-dim); font-size: 14.5px; }
.icon-btn { flex-shrink: 0; width: 38px; height: 38px; border: none; background: transparent;
  color: var(--grey); cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; transition: var(--trans); }
.icon-btn:hover { color: var(--cyan-bright); background: rgba(34,211,238,.08); }
#micBtn.listening { color: var(--danger); animation: micPulse 1s ease-in-out infinite; }
@keyframes micPulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.18);} }
.go-btn { flex-shrink: 0; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #050B18; font-weight: 800; font-size: 14.5px;
  padding: 12px 24px; border-radius: 26px; font-family: inherit;
  transition: transform .15s, box-shadow .2s; margin-right: 4px; }
.go-btn:hover { box-shadow: 0 0 20px rgba(34,211,238,.5); }
.go-btn:active { transform: scale(.93); }

/* ============ Suggestions ============ */
.suggestions {
  position: absolute; top: 100%; right: 0; left: 0;
  background: var(--card);
  border: 1.5px solid var(--cyan-bright); border-top: none;
  border-radius: 0 0 24px 24px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  max-height: min(420px, 52vh); overflow-y: auto;
}
.sug {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; cursor: pointer; transition: background .15s;
  font-size: 14.5px; color: var(--white);
}
.sug:hover, .sug.active { background: rgba(34,211,238,.1); }
.sug .sug-ico { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: var(--grey); }
.sug .sug-ico img { width: 18px; height: 18px; border-radius: 4px; }
.sug .sug-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug .sug-text b { color: var(--cyan-bright); font-weight: 700; }
.sug .sug-hint { flex-shrink: 0; font-size: 11px; color: var(--grey-dim);
  border: 1px solid var(--card-light); padding: 2px 9px; border-radius: 10px; }
.sug.site-sug .sug-text { color: var(--cyan-bright); font-weight: 600; }
.sug.history-sug .sug-ico { color: var(--purple); }

/* ============ Categories ============ */
.categories { display: flex; gap: 7px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.cat { display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--card-light); background: var(--card);
  color: var(--grey); font-size: 12.5px; padding: 8px 16px;
  border-radius: 20px; cursor: pointer; font-family: inherit; transition: var(--trans); }
.cat.active { background: linear-gradient(135deg, rgba(34,211,238,.16), rgba(99,102,241,.16));
  border-color: var(--cyan); color: var(--cyan-bright); font-weight: 700;
  box-shadow: 0 0 12px rgba(34,211,238,.18); }
.cat:hover:not(.active) { border-color: rgba(34,211,238,.4); color: var(--white); }

/* ============ Engines ============ */
.engines { display: flex; align-items: center; gap: 7px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.engines-label { font-size: 11.5px; color: var(--grey-dim); }
.chip { border: 1px solid var(--card-light); background: transparent;
  color: var(--grey); font-size: 11.5px; padding: 6px 13px;
  border-radius: 16px; cursor: pointer; font-family: inherit; transition: var(--trans); }
.chip.active { border-color: var(--cyan); color: var(--cyan-bright); font-weight: 700;
  background: rgba(34,211,238,.09); }
.corser-chip { display: inline-flex; align-items: center; gap: 7px;
  border-color: var(--cyan); color: var(--cyan-bright); font-weight: 700;
  background: rgba(34,211,238,.09); cursor: default; }

/* ============ Quick access ============ */
.quick-section, .recent-section { width: 100%; margin-top: 38px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.section-head h2 { font-size: 14.5px; font-weight: 700; color: var(--white); opacity: .88; letter-spacing: .4px; }
.edit-btn { border: none; background: transparent; color: var(--cyan); font-size: 12px;
  cursor: pointer; font-family: inherit; padding: 4px 8px; border-radius: 8px; transition: var(--trans); }
.edit-btn:hover { background: rgba(34,211,238,.1); }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 16px 8px; }
.quick-item { display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; text-decoration: none; position: relative; }
.quick-icon { width: 56px; height: 56px; border-radius: 18px;
  background: var(--card); border: 1px solid rgba(34,211,238,.2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: var(--trans); }
.quick-item:hover .quick-icon { transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.3), 0 0 14px rgba(34,211,238,.2); border-color: var(--cyan); }
.quick-item:active .quick-icon { transform: scale(.92); }
.quick-icon img { width: 30px; height: 30px; border-radius: 7px; object-fit: contain; }
.quick-item span { font-size: 11px; color: var(--grey); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-item .remove-link { position: absolute; top: -6px; left: -6px;
  width: 20px; height: 20px; border-radius: 50%; border: none;
  background: var(--danger); color: #fff; font-size: 12px; line-height: 1;
  cursor: pointer; display: none; align-items: center; justify-content: center; z-index: 2; }
.quick-grid.editing .remove-link { display: flex; }
.quick-grid.editing .quick-icon { animation: wiggle .35s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-2.2deg);} to { transform: rotate(2.2deg);} }
.add-link .quick-icon { border-style: dashed; color: var(--cyan); font-size: 26px; }

/* ============ Recent ============ */
.recent-list { display: flex; flex-direction: column; gap: 6px; }
.recent-item { display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid transparent;
  border-radius: 14px; padding: 11px 16px; cursor: pointer;
  font-size: 13.5px; color: var(--grey); transition: var(--trans); }
.recent-item:hover { border-color: rgba(34,211,238,.35); color: var(--white); }
.recent-item svg { flex-shrink: 0; color: var(--purple); }
.recent-item .r-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .r-del { border: none; background: transparent; color: var(--grey-dim);
  cursor: pointer; padding: 4px; border-radius: 6px; }
.recent-item .r-del:hover { color: var(--danger); }

/* ============ Footer ============ */
.footer { position: relative; z-index: 2; padding: 22px 16px 26px; }
.footer-inner { text-align: center; font-size: 11.5px; color: var(--grey-dim); line-height: 1.9; }
.footer .sep { margin: 0 8px; }
.grad { background: linear-gradient(90deg, var(--cyan-bright), var(--purple));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ============ Modal ============ */
.modal-backdrop { position: fixed; inset: 0; z-index: 100;
  background: rgba(5,11,24,.72); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 430px; background: var(--navy);
  border: 1px solid var(--card-light); border-radius: 22px; padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  animation: modalIn .25s cubic-bezier(.34,1.4,.64,1); }
@keyframes modalIn { from { opacity: 0; transform: scale(.92) translateY(14px);} to { opacity: 1; transform: none;} }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 17px; }
.setting-row { display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 13px 0; border-bottom: 1px solid rgba(148,163,184,.09); }
.setting-row:last-child { border-bottom: none; }
.setting-title { font-size: 14px; font-weight: 600; }
.setting-sub { font-size: 11.5px; color: var(--grey-dim); margin-top: 3px; line-height: 1.5; }

/* Switch */
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; border-radius: 26px; cursor: pointer;
  background: var(--card-light); transition: .25s; }
.slider::before { content: ''; position: absolute; width: 20px; height: 20px;
  border-radius: 50%; background: var(--grey); top: 3px; right: 3px; transition: .25s; }
.switch input:checked + .slider { background: rgba(34,211,238,.35); }
.switch input:checked + .slider::before { background: var(--cyan-bright); transform: translateX(-20px); }

/* ============ Redirect overlay ============ */
.redirecting { position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(180deg, var(--navy-dark), var(--navy));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0;} to { opacity: 1;} }
.redirecting .r-brand { font-size: 28px; font-weight: 900; letter-spacing: 7px;
  background: linear-gradient(90deg, var(--cyan-bright), var(--purple));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.spinner { width: 44px; height: 44px; border-radius: 50%;
  border: 3.5px solid rgba(34,211,238,.15); border-top-color: var(--cyan-bright);
  animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg);} }
.redirecting .r-query { color: var(--grey); font-size: 13.5px; max-width: 80%;
  text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Compact mode (after typing) ============ */
@media (max-width: 480px) {
  .main { padding-top: 3vh; }
  .logo-orb { width: 82px; height: 82px; }
  .logo-orb span { font-size: 38px; }
  .go-btn { padding: 11px 18px; }
  .engines-label { display: none; }
}
@media (max-height: 640px) {
  .hero { margin-bottom: 16px; }
  .logo-orb { width: 70px; height: 70px; }
  .logo-orb span { font-size: 32px; }
  .brand { font-size: 30px; margin-top: 10px; }
}
