.btn-primary {
  background:#fff; color:#000; border:none;
  padding:11px 22px; border-radius:40px;
  font-size:14px; font-weight:500;
  transition:all .3s var(--ease);
  white-space:nowrap; user-select:none;
  display:inline-flex; align-items:center; gap:7px;
}
.btn-primary:hover { background:rgba(255,255,255,.9); }
.btn-primary:active { transform:scale(.95); }

.btn-secondary {
  background:transparent; color:var(--text);
  border:1px solid var(--b2); padding:11px 22px;
  border-radius:40px; font-size:14px; font-weight:500;
  transition:all .3s var(--ease); white-space:nowrap; user-select:none;
  display:inline-flex; align-items:center; gap:7px;
}
.btn-secondary:hover { background:rgba(255,255,255,.08); border-color:var(--b3); }
.btn-secondary:active { transform:scale(.95); }

.btn-float {
  width:42px; height:42px; min-width:42px; border-radius:50%;
  background:transparent; border:1px solid var(--b1);
  display:flex; align-items:center; justify-content:center;
  transition:all .3s var(--ease); user-select:none;
}
.btn-float:hover { background:rgba(255,255,255,.06); border-color:var(--b2); }
.btn-float:active { transform:scale(.95); }
.btn-float img { width:20px; height:20px; filter:brightness(0) invert(1); }

.si { filter:brightness(0) invert(1); pointer-events:none; user-select:none; }
.si-acc {
  filter:brightness(0) saturate(100%) invert(50%) sepia(80%) saturate(500%) hue-rotate(195deg) brightness(110%);
  pointer-events:none; user-select:none;
}

.chip {
  display:inline-flex; align-items:center; gap:5px;
  padding:4px 12px; background:rgba(62,145,255,.1);
  border:1px solid rgba(62,145,255,.2); border-radius:20px;
  font-size:12px; color:var(--accent); user-select:none;
}

.skeleton {
  background:linear-gradient(90deg,rgba(255,255,255,.04) 25%,rgba(255,255,255,.08) 50%,rgba(255,255,255,.04) 75%);
  background-size:200% 100%; animation:shimmer 1.4s infinite; border-radius:6px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.spinner-ring {
  width:16px; height:16px; flex-shrink:0;
  border:2px solid rgba(62,145,255,.2); border-top-color:var(--accent);
  border-radius:50%; animation:spin .8s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }

#home-view {
  display:flex; flex-direction:column; align-items:center;
  justify-content:center; min-height:100vh; padding:0 var(--safe); position:relative;
}

.home-top {
  position:absolute; top:0; left:0; right:0;
  display:flex; align-items:center; justify-content:flex-end;
  padding:16px var(--safe); gap:10px;
}

.home-logo {
  display:flex; align-items:center; gap:10px;
  margin-bottom:40px; user-select:none;
}
.home-logo img { width:52px; height:52px; filter:brightness(0) invert(1); }
.home-logo-text {
  font-size:2.6rem; font-weight:700; letter-spacing:-.5px;
  background:linear-gradient(135deg,#fff 0%,rgba(255,255,255,.6) 100%);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text;
}

.search-wrap { width:100%; max-width:620px; position:relative; }
.search-box {
  width:100%; background:rgba(255,255,255,.05); border:1px solid var(--b1);
  border-radius:40px; padding:14px 56px 14px 52px;
  font-size:16px; color:var(--text); outline:none;
  transition:background .3s var(--ease),border-color .3s var(--ease);
  user-select:text;
}
.search-box::placeholder { color:var(--text-4); }
.search-box:focus { background:rgba(255,255,255,.08); border-color:var(--b2); }

.s-icon-l {
  position:absolute; left:18px; top:50%; transform:translateY(-50%);
  width:18px; height:18px; filter:brightness(0) invert(1); opacity:.5;
}
.s-clear {
  position:absolute; right:16px; top:50%; transform:translateY(-50%);
  background:none; border:none; display:none; align-items:center;
  justify-content:center; width:28px; height:28px; border-radius:50%;
  transition:background .2s var(--ease); user-select:none;
}
.s-clear:hover { background:rgba(255,255,255,.08); }
.s-clear:active { transform:translateY(-50%) scale(.9); }
.s-clear img { width:14px; height:14px; filter:brightness(0) invert(1); }

.history-dropdown {
  position:absolute; top:calc(100% + 6px); left:0; right:0;
  background:var(--bg-card-solid); border:1px solid var(--b1);
  border-radius:16px; z-index:500; display:none; overflow:hidden;
  box-shadow:0 8px 24px rgba(0,0,0,.4);
}
.history-dropdown.open { display:block; }
.history-item {
  display:flex; align-items:center; gap:10px;
  padding:10px 16px; cursor:pointer; font-size:13px;
  color:var(--text-2); transition:background .15s; user-select:none;
}
.history-item:hover { background:rgba(255,255,255,.06); }
.history-item img { width:14px; height:14px; filter:brightness(0) invert(1); opacity:.4; }
.history-item span { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.history-item .h-del {
  opacity:0; transition:opacity .15s; pointer-events:auto; cursor:pointer;
  padding:2px 4px; border-radius:4px;
}
.history-item:hover .h-del { opacity:.5; }
.history-item .h-del:hover { opacity:1; background:rgba(255,255,255,.1); }

.home-actions { display:flex; gap:10px; margin-top:24px; user-select:none; }

.home-footer {
  position:absolute; bottom:0; left:0; right:0;
  padding:14px var(--safe); border-top:1px solid var(--b1);
  display:flex; align-items:center; gap:20px; flex-wrap:wrap;
}
.home-footer a { font-size:13px; color:var(--text-3); transition:color .2s; user-select:none; }
.home-footer a:hover { color:var(--text-2); }

#results-view { display:none; flex-direction:column; min-height:100vh; }

.r-header {
  position:sticky; top:0; z-index:200;
  background:rgba(10,10,10,.95);
  border-bottom:1px solid var(--b1);
  padding:10px var(--safe);
  display:flex; align-items:center; gap:14px;
}

.r-logo {
  font-size:1.2rem; font-weight:700; cursor:pointer; white-space:nowrap;
  user-select:none; flex-shrink:0;
  background:linear-gradient(135deg,#fff 0%,rgba(255,255,255,.6) 100%);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text;
}

.r-search-wrap { position:relative; flex:1; max-width:560px; }
.r-search-box {
  width:100%; background:rgba(255,255,255,.05); border:1px solid var(--b1);
  border-radius:40px; padding:9px 42px;
  font-size:15px; color:var(--text); outline:none;
  transition:background .3s var(--ease),border-color .3s var(--ease); user-select:text;
}
.r-search-box::placeholder { color:var(--text-4); }
.r-search-box:focus { background:rgba(255,255,255,.08); border-color:var(--b2); }
.r-s-icon {
  position:absolute; left:14px; top:50%; transform:translateY(-50%);
  width:16px; height:16px; filter:brightness(0) invert(1); opacity:.5;
}
.r-clear {
  position:absolute; right:11px; top:50%; transform:translateY(-50%);
  background:none; border:none; display:none; align-items:center;
  justify-content:center; width:26px; height:26px; border-radius:50%;
  transition:background .2s var(--ease); user-select:none;
}
.r-clear:hover { background:rgba(255,255,255,.08); }
.r-clear:active { transform:translateY(-50%) scale(.9); }
.r-clear img { width:13px; height:13px; filter:brightness(0) invert(1); }

.r-header-right {
  display:flex; align-items:center; gap:8px;
  margin-left:auto; flex-shrink:0;
}

.avatar-btn {
  width:32px; height:32px; border-radius:50%;
  border:1.5px solid var(--b2); overflow:hidden;
  display:none; cursor:pointer; flex-shrink:0;
  transition:border-color .2s; position:relative;
}
.avatar-btn:hover { border-color:var(--accent); }
.avatar-btn img { width:100%; height:100%; object-fit:cover; }

.avatar-popup {
  position:absolute; top:calc(100% + 8px); right:0;
  background:var(--bg-card-solid); border:1px solid var(--b1);
  border-radius:16px; padding:16px; width:200px;
  box-shadow:0 8px 24px rgba(0,0,0,.5); z-index:300;
  display:none; flex-direction:column; align-items:center; gap:10px;
}
.avatar-popup.open { display:flex; }
.avatar-popup-img {
  width:86px; height:86px; border-radius:50%;
  border:2px solid var(--b2); object-fit:cover;
}
.avatar-popup-name {
  font-size:13px; font-weight:500; text-align:center;
  color:var(--text-2); user-select:none;
}
.avatar-popup-btns { display:flex; flex-direction:column; gap:6px; width:100%; }
.avatar-popup-btns button {
  width:100%; padding:9px 14px; border-radius:40px; font-size:13px;
  font-weight:500; transition:all .2s var(--ease); user-select:none;
}
.btn-logout {
  background:transparent; color:var(--text-2);
  border:1px solid var(--b2);
}
.btn-logout:hover { background:rgba(255,255,255,.08); border-color:var(--b3); }
.btn-manage {
  background:#fff; color:#000; border:none;
}
.btn-manage:hover { background:rgba(255,255,255,.9); }

.tabs-bar {
  position:sticky; top:53px; z-index:190;
  display:flex; align-items:center; gap:2px;
  padding:0 var(--safe); border-bottom:1px solid var(--b1);
  background:rgba(10,10,10,.98); overflow-x:auto; scrollbar-width:none;
}
.tabs-bar::-webkit-scrollbar { display:none; }

.tab-btn {
  background:none; border:none; color:var(--text-3);
  font-size:13px; padding:11px 15px; white-space:nowrap;
  position:relative; transition:color .2s var(--ease);
  user-select:none; display:flex; align-items:center; gap:7px; min-height:42px;
}
.tab-btn img { width:15px; height:15px; filter:brightness(0) invert(1); opacity:.5; transition:opacity .2s; }
.tab-btn:hover { color:var(--text-2); }
.tab-btn:hover img { opacity:.7; }
.tab-btn.active { color:var(--accent); }
.tab-btn.active img {
  opacity:1;
  filter:brightness(0) saturate(100%) invert(50%) sepia(80%) saturate(500%) hue-rotate(195deg) brightness(110%);
}
.tab-btn.active::after {
  content:''; position:absolute; bottom:0; left:0; right:0;
  height:2px; background:var(--accent); border-radius:2px 2px 0 0;
}

.r-main {
  display:flex; gap:28px; padding:22px var(--safe) 48px;
  max-width:1120px; width:100%; margin:0 auto;
}
.r-col { flex:1; min-width:0; }
.r-info { font-size:12px; color:var(--text-3); margin-bottom:18px; user-select:none; }

.r-sidebar {
  width:300px; flex-shrink:0; display:flex; flex-direction:column; gap:14px;
}

.ai-card {
  background:var(--bg-card); backdrop-filter:blur(20px);
  border:1px solid rgba(62,145,255,.18); border-radius:20px; padding:18px 20px;
  transition:border-color .3s var(--ease); position:relative; overflow:hidden;
}
.ai-card:hover { border-color:rgba(62,145,255,.3); }
.ai-card-header {
  display:flex; align-items:center; gap:7px; margin-bottom:10px; user-select:none;
}
.ai-card-label {
  font-size:11px; font-weight:600; color:var(--accent);
  text-transform:uppercase; letter-spacing:.5px;
}
.ai-card-img {
  position:absolute; top:14px; right:14px;
  width:56px; height:34px; border-radius:6px;
  object-fit:cover; border:1px solid var(--b1);
}
.ai-card-text {
  font-size:13px; color:var(--text-2); line-height:1.72;
  user-select:text; padding-right:4px;
}
.ai-card-text.has-img { padding-right:72px; }
.ai-card-footer {
  display:flex; align-items:center; gap:8px; margin-top:12px;
  padding-top:10px; border-top:1px solid var(--b1);
  font-size:11px; color:var(--text-3); user-select:none;
}
.ai-card-footer img { width:12px; height:12px; filter:brightness(0) invert(1); opacity:.4; }

.kg-card {
  background:var(--bg-card); backdrop-filter:blur(20px);
  border:1px solid var(--b1); border-radius:20px; padding:20px;
  transition:border-color .3s var(--ease);
}
.kg-card:hover { border-color:var(--b2); }
.kg-title { font-size:18px; font-weight:600; margin-bottom:2px; user-select:text; }
.kg-type { font-size:12px; color:var(--text-3); margin-bottom:12px; user-select:text; }
.kg-desc {
  font-size:13px; color:var(--text-2); line-height:1.65;
  border-top:1px solid var(--b1); padding-top:12px; user-select:text;
}
.kg-links { display:flex; gap:7px; flex-wrap:wrap; margin-top:12px; }

.result-card {
  display:block; border-radius:14px; padding:13px 16px;
  margin-bottom:3px; transition:background .2s var(--ease);
}
.result-card:hover { background:rgba(255,255,255,.04); }
.result-card:active { transform:scale(.99); }
.r-source { display:flex; align-items:center; gap:7px; margin-bottom:3px; }
.r-fav { width:16px; height:16px; border-radius:3px; }
.r-url { font-size:12px; color:var(--text-3); user-select:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.r-title {
  font-size:17px; font-weight:500; color:#7ab8ff; margin-bottom:3px;
  line-height:1.3; user-select:text; transition:color .2s;
}
.result-card:hover .r-title { color:#9ecbff; }
.r-snip { font-size:13px; color:var(--text-2); line-height:1.65; user-select:text; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

.img-section { position:relative; }
.img-filters {
  display:flex; gap:8px; padding:0 0 14px; overflow-x:auto; scrollbar-width:none;
}
.img-filters::-webkit-scrollbar { display:none; }
.img-filter-chip {
  display:flex; align-items:center; gap:6px; padding:6px 14px;
  background:rgba(255,255,255,.05); border:1px solid var(--b1);
  border-radius:40px; font-size:12px; color:var(--text-2);
  white-space:nowrap; cursor:pointer; user-select:none; flex-shrink:0;
  transition:all .2s var(--ease);
}
.img-filter-chip img { width:12px; height:12px; border-radius:2px; }
.img-filter-chip:hover { background:rgba(255,255,255,.08); border-color:var(--b2); }

.img-grid {
  display:grid; gap:8px;
  grid-template-columns:repeat(auto-fill,minmax(278px,1fr));
}
.img-grid.panel-open { grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); }

.img-item {
  width:100%; height:168px; border-radius:10px; overflow:hidden;
  cursor:pointer; position:relative; background:rgba(255,255,255,.04);
  border:1px solid var(--b1); transition:transform .2s var(--ease);
}
.img-item:hover { transform:scale(1.02); border-color:var(--b2); }
.img-item.active { border:2px solid var(--accent); }
.img-item img { width:100%; height:100%; object-fit:cover; display:block; }
.img-item-src {
  position:absolute; bottom:0; left:0; right:0;
  background:linear-gradient(transparent,rgba(0,0,0,.7));
  padding:18px 8px 6px; display:flex; align-items:center; gap:5px;
  opacity:0; transition:opacity .2s;
}
.img-item:hover .img-item-src { opacity:1; }
.img-item-src img { width:12px; height:12px; border-radius:2px; }
.img-item-src span { font-size:11px; color:rgba(255,255,255,.7); user-select:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.img-panel {
  position:sticky; top:110px; width:320px; flex-shrink:0;
  background:var(--bg-card); border:1px solid var(--b1);
  border-radius:20px; padding:0; overflow:hidden;
  display:none; max-height:calc(100vh - 130px); overflow-y:auto;
}
.img-panel.open { display:block; }
.img-panel-close {
  position:absolute; top:10px; right:10px; z-index:2;
  background:rgba(0,0,0,.5); border:none; border-radius:50%;
  width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:background .2s;
}
.img-panel-close:hover { background:rgba(0,0,0,.8); }
.img-panel-close img { width:14px; height:14px; filter:brightness(0) invert(1); }
.img-panel img.preview { width:100%; object-fit:contain; max-height:260px; background:#000; display:block; }
.img-panel-info { padding:14px 16px; }
.img-panel-title { font-size:13px; font-weight:500; margin-bottom:6px; user-select:text; line-height:1.4; }
.img-panel-domain { font-size:12px; color:var(--text-3); margin-bottom:12px; user-select:none; }
.img-panel-btns { display:flex; gap:8px; }
.img-panel-btns a {
  flex:1; padding:9px; border-radius:40px; font-size:12px; font-weight:500;
  text-align:center; transition:all .2s var(--ease); display:block;
}

.video-card {
  display:flex; gap:14px; align-items:flex-start;
  border-radius:14px; padding:13px 16px; margin-bottom:3px;
  transition:background .2s var(--ease);
}
.video-card:hover { background:rgba(255,255,255,.04); }
.video-thumb {
  width:224px; height:126px; flex-shrink:0; border-radius:10px;
  background:rgba(62,145,255,.06); border:1px solid var(--b1);
  overflow:hidden; display:flex; align-items:center; justify-content:center;
}
.video-thumb img.thumb-img { width:100%; height:100%; object-fit:cover; }
.video-thumb img.thumb-icon { width:28px; height:28px; opacity:.3; }

.news-card {
  display:flex; gap:12px; align-items:flex-start;
  border-radius:14px; padding:13px 16px; margin-bottom:3px;
  transition:background .2s var(--ease);
}
.news-card:hover { background:rgba(255,255,255,.04); }
.news-thumb {
  width:80px; height:60px; flex-shrink:0; border-radius:8px;
  background:rgba(255,255,255,.04); border:1px solid var(--b1); overflow:hidden;
}
.news-thumb img { width:100%; height:100%; object-fit:cover; }

.sk-card { padding:13px 16px; margin-bottom:3px; }
.sk-line { height:10px; margin-bottom:8px; }

.img-section-wrap { display:flex; gap:14px; align-items:flex-start; }
.img-grid-wrap { flex:1; min-width:0; }

.r-footer {
  text-align:center; padding:28px var(--safe) 48px;
  border-top:1px solid var(--b1); margin-top:16px;
}
.r-footer p { font-size:12px; color:var(--text-3); user-select:none; }
.r-footer a { color:var(--text-3); transition:color .2s; }
.r-footer a:hover { color:var(--text-2); }

@media(max-width:900px) {
  .r-sidebar { width:260px; }
  .img-panel { width:260px; }
}
@media(max-width:768px) {
  .r-sidebar { display:none; }
  .r-main { padding:14px var(--safe) 48px; }
  .r-header-right .btn-primary { display:none; }
  .video-thumb { width:140px; height:79px; }
  .img-grid { grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); }
  .img-item { height:100px; }
  .img-panel { width:100%; position:fixed; bottom:0; left:0; right:0; top:auto; border-radius:20px 20px 0 0; max-height:70vh; }
}
@media(max-width:480px) {
  .home-logo-text { font-size:1.9rem; }
  .home-logo img { width:40px; height:40px; }
  .home-actions { flex-direction:column; width:100%; max-width:300px; }
  .home-actions button { justify-content:center; }
  .r-header { gap:8px; }
  .r-logo { font-size:1.1rem; }
  .img-grid { grid-template-columns:repeat(auto-fill,minmax(130px,1fr)); }
  .img-item { height:90px; }
  .video-card { flex-direction:column; }
  .video-thumb { width:100%; height:160px; }
}
